Navigation:Home > Content >

Neon.mq4

Time: 2017-08-01 | Download file:Neon.mq4

//+------------------------------------------------------------------+
//|                                                      ProjectName |
//|                                      Copyright 2012, CompanyName |
//|                                       http://www.companyname.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2016, Crossluck"
#property version "1.03"
#property description "Neon"
//-----------------------------------------------------------------------------------------------------------------------------//
#property strict
//-----------------------------------------------------------------------------------------------------------------------------//
#property indicator_separate_window
#property indicator_buffers 6
#property indicator_color1 clrAqua
#property indicator_width1 3
#property indicator_color2 clrAqua
#property indicator_width2 1
#property indicator_color3 clrAqua
#property indicator_width3 1
#property indicator_color4 clrAqua
#property indicator_width4 3
#property indicator_color5 clrAqua
#property indicator_width5 1
#property indicator_color6 clrAqua
#property indicator_width6 1
//-----------------------------------------------------------------------------------------------------------------------------//
extern string S1="Settings ADX";
extern int period=14;
extern ENUM_APPLIED_PRICE applied_price=0;
extern int trend_strength=20;
extern string S2="Settings Moving Average";
extern int ma_period=14;
extern int ma_shift=0;
extern ENUM_MA_METHOD ma_method=0;
extern ENUM_APPLIED_PRICE ma_applied_price=0;
extern string S3="Graphics Settings";
extern bool ClearAllObjects=true;
extern int CountedBars=1000;
extern bool UseADX=true;
extern bool UseMa=false;
extern bool UseVolume=false;
extern string S4="Sound Settings";
extern string SoundFile="alert.wav";
extern bool UseSound=true;
//-----------------------------------------------------------------------------------------------------------------------------//
string LF="\n";
//-----------------------------------------------------------------------------------------------------------------------------//
int ObjCount=0;
int current=0;
//-----------------------------------------------------------------------------------------------------------------------------//
double up[];
double upma[];
double upvolume[];
double down[];
double downma[];
double downvolume[];
//-----------------------------------------------------------------------------------------------------------------------------//
bool buy=false;
bool buyma=false;
bool buyvolume=false;
bool sell=false;
bool sellma=false;
bool sellvolume=false;
//-----------------------------------------------------------------------------------------------------------------------------//
bool sBuy=false;
bool sSell=false;
//-----------------------------------------------------------------------------------------------------------------------------//
int init()
  {
   if(ClearAllObjects)ObjectsDeleteAll();
   IndicatorShortName("NEON");
   IndicatorDigits(5);
   IndicatorBuffers(6);
   SetIndexBuffer(0,up);
   SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID);
   SetIndexBuffer(1,upma);
   SetIndexStyle(1,DRAW_ARROW,STYLE_SOLID);
   SetIndexArrow(1,217);
   SetIndexBuffer(2,upvolume);
   SetIndexStyle(2,DRAW_ARROW,STYLE_SOLID);
   SetIndexArrow(2,217);
   SetIndexBuffer(3,down);
   SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_SOLID);
   SetIndexBuffer(4,downma);
   SetIndexStyle(4,DRAW_ARROW,STYLE_SOLID);
   SetIndexArrow(4,218);
   SetIndexBuffer(5,downvolume);
   SetIndexStyle(5,DRAW_ARROW,STYLE_SOLID);
   SetIndexArrow(5,218);
   IndicatorSetDouble(INDICATOR_MINIMUM,-10);
   IndicatorSetDouble(INDICATOR_MAXIMUM,10);
   IndicatorSetInteger(INDICATOR_LEVELCOLOR,clrDarkSlateGray);
   return(0);
  }
//-----------------------------------------------------------------------------------------------------------------------------//
int deinit()
  {
   if(ClearAllObjects)ObjectsDeleteAll();
   return(0);
  }
//-----------------------------------------------------------------------------------------------------------------------------//
int start()
  {
   Tick();
   return(0);
  }
//-----------------------------------------------------------------------------------------------------------------------------//
void Tick()
  {
   for(int i=CountedBars;i>=0;i--)
     {
      current=i;
      up();
      upma();
      upvolume();
      down();
      downma();
      downvolume();
     }
  }
//-----------------------------------------------------------------------------------------------------------------------------//
void up()
  {
   if(UseADX)
      if(buy==false)
         if(iADX(NULL,PERIOD_CURRENT,period,applied_price,MODE_PLUSDI,current)>iADX(NULL,PERIOD_CURRENT,period,applied_price,MODE_MINUSDI,current)
            && 
            (iADX(NULL,PERIOD_CURRENT,period,applied_price,MODE_MAIN,current)>=trend_strength))
           {
            arrows_up();
           }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void arrows_up()
  {
   up[current]=5;
   buy=true;
   sell=false;
  }
//-----------------------------------------------------------------------------------------------------------------------------//
void upma()
  {
   if(UseMa)
      if(buyma==false)
         if(iADX(NULL,PERIOD_CURRENT,period,applied_price,MODE_PLUSDI,current)>iADX(NULL,PERIOD_CURRENT,period,applied_price,MODE_MINUSDI,current)
            && 
            (iADX(NULL,PERIOD_CURRENT,period,applied_price,MODE_MAIN,current)>=trend_strength)
            && 
            (Open[current]>iMA(NULL,PERIOD_CURRENT,ma_period,ma_shift,ma_method,ma_applied_price,current)
            && 
            (iMA(NULL,PERIOD_CURRENT,ma_period,ma_shift,ma_method,ma_applied_price,current)>(iMA(NULL,PERIOD_CURRENT,ma_period,ma_shift,ma_method,ma_applied_price,current+1)))))
           {
            arrows_upma();
           }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void arrows_upma()
  {
   upma[current]=6;
   buyma=true;
   sellma=false;
  }
//-----------------------------------------------------------------------------------------------------------------------------//
void upvolume()
  {
   if(UseVolume)
      if(buyvolume==false)
         if(iADX(NULL,PERIOD_CURRENT,period,applied_price,MODE_PLUSDI,current)>iADX(NULL,PERIOD_CURRENT,period,applied_price,MODE_MINUSDI,current)
            && 
            (iADX(NULL,PERIOD_CURRENT,period,applied_price,MODE_MAIN,current)>=trend_strength)
            && 
            (iVolume(NULL,PERIOD_CURRENT,current+1)>(iVolume(NULL,PERIOD_CURRENT,current+2))))
           {
            arrows_upvolume();
           }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void arrows_upvolume()
  {
   upvolume[current]=7;
   buyvolume=true;
   sellvolume=false;
  }
//-----------------------------------------------------------------------------------------------------------------------------//
void down()
  {
   if(UseADX)
      if(sell==false)
         if(iADX(NULL,PERIOD_CURRENT,period,applied_price,MODE_PLUSDI,current)=trend_strength))
           {
            arrows_down();
           }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void arrows_down()
  {
   down[current]=-5;
   buy=false;
   sell=true;
  }
//-----------------------------------------------------------------------------------------------------------------------------//
void downma()
  {
   if(UseMa)
      if(sellma==false)
         if(iADX(NULL,PERIOD_CURRENT,period,applied_price,MODE_PLUSDI,current)=trend_strength)
            && 
            (Open[current]=trend_strength)
            && 
            (iVolume(NULL,PERIOD_CURRENT,current+1)>(iVolume(NULL,PERIOD_CURRENT,current+2))))
           {
            arrows_downvolume();
           }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void arrows_downvolume()
  {
   downvolume[current]=-7;
   buyvolume=false;
   sellvolume=true;
//-----------------------------------------------------------------------------------------------------------------------------//
   if(up[0]!=EMPTY_VALUE && up[0]!=0 && sBuy)
     {
      sBuy=false;
      if(UseSound)PlaySound(SoundFile);
      Alert("(Neon)" " He entered a buy signal on the symbol "+Symbol()+", on the time-frame "+(string)Period()+" min.,"+" by price "+(string)Bid);
     }
   if(!sBuy && (up[0]==EMPTY_VALUE || up[0]==0))sBuy=true;
//-----------------------------------------------------------------------------------------------------------------------------//
   if(upma[0]!=EMPTY_VALUE && upma[0]!=0 && sBuy)
     {
      sBuy=false;
      if(UseSound)PlaySound(SoundFile);
      Alert("(Neon)" " He entered a buy signal on the symbol "+Symbol()+", on the time-frame "+(string)Period()+" min.,"+" by price "+(string)Bid);
     }
   if(!sBuy && (upma[0]==EMPTY_VALUE || upma[0]==0))sBuy=true;
//-----------------------------------------------------------------------------------------------------------------------------//
   if(upvolume[0]!=EMPTY_VALUE && upvolume[0]!=0 && sBuy)
     {
      sBuy=false;
      if(UseSound)PlaySound(SoundFile);
      Alert("(Neon)" " He entered a buy signal on the symbol "+Symbol()+", on the time-frame "+(string)Period()+" min.,"+" by price "+(string)Bid);
     }
   if(!sBuy && (upvolume[0]==EMPTY_VALUE || upvolume[0]==0))sBuy=true;
//-----------------------------------------------------------------------------------------------------------------------------//
   if(down[0]!=EMPTY_VALUE && down[0]!=0 && sSell)
     {
      sSell=false;
      if(UseSound)PlaySound(SoundFile);
      Alert("(Neon)" " He entered a sell signal on the symbol "+Symbol()+", on the time-frame "+(string)Period()+" min.,"+" by price "+(string)Bid);
     }
   if(!sSell && (down[0]==EMPTY_VALUE || down[0]==0))sSell=true;
//-----------------------------------------------------------------------------------------------------------------------------//
   if(downma[0]!=EMPTY_VALUE && downma[0]!=0 && sSell)
     {
      sSell=false;
      if(UseSound)PlaySound(SoundFile);
      Alert("(Neon)" " He entered a sell signal on the symbol "+Symbol()+", on the time-frame "+(string)Period()+" min.,"+" by price "+(string)Bid);
     }
   if(!sSell && (downma[0]==EMPTY_VALUE || downma[0]==0))sSell=true;
//-----------------------------------------------------------------------------------------------------------------------------//
   if(downvolume[0]!=EMPTY_VALUE && downvolume[0]!=0 && sSell)
     {
      sSell=false;
      if(UseSound)PlaySound(SoundFile);
      Alert("(Neon)" " He entered a sell signal on the symbol "+Symbol()+", on the time-frame "+(string)Period()+" min.,"+" by price "+(string)Bid);
     }
   if(!sSell && (downvolume[0]==EMPTY_VALUE || downvolume[0]==0))sSell=true;
  }
//-----------------------------------------------------------------------------------------------------------------------------//

Recommend