position recovery/take profit  [SOLVED]

Questions about MultiCharts and user contributed studies.
moreno
Posts: 22
Joined: 29 May 2019
Has thanked: 19 times

position recovery/take profit

Postby moreno » 29 Jun 2020

Hi,
trying to build a recovery signal for losing position. when an unrealized loss in an open position (1 contract long) reach -50 since it was entered then sell 2 contracts (reverse position).
both entry signal and recovery/take profit signal runs at the same time.
i wrote the code below but it doesn't work as I expected.
it doesn't sell 2 contracts when the loss reaches -50 and it closes potion in a bigger loss (from -80 to -140...).
who can help with this?

the full code of recovery signal -

Code: Select all

if openpositionprofit < -50 then sell ("recovery 1") 2 contracts this bar at close; setprofittarget(100);

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: position recovery/take profit  [SOLVED]

Postby TJ » 29 Jun 2020

Look up the keyword

SELLSHORT

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: position recovery/take profit

Postby TJ » 29 Jun 2020

>>it closes potion in a bigger loss (from -80 to -140...).

This could be caused by a lot of reasons.

eg.
fast market
you did not set IOG
coding logic
etc.,

moreno
Posts: 22
Joined: 29 May 2019
Has thanked: 19 times

Re: position recovery/take profit

Postby moreno » 30 Jun 2020

thanks, TJ!


Return to “MultiCharts”