-
for(int iCount = OrdersTotal()-1; iCount<=0; iCount--)
If you have two or more orders, your loop does nothing.
If you have one or zero, you have an infinite loop.
-
lastIsBuy = TRUE;
This will be set if you have any open buy orders.
-
if(lastOPBuy!=OrderOpenPrice()) lastOPBuy=OrderOpenPrice();
Since it is unlikely that you will have two buy orders opened at the same exact price, lastOPBuy will be the open price of the earliest order, not the last.
William Roeder #: If you have two or more orders, your loop does nothing.
Yes I fix this problem by changing the operation and addd break statement so that it will stop at the first buy or sell order.
A quick question, if the grid is 5 pips and I use Ask+5 pips for buy order, the price doesn't always filled at the exact price, the only way for it to be exact is using stop order. is this correct?
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
Hi I create an EA using grid technic. the EA will open the first order according to a specific logic and then the grid technic will run after it. I have 2 problem that I faced:
first one is that the EA failed to safe last open order if price is below last open order for buy order or if price is above last open order for sell order,
second, it failed to open third order if there's 2 open order, the EA will stop at break statement even though there's still 2 open order.
I don't know if this 2 problem is connected or not but I can't find the problem myself. can anyone tell me where's the problem?