[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 166

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Gentlemen professionals, I need your help again!
Below is a snippet of code responsible for closing trades, but the thing is that when pending orders are not executed it does not delete them, I can't figure out why. But when I need to close a pending order that has already been executed, everything goes correctly and if the order hasn't been executed then it just hangs there until it executes...
OrderSelect(0, SELECT_BY_POS, MODE_TRADES);
Magic = OrderMagicNumber();
orderticket = OrderTicket();
if (OrdersTotal() == 1 && Magic == 111 && OrderType( ) == 0) {
if (H1_BUY_5 == 0 || H1_BUY_1 == 0) {
OrderClose(orderticket, lots, Bid, 5, Yellow);
if (OrdersTotal() == 1) OrderDelete(orderticket, Brown);
}
}
This is the condition that selects only buy orders,
if (OrdersTotal() == 1 && Magic == 111 && OrderType( ) == 0)
so there is no way to remove the pending order
Probably because you calculate the lot first and then
Thanks, changed the lot calculation, but it still doesn't work.
How does it not work, what does it say in the logs?
Check what values np takes, here
There are no error messages in the logbook. Can you look at the whole EA code? It should close 1/3 of lot if stoploss already moved to breakeven by trawl.
Oooooooo how messed up everything is. In general, everything is wrong, easier to throw out and write a new one. Parameters are defined incorrectly, functions are called incorrectly, a lot of unnecessary calculations. Good for a tutorial on how not to write code.
Oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo messy. All in all, it's all wrong, it's easier to throw it away and write a new one. Parameters are defined incorrectly, functions are called incorrectly, a lot of unnecessary calculations. It will be good for a tutorial on how not to write code.
...Should close 1/3 of the lot if a stop loss already moved to breakeven by the trawl is triggered.
I look at all this and think to myself - why take on such tasks if you are not sure of the basics? This kind of self-study does more good than harm. The spark of thought drowns in a pile of mistakes.
Probably meant more harm than good.
Please advise us, gentlemen!
Imagine the situation: a stop is triggered, because of the triggering of the N-th condition. But after a couple of candlesticks, the N-th condition has fallen away. With the help of which function you can open the deal again after the N-th condition falls out. That is, you need to determine that triggered a stop some number of bars ago, and because the N-th condition has fallen away, repeat the trade!