Trouble with bars

 

Hi everyone,

My very small EA is not counting the bars properly..... I thought that if I'm in a 5' chart window, it would do it, but it does not.

So because I'm new at this, I'm trying with something very small, just delivering buy stops and sell stops at 20 pips from the last bar high and low.

It does compiles fine, however the EA is sending many orders per bar, not just 1 and 1.

What is the problem with it?

//+------------------------------------------------------------------+

//| First try.mq4 |

//| Pablo |

//| |

//+------------------------------------------------------------------+

#property copyright "Pablo"

#property link ""

//---- input parameters

//+------------------------------------------------------------------+

//| expert initialization function |

//+------------------------------------------------------------------+

int init()

{

//----

//----

return(0);

}

//+------------------------------------------------------------------+

//| expert deinitialization function |

//+------------------------------------------------------------------+

int deinit()

{

//----

//----

return(0);

}

//+------------------------------------------------------------------+

//| expert start function |

//+------------------------------------------------------------------+

int start()

{

//----

int TicketPendingOrderLong, TicketPendingOrderShort;

double point;

point=MarketInfo(Symbol(),MODE_POINT);

{

TicketPendingOrderLong=OrderSend(Symbol(),OP_BUYSTOP,1.0,High[1]+20*Point,5,High[1]-10*Point,High[1]+50*Point,"Long pending order",16384,0,Green);

if(TicketPendingOrderLong<=0) Print("Error = ",GetLastError());

TicketPendingOrderShort=OrderSend(Symbol(),OP_SELLSTOP,1.0,Low[1]-20*Point,5,Low[1]+10*Point,Low[1]-50*Point,"Short pending order",16384,0,Green);

if(TicketPendingOrderShort<=0) Print("Error = ",GetLastError());

return(0);

}

//----

return(0);

}

//+------------------------------------------------------------------+
 

you did not block the max trade at a time and

did not code any thing related to the bar (except high and low)

 

Max trades at a time?

ohhh I see, I just finished an indicator that reads the bars, in this case the last one, so I'm going to attach it to my window and modify the EA to take data from it.

However you've mention something about limiting the trades by time??????? what is that????? I'm very thankful for your help, I'm new at this.

Pablo.

 

ie.

if(OrdersTotal()<1)

{

OrderSend(..........);

}

this will allow only 1 order at a time

 

thanks

thanks a lot phoenix, have a nice day

Reason: