
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 everyone, new to the forum and very new to programming - been mostly teaching myself by doing and reading a LOT of forum posts. Anyway, working on an EA which is based on a simple box breakout strategy - at a certain time, EA establishes high and low price over X bars and places buy stop and sell stop above and below respectively. After X hours the orders are closed. There's other aspects to it but that's the very basics and all that's necessary to include at this stage.
This is the order management part of the EA. I added a OneCancelsTheOther feature - when one of the buy/sell stops is activated, the remaining 'pending' order is deleted. When tested this works.
I have been trying to add a MoveStopLossToBreakEven feature (if half way to profit target, stop loss changed to order open price) which has not been successful. I've added the coding I'm using for this part below but it is uncompiled and simply to demonstrate roughly the method I've been going for.
Though most of it works, it seems inefficient and the MoveStopLossToBreakEven doesn't work when tested. Any suggestions for improvement appreciated.