Open e Close pending Order
-
I intend to experiment my first ea with this strategy : Calculate the minimum and maximum from 2.00 to 3:30 am and set two pending buy and sell orders on these two values with the trade closing at 20:00. the stop loss should be 10/15 pips and go to breakeven if the direction is in profit in the opposite direction (in profit). I've now sketched out (with very little FX experience) something like this, but it opens many trades (not just two) and doesn't close at the specified time. moreover, the last trades in the backtest do not close them at all. I am attaching the code diagram. I would also like to implement a trailing for profitable positions and the consequent breakeven for the opposite position. If anyone could help me figure out the steps, the functions to insert, and what's missing in the logic I'd be grateful.
shared/pHuPOi6Lb
-
-
@Denim You need some changes. Firstly, you need to modify the launcher. According to your initial description, you will need something like this:

That way there will be just one only buy and one only sell.
-
Thank you for the explanation! I applied the filter and now it works almost fine. The only thing I still haven't figured out is how to close the order that remains open (if it's not in profit) by 10pm on the same day at the latest. If it doesn't close that one, it doesn't open others.
-
@Denim Then you need to apply a second time filter like this:

You will need to coordinate the one you are already using with this one in order to avoid conflicting each other.
-
@l-andorrà Sorry for the constant questions. I tried to apply the suggested filter but evidently I didn't quite understand how to apply it in the scheme to close open or pending operations. I also have another question: pending orders away from the current price. can they progressively "move" closer to the current price to either close or open?
-
Let's move step by step. Can you please share the link to your last version of the project? I will take a look at it.
-
@l-andorrà The project is this. Maybe I didn't quite understand how to implement closing an order for minimum loss and how to set the movement of pending orders closer to the current price. Here is the project (if you can call it that..)
-
The end time of your time filter block needs to be later that the start time. This is why it doesn't work.