Okay here's the order execution code from my EA, the problem I'm having is that it only seems to open orders in the direction I put first in the code... So for this code it only opens short positions, however if I swap the Buy and Sell orders around it opens long and not short positions. I just get invalid stop errors opening BUY/SELL order depending on which one is last in the code. If i change the stop loss and take profit to 0 in the last one it places trades but i need to put stops in obviously... Anyone see what I'm doing wrong?
Try deleting this return(0); I suspect that you never reach the second trade loop:}
else Print("Error opening SELL order : ",GetLastError());
return(0);
}
for(cnt=0;cnt<OrdersTotal();cnt++)
HTH
Keith
Try deleting this return(0); I suspect that you never reach the second trade loop:}
else Print("Error opening SELL order : ",GetLastError());
return(0);
}
for(cnt=0;cnt<OrdersTotal();cnt++)
HTH
Keith
No I get error opening BUY order :130 from the second loop. It must be something to do with the stops because if I set them to be fixed values say 100*point then it works. However I want my stops to be based on the ATR and that doesnt seem possible at the moment. Having said that it happily puts variable stops on the sell orders, so im not sure whats going on... The SL is calculated as twice the ATR times by my ATR multiplier which ive set at 1 for now. The TP is calculated very similarly just it's 5 times the ATR. Thanks for the suggestion thou Keith

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Okay here's the order execution code from my EA, the problem I'm having is that it only seems to open orders in the direction I put first in the code... So for this code it only opens short positions, however if I swap the Buy and Sell orders around it opens long and not short positions. I just get invalid stop errors opening BUY/SELL order depending on which one is last in the code. If i change the stop loss and take profit to 0 in the last one it places trades but i need to put stops in obviously... Anyone see what I'm doing wrong?