Code Help : Avoid re Entry

 

Hi everybody. I need your help.

I try to make simple EA. But I have problem.

I want code to avoid my ea open new order when at the same bar

I already have close order.

Example : Pair USD/JPY Time Frame H1.

At 10.10 EA open Buy Order, Price going up. At 10.35 EA close

this position. After order close EA cannot make another order until

11.00 ( Same bar with close previous order ). EA can make order again

at 11.01 because this is a new bar.

Thank you for your help.

 

double bar;

when you make a trade then set

bar=Bars;

in the options to make the trade add

if bar!=Bars && more of your code is req to make a better judgement

 
wisnuw:
Hi everybody. I need your help.

I try to make simple EA. But I have problem.

I want code to avoid my ea open new order when at the same bar

I already have close order.

Example : Pair USD/JPY Time Frame H1.

At 10.10 EA open Buy Order, Price going up. At 10.35 EA close

this position. After order close EA cannot make another order until

11.00 ( Same bar with close previous order ). EA can make order again

at 11.01 because this is a new bar.

Thank you for your help.

Either post the code or PM me, I can add the code for you.

 

please can someone add arrows to this indy

hi all,

could a coder please add (green) up and (red) down arrows to indicator window when the lines cross on this indicator.

im trying to judge by eye but is it quite difficult

many thanks

 

Perky and fxd01, thanks for your help.

I already add code like Perky suggest but did not solve the problem.

What I want is if EA already close previous order. EA cannot

make another open order at the same bar of close previous order.

For TF H1

If EA open pending BUY_STOP at 10.30 the bar will be close at 10.59

and the order open at 11.10 ( next bar of open order ) if at 11.30 EA close the order. at 11.40 EA still can make another order because previous pending order was make at 10.30 ( last bar ).

 
wisnuw:
Perky and fxd01, thanks for your help.

I already add code like Perky suggest but did not solve the problem.

What I want is if EA already close previous order. EA cannot

make another open order at the same bar of close previous order.

For TF H1

If EA open pending BUY_STOP at 10.30 the bar will be close at 10.59

and the order open at 11.10 ( next bar of open order ) if at 11.30 EA close the order. at 11.40 EA still can make another order because previous pending order was make at 10.30 ( last bar ).

just add some code like this

int PrevOP;

int Order=OrdersHistoryTotal()

for(int i=Order-1;i>=0;i--)

{

if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) break;

if(OrderSymbol()!=Symbol() || OrderType()==OP_SELL || OrderType()==OP_BUY) continue;

//----

if(OrderCloseTime()>Time[0]) PrevOp++;

}

if (PrevOP>0) ===> don't trading..... OK

Thanks

 

Thanks mas awoo5182,

I will try to attach your code to my EA.

I hope this will solve my problem.

 

Need help how to auto reset EA after executed

Hi, I would like to need your expert help on how to reset EA value back to default value after it executed once. Thanks for your help.

Reason: