hi everyone,
I would like to set a take profit condition for a proorder strategy.
The take profit must be set at the level of the daily pivot point when the position is opened.
I tried with this code:
// Conditions for exiting long positions
indicator6 = (DHigh (1) + DLow (1) + DClose (1)) / 3
c26 = (close <= indicator6)
IF c26 THEN
SELL AT MARKET
ENDIF
unfortunately with this code the pivot point is updated according to the new price trend. I would like to set the take profit at the level of the daily pivot point at the time the order is opened.
It can be done?
thanx Marco
Just save the value at the time that the buy order is placed and then place a pending sell stop order at each bar close. Alternatively just sell at that price or below that price as you did in your code.
if (your conditions) then
buy 1 contract at market
exitprice = (DHigh (1) + DLow (1) + DClose (1)) / 3
sell at exitprice stop
endif
IF longonmarket THEN
sell at exitprice stop
ENDIF
if (your conditions) then
buy 1 contract at market
exitprice = (DHigh (1) + DLow (1) + DClose (1)) / 3
endif
IF longonmarket and close <= exitprice THEN
sell at market
ENDIF
Note: Please use the ‘Insert PRT Code’ button when putting code in your future posts as it makes it easier for others to read. I have tidied up your post for you. 🙂
thanks for the reply Vonasi, and thank you for ordering my post. In the future I will use the right function to enter the codes here.