ea doesn't work

To add comments, please log in or register
ludovico97
18
ludovico97  

I'm not capable to understand why this simple EA doesn't work... Can someone help me? :)

the mt4 doesn't give any error but when i start the backtest there aren't opened orders... :/

EDIT: Code removed and added in a later post

Konstantin Nikitin
11950
Konstantin Nikitin  

Insert the correct code

ludovico97
18
ludovico97  
double Ticket;

void OnTick(){

   OpenOrder_Long();
   CloseOrder_Long();

}

void OpenOrder_Long(){

   if(iClose(Symbol(), 0, 1) > iHigh(Symbol(), 0, iHighest(Symbol(), 0, MODE_HIGH, 50, 1))&&
      
      OrdersTotal() == 0){
   
      Ticket = OrderSend(Symbol(), OP_BUY, 0.5, Ask, 0, 0, 0, 0, 0, 0, 0);
   
   }

}
   
void CloseOrder_Long(){
   
   if(iClose(Symbol(), 0, 1) < iLow(Symbol(), 0, iLowest(Symbol(), 0, MODE_LOW, 50, 1))){
   
      OrderClose(Ticket, OrderLots(), Ask, 0, 0);
   
   }

}
ludovico97
18
ludovico97  
ups... i'm sorry, i'm new to the forum. thanks
William Roeder
18697
William Roeder  
ludovico97: I'm not capable to understand why this simple EA doesn't work...
if(iClose(Symbol(), 0, 1) > iHigh(Symbol(), 0, iHighest(Symbol(), 0, MODE_HIGH, 50, 1))

How can the Close of bar 1 ever be higher than the highest bar [49 … 1]? How can the Close of bar 1 be higher than the High of bar 1?

ludovico97
18
ludovico97  
William Roeder:

How can the Close of bar 1 ever be higher than the highest bar [49 … 1]? How can the Close of bar 1 be higher than the High of bar 1?

Oh god... Thank you so much... Now i undestand
To add comments, please log in or register