How to make dynamic profit target and stop loss in ninjascript

952 Views Asked by At
  • set Profit Target PT1 = 10, Stop Loss SL = 1%
  • When reach exit PT 1 then close half of the position "long1", set stop loss to breakeven, and PT 2 = first break in opposite direction to the trade entry direction. so, when I meet the first red candle after exiting half of the position, I'd like to sell the another half of the position "long2". If not, exit at stop loss = breakeven.

How to make dynamic pt and sl?

if (Position.MarketPosition == MarketPosition.Long)
{
     SetProfitTarget("Long_1", CalculationMode.Price, vwap[0] + Close[0] * ProfitTargetPercent);
     SetStopLoss("Long_1", CalculationMode.Percent, StopLossPercent, false);
}               
...
EnterLong("Long_1");
EnterLong("Long_2");                    
0

There are 0 best solutions below