• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stategy stop enter positions

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

    Stategy stop enter positions

    Hello,
    I´m having problems with the stops of a strategy.

    Some times it stops entering the market when the conditions for entering are meet an only resumes when a new day starts..

    Here is the code:
    double stop; if (CurrentBar < Math.Max(PeriodStd, highWindow)) return; if (Bars.IsFirstBarOfSession) entriesPerWindowLeft = maxEntriesPerWindow; if (Position.MarketPosition == MarketPosition.Flat) SetStopLoss(CalculationMode.Currency, stopInCurrency); std0 = StdDev(PeriodStd)[0]; stop = std0< priceStopPoints ? std0* instrumentPointValue : priceStopPoints; double pullback = (Close[0] - MAX(highWindow)[0]) / std0; if (entriesPerWindowLeft > 0 && pullback >= DipBuy) { EnterLong(PositionLots); SetStopLoss(CalculationMode.Currency, stop); entriesPerWindowLeft--; } else if (pullback < DipBuy) { ExitLong(); entriesPerWindowLeft = maxEntriesPerWindow; }

    If a run a different version of the strategy, using the same stop value the situation does not occur

    if (CurrentBar<Math.Max(PeriodStd, highWindow)) return; if (Bars.IsFirstBarOfSession) entriesPerWindowLeft = maxEntriesPerWindow; if(Position.MarketPosition==MarketPosition.Flat) SetStopLoss(CalculationMode.Currency, stopInCurrency); double std0 = StdDev(PeriodStd)[0]; double pullback = (Close[0] - MAX(highWindow)[0]) / std0; if (entriesPerWindowLeft > 0 && pullback >= DipBuy) { EnterLong(PositionLots); entriesPerWindowLeft--; SetStopLoss(CalculationMode.Currency, stopInCurrency); } else if (pullback<DipBuy) { ExitLong(); entriesPerWindowLeft = maxEntriesPerWindow; }

    ​​​​​​​In attach is a print screen demonstrating the situation, the red and green vertical zones were trades should have taken place but at some point stop occurring. The two above blocks should (in my best judgment) yield the same numbers of trades, but that did not happened.

    Regards,

    Vava


    #2
    I forgot to mention that the behavior does not seem to occur in market replay

    Comment


      #3
      Hello vavatete,

      Thanks for your post.

      Please check the "Log" tab for any error messages related to your strategy during the course of its run. The log will list when the strategy was enabled as well as disabled and any orders it placed or errors it encountered.

      If no errors found then we suggest that you debug your strategy using print statements to determine the value of the variables employed in the trade entry/exit conditions when the entry/exits should have or should not have occurred. Print statements will send their information to the New>Ninjascript output window.

      Here is a link to our help guide's debugging tips for further information: https://ninjatrader.com/support/help...script_cod.htm

      Paul H.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by soulfx, Today, 03:57 AM
      0 responses
      1 view
      0 likes
      Last Post soulfx
      by soulfx
       
      Started by digibob, Today, 03:45 AM
      0 responses
      2 views
      0 likes
      Last Post digibob
      by digibob
       
      Started by Matts7, Today, 12:56 AM
      1 response
      14 views
      0 likes
      Last Post NinjaTrader_Marco  
      Started by barrybrice, Yesterday, 08:51 PM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_Marco  
      Started by hayleeabb, Today, 12:30 AM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_ChrisSch  
      Working...
      X