Set Take Profit to the TP of the first position

Created at 25 Aug 2023, 17:33
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
CT

ctid3999979

Joined 05.07.2021

Set Take Profit to the TP of the first position
25 Aug 2023, 17:33


Hi

I'm creating a trend following bot and would like to stack positions along the trend.

In Psuedocode, I'd like to dow this:

1. If number of open positions is greater than 0
2. Get Take Profit price of the fir open position.
3. Set the Take profit of the last open position to the price in step 2.

So I would like all my positions to have the same take profit as the first position I open for any given trend.

I've noticed though that you can only give the ExecuteMarketOrder function a Take Profit as the number of pips away from the execution price. Am I wrong here?

Would I have to open the order and then use a ModifyTakeprofitPrice method to change it to match the first position?
 


@ctid3999979
Replies

PanagiotisChar
26 Aug 2023, 14:54 ( Updated at: 26 Aug 2023, 15:01 )

Hi there,

Yeap that is correct.

Aieden Technologies

Need help? Join us on Telegram


@PanagiotisChar