Download MetaTrader 5
To add comments, please log in or register
Share links from other resources. Now they have a description.
Bryan McAfee
970
Bryan McAfee 2014.11.12 16:37 

Hi all I am trying to get a indi of mine to use the alert price minus the open price of the candle 2 candles later, if that makes sense.

 It basically sums up some stats for me then.

 I have everything working fine except for it to wait for 2 candles to run the calculations.

I removed all my attempts at getting it to work and have the code posted below, any help would be loved!!!

 

 static datetime dtlboai11;

   static int NewSignal,Win,Loss;

   static double SignalPrice;

   if(dtlboai11!=iTime(Symbol(),0,0))

   {

    // calculate profit 

     if(NewSignal==1)

     {

      if(SignalPrice-Open[0]>=0)

       Win++;

      else 

       Loss++;

      NewSignal=0; 

     }

    else if(NewSignal==-1)

    {

      if(SignalPrice-Open[0]<=0)

       Win++;

      else 

       Loss++;

     NewSignal=0;

    } 
Enrico Lambino
4280
Enrico Lambino 2014.11.12 21:23  
bryan.mcafee:

Hi all I am trying to get a indi of mine to use the alert price minus the open price of the candle 2 candles later, if that makes sense.

 It basically sums up some stats for me then.

 I have everything working fine except for it to wait for 2 candles to run the calculations.

I removed all my attempts at getting it to work and have the code posted below, any help would be loved!!!


Doing it backwards will be easier. You can use Open[2] rather than the static variable SignalPrice. The code is also missing a closing bracket, so I am assuming that you are setting the new value for dtlboai11 (and SignalPrice) at each new bar. If not, then the condition will not execute, as dtlboai11 will always be zero.

/
To add comments, please log in or register