Need help ! Basic counter ITM or OTM

To add comments, please log in or register
joshungtx
12
joshungtx  
#property strict
#property indicator_chart_window
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//---- input parameters
extern int ADX_period = 14;
extern bool UseADX_level        = true;
extern double ADX_level  = 23.6;

extern int CountBars=350;
extern bool Alert =true;
extern bool Sound =true;
extern bool Alert_via_Mobile = true;
extern string SoundFile="wait.waw";
//---- buffers
double val1[];
double val2[];
double b4plusdi,nowplusdi,b4minusdi,nowminusdi,b4adxmain,nowadxmain;
bool SoundBuy=False;
bool SoundSell=False;
string mss ="";
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- indicator line
   IndicatorBuffers(2);
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,108);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,108);
   SetIndexBuffer(0,val1);
   SetIndexBuffer(1,val2);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| AltrTrend_Signal_v2_2                                            |
//+------------------------------------------------------------------+
int start()
  {
   if (CountBars>=Bars) CountBars=Bars;
   SetIndexDrawBegin(0,Bars-CountBars);
   SetIndexDrawBegin(1,Bars-CountBars);
   int i,shift,limit,CountedBars=IndicatorCounted();
   if (CountedBars < 1)
     {
      for(i=0; i<=CountBars; i++) {val1[i]=0.0; val2[i]=0.0;}
     }

   if(CountedBars > 0) CountedBars--;
//----   
   limit=Bars - CountedBars;
//----
   for(shift=limit; shift>=0; shift--)
     {
      b4plusdi=iADX(NULL,0,ADX_period,PRICE_CLOSE,MODE_PLUSDI,shift+1);
      nowplusdi=iADX(NULL,0,ADX_period,PRICE_CLOSE,MODE_PLUSDI,shift);
      b4minusdi=iADX(NULL,0,ADX_period,PRICE_CLOSE,MODE_MINUSDI,shift+1);
      nowminusdi=iADX(NULL,0,ADX_period,PRICE_CLOSE,MODE_MINUSDI,shift);
      b4adxmain = iADX(NULL,0,ADX_period,PRICE_CLOSE,MODE_MAIN,shift+1);
      nowadxmain = iADX(NULL,0,ADX_period,PRICE_CLOSE,MODE_MAIN,shift);
 
  
   if   (UseADX_level) 
     {
      if (b4plusdi<b4minusdi && nowplusdi>nowminusdi  &&  nowadxmain >= ADX_level)
         
         val1[shift]=Low[shift]-5*Point;
         
       if (b4adxmain < ADX_level && nowadxmain > ADX_level && nowplusdi>nowminusdi)
         
         val1[shift]=Low[shift]-5*Point;
            
         
      if (b4plusdi>b4minusdi && nowplusdi<nowminusdi  &&  nowadxmain >= ADX_level)
       val2[shift]=High[shift]+5*Point;
      if (b4adxmain < ADX_level && nowadxmain > ADX_level && nowplusdi<nowminusdi)
          val2[shift]=High[shift]+5*Point;
         
         
         

 
     } 
   
     else 
      {
      if (b4plusdi<b4minusdi && nowplusdi>nowminusdi)
         {
         val1[shift]=Low[shift]-5*Point;
         }
      if (b4plusdi>b4minusdi && nowplusdi<nowminusdi)
         {
         val2[shift]=High[shift]+5*Point;
         }
       } 
     }
   if (val1[0]!=EMPTY_VALUE && val1[0]!=0 && SoundBuy)
     {
      SoundBuy=False;
      if (Alert) Alert(Symbol(), " M", Period(), " ADX Cross UP");
      if (Sound) PlaySound (SoundFile);
      mss = Symbol()+ " M" + Period() +" ADX Cross UP ";
      if (Alert_via_Mobile) SendNotification(mss);

      
     }
   if (!SoundBuy && (val1[0]==EMPTY_VALUE || val1[0]==0)) SoundBuy=True;
   if (val2[0]!=EMPTY_VALUE && val2[0]!=0 && SoundSell)
     {
      SoundSell=False;
      if (Sound) PlaySound (SoundFile);
      mss = Symbol()+ " M" + Period() +" ADX Cross Down ";
      if (Alert_via_Mobile) SendNotification(mss);
     }
   if (!SoundSell && (val2[0]==EMPTY_VALUE || val2[0]==0)) SoundSell=True;
   return(0);
  }
//+------

How I can counter  to draw a green check mark on the ITM (wins) Trades and a red X on the OTM (loss) trades  with input is expried time ?

here is "first coppycat indicator" . I want to modify but I just learn 2 days. Plz help me

Files:
To add comments, please log in or register