Hi,
I am trying to develop a code for an strategy with multiple targets where each sum of the target account for the total profit; example if price reach target 1, then target2 and finally target 3 I can count each as a profit in a sum will give the total profit.
Same with Breakeven where Breakeven do not count as a loss neither a profit.
Thank you in advance;
that is very vague, can you elaborate, i am not sure what you are asking for?
i don't know what a sum of target means?
what are the rules and conditions, for buying, selling, aborting?
are you buying all the desired shares on the initial buy signal?
are you buying more at a target? or selling some at a target level? how much?
what rules determine when to sell? what if price drops? or goes flat for 30 bars?
what happens if price doesn't reach a target? after how many bars do you abort and reset things and sell, for a loss?
make an outline with 3 sections,
buy, sell, abort,
and list every possible condition and the rules to follow
or think of it this way,
where do you want to see something? chart
what do you want to see?
when do you want to see it?
this would be a way to start,
when a buy happens, the close price could be saved like this,
def buy = ... some condition
def buy_price = if barnumber() == 1 then 0 else if buy then close else buy_price[1];
#then buy_price can be referenced and targets and stops calculated from it.
input target1_percent = 0.5;
plot target1 = if buy_price > 0 then buy_price * (1+ (target1_percent/100)) else double.nan;