getLowestPriceThree
You have posted part of the code, which is incomplete. To increase the chances of getting help you should post your full source code
after that nothing that can be useful for the case. There is all the things that i trying to handle to avoid the error
nothing useful for the case
There is no need to create pending orders in code.
-
The pending has the slight advantage, A) you are closer to the top of the queue (filled quicker), B) there's no round trip network delay (filled quicker.)
Don't worry about it unless you're scalping M1 or trading news.
-
Humans can't watch the screen 24/7, so they use pending orders; EAs can, so no need for pending orders, have it wait until the market reaches the trigger price and just open an order.
There is no need to create pending orders in code.
-
The pending has the slight advantage, A) you are closer to the top of the queue (filled quicker), B) there's no round trip network delay (filled quicker.)
Don't worry about it unless you're scalping M1 or trading news.
-
Humans can't watch the screen 24/7, so they use pending orders; EAs can, so no need for pending orders, have it wait until the market reaches the trigger price and just open an order.
Especially, it happens for long, for short it happens a way less. But still huge amount of trades. Short function provided
double iLowPrice = iLow(NULL, 0, 0) * 0.9998; double stopLossOnce = getHighestPriceThree(); // Ensure the stop-loss level respects the minimum stop level double minStopLevel = SymbolInfoInteger(Symbol(), SYMBOL_TRADE_STOPS_LEVEL) * Point; double normalizedStopLossOnce = NormalizeDouble(stopLossOnce, Digits); double stopLoss = (normalizedStopLossOnce > Bid + minStopLevel) ? normalizedStopLossOnce : Bid + minStopLevel; // Ensure entry price is below the current Bid price double entryPrice = NormalizeDouble(iLowPrice, Digits); if(entryPrice >= Bid) { entryPrice = Bid - minStopLevel; // Set entry price to be beyond current Bid price } if(iLowPrice < Ask) { shortOpenedAt = TimeCurrent(); double lots = calculateLotSize(iLowPrice, stopLossOnce) / contractSize; lots = NormalizeDouble(lots, 1); openedOrder = OrderSend( Symbol(), OP_SELLSTOP, lots, entryPrice, slippage, stopLoss, 0, DoubleToString(priceProgress), MAGICMA, TimeCurrent() + order_expiration_time_short, clrRed ); if(openedOrder < 0) { Print("OrderSend failed with error short#", GetLastError()); } else { Print("OrderSend successfully: Ticket #", openedOrder); } } } } } }

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Was trying to handle that for almost 2 days, cannot find the solution. Understanding that it is cause the invalid stops didn't really help