Download MetaTrader 5

Last 3 Bars

To add comments, please log in or register
Move from theory to practice. Code Base will help you!
Jugler1986
22
Jugler1986 2016.08.24 08:04 

Hi guys,

 

got an issue about my first self programmed EA, again :-)

 

bool b_last3 = false;
                {
                   for(int i=1;i<4;i++)
                     {
                      if(i==4)break;
                      
                      if(Price.bar[i].close < MA[i])
                         {b_last3 = true;}

 so the boolean shall be set to true if the last 3 bars are below the equivalent MA line. In the following Buy condition it works. But only one time. So it understands "okay, the last 3 bars are below the MA and if the 4th bar closes above the MA I will open a Buy-Order" it works fine for now. but after it has reached the buy stop/take profit it never starts again to check these conditions, although it should do the same as above.

 Maybe someone could explain to me, if my array is wrong or if i forgot something like "reset everything to 0"-condition.

 

thanks a lot

 

jugler 

To add comments, please log in or register