my code below just prints best/worst equity when these are breached. And when equity hits X then closes all trades.
This worked fine for oever 3 months til my lateest update 5833. i dont know if this is a bug or is my amateur coding. Here's my coding below. If you see anything that is wrong or can be done better, PLEASE TELL ME.
klast week and today, it didnt close all trades when it was supposed to do so. and then, even when i manually right clicked on a trade and selected : Bulk Positions >> Close all positions, i had to do this 4 times before all my 100 trades had closed! i am suspicious about both my coding AND 5833.
I don't know if -1 is proper for a Deviation parameter:
trade.PositionClose(tk,-1); I do know that I don't have a problem in Build 5833, using 0 instead of -1.
I don't know if -1 is proper for a Deviation parameter:
I do know that I don't have a problem in Build 5833, using 0 instead of -1.
i have been using that line for years, no issues, but i have SetDeviation in my OnInit, so i never understood what i was meant to put on that Deviation parameter on the trade.PositionClose line.
I see that you have:
input int iSlippage = 1; // Slippage (in pips)
trade.SetDeviationInPoints(iSlippage);
But I don't see any pips to points conversion math.
TBH, I have no idea how your SetDeviaton code interacts with an attempt to override it with -1... in Build 5833.
On an unrelated note, your event handler header comments for OnInit() and OnTick() appear to be transposed.
Also, PositionsTotal() is an int.
Your custom define shows a ushort:
#define total0 (ushort)PositionsTotal()
for(int k = total0 - 1; k >= 0; k--)
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
my code below just prints best/worst equity when these are breached. And when equity hits X then closes all trades.
This worked fine for oever 3 months til my lateest update 5833. i dont know if this is a bug or is my amateur coding. Here's my coding below. If you see anything that is wrong or can be done better, PLEASE TELL ME.
klast week and today, it didnt close all trades when it was supposed to do so. and then, even when i manually right clicked on a trade and selected : Bulk Positions >> Close all positions, i had to do this 4 times before all my 100 trades had closed! i am suspicious about both my coding AND 5833.