Please I will apreciate if you may help me.
I want to close a position (long or short) partially when it is on profit when the price is at X% of TargetProfit. For example
Is Bar Open is True
AND MARKET POSITION IS LONG
AND Condition (Price, Indicator, etc.) > OpeningPrice+ConvertToRealPIPS((X/100)*TP), then ClosePartially (Order, Quantity)
My EA is making it well sometimes and it closes partially the position as my condition is triggered.
After the position partial closing, the condition is evaluated again as a new bar opened and if it is true, the EA closes the postion partially again for the same partial profit.
So the EA is closing the position partially more times that I was expected for the same TP if the condition is satisfied at each candle.
What I want is to close partially just one time per condition satisfied.
I will appreciate whatever suggestion.
- you need to use a “helper” variable. You can call it “partialTPhit” and set it to 0 (zero) by default as well as with opening the initial position using Assign Variable (partialTPhit) = 0.
- include this variable into your partial exit condition (IF partialTPhit = 0 AND “your other conditions”)
- below the condition add this action – Assign Variable (partialTPhit) = 1. This will prevent additional partial profit taking
For a next new trade it will be reset to work properly by the assign action set in step #1
Let me know if you need an example on this
Following your suggestion I have been able to get what I want by setting your setp-by-step for each partial close condition.
My EA has 3 partial TP at 25%, 50% & 75% of TP.
Thank you so much for your help
I have found that the trades using the full TP take a long time open. It means less number of trades for the strategy and loosing some oportunities that maybe are more profitable. So I am checking what happens if I close partially the position one or more times with a limit for the number of bars since the position was opened.
Thanks for your help
it can be easily done using partial close function
You must be logged in to reply to this topic.