Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

SetStopLoss problem activating strategy immediately submits stoploss and ProfitTarget

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    SetStopLoss problem activating strategy immediately submits stoploss and ProfitTarget

    In my strategy I enter multiple entries with separate Profit targets.
    But I want to protect profit if the trade starts failing.
    So the strategy enters one trade with PT with qty 4 , a low target.
    It also enters one trade for qty 2 next target
    An lastly enters 1 trade with qty 1 which would be the runner. highest target
    So in my condition if position is less than 2 (in other words the first two trades gave filled) then set stoploss to the postion.average + the first profit target, that way if the trade goes south it stops out.
    When I add the first condition it creates a stop and profit target as soon as strategy is enabled.
    Without it there are many $0.00 stop loss trades.
    What am I missing here to accomplish my desired outcome?

    /// Condition to set and reset the stoploss to the original stop
    if (Position.MarketPosition == MarketPosition.Flat)
    {
    SetStopLoss("",CalculationMode.Ticks, Stop,false);
    previousPrice = 0;
    }
    /// Condition to move the stop for the last trade to a new stop
    if (Position.Quantity < 2 && Position.MarketPosition == MarketPosition.Long && BarsSinceEntryExecution() > 3 && previousPrice == 0)
    {
    newStopLossTicks = Position.AveragePrice + L_Profit;
    SetStopLoss(CalculationMode.Price, newStopLossTicks);
    previousPrice = Position.AveragePrice;

    }

    #2
    I think it is resolved, what I was seeing was historical fills with stop and profit orders remaining from those fills. I have since added not to consider historical and it seems to work, testing today.

    Comment


      #3
      Hello set2win,

      Thanks for following up.

      If you are still having difficulty please reply back with any other details you have from your testing and we can review that further.

      I look forward to being of further assistance.
      JesseNinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by geotrades1, Today, 10:02 AM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by ender_wiggum, Today, 09:50 AM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by rajendrasubedi2023, Today, 09:50 AM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by bmartz, Today, 09:30 AM
      1 response
      10 views
      0 likes
      Last Post NinjaTrader_Erick  
      Started by geddyisodin, Today, 05:20 AM
      3 responses
      27 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Working...
      X