For a new bar test, Bars is unreliable (a refresh/reconnect can change number of bars on chart,) volume is unreliable (miss ticks,) Price is unreliable (duplicate prices and The == operand. - MQL4 programming forum.) Always use time.
New candle - MQL4 programming forum #3 2014.04.04
I disagree with making a new bar function, because it can only be called once per tick. A variable can be tested multiple times.
Running EA once at the start of each bar - MQL4 programming forum 2011.05.06
already did like what you suggest but the result is the same. Does mt4 cannot process more than one open position condition?
Show all of the relevant code.
if(IsNewCandle()) { if(!CheckIfOpenOrdersByMagicNumber(magicNumberWeak)) //check if there's open position with specific magic number { if(FuncOpenPosition() == 3) { double stopLossPrice = NormalizeDouble((Bid + spread) - (stoploss*Point()),Digits); double takeProfitPrice = NormalizeDouble((Bid + spread) + takeProfitWeakPosition*Point(),Digits); double lotSize = NormalizeDouble(OptimalLotSize(riskPerTrade,Ask,stopLossPrice)/lotType,2); orderId = OrderSend(Symbol(),OP_BUY,lotSize,Ask,0,stopLossPrice,takeProfitPrice,"Weak BUY",magicNumberStrong); } if(FuncOpenPosition() == 4) { double stopLossPrice = NormalizeDouble((Bid + stoploss*Point()),Digits); double takeProfitPrice = NormalizeDouble(Bid - takeProfitWeakPosition*Point(),Digits); double lotSize = NormalizeDouble(OptimalLotSize(riskPerTrade,Bid,stopLossPrice)/lotType,2); orderId = OrderSend(Symbol(),OP_SELL,lotSize,Bid,0,stopLossPrice,takeProfitPrice,"Weak SELL",magicNumberStrong); } } }
this all the relevant code. This is the only code that repeating open position
this all the relevant code

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi everyone,
I've created EA that using ichimoku indi as a condition to open order. In the EA I've created 2 magic number to open a STRONG or WEAK open position. The problem of this EA is when the indicator indicates there's a WEAK open position and start to open position every tick like the ss I've attached. Here's my code for the WEAK open position.
I've already using a function that will run every new candle but it seems doesn't work. My code for IsNewCandle func is like this.
I've tried many times to fix this issue and still doesn't know what cause it to happened like this. Hopefully you guys can help me to tell me where the error is.
Thank you