Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy COBC=false, Indicator COBC=true?

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

    Strategy COBC=false, Indicator COBC=true?

    Hi Ninja Team,

    This is probably a simple thing but has me scratching my head. I have a simple MA cross strategy with an entry and trail stop running on five min bars, CalculateOnBarClose = false so that it enters and trails on every tick.

    The thing is I want the indicators (the MAs) to be CalculateOnBarClose=true.

    I've tried Add(PeriodType.Tick, 1) with the Strategy COBC set to true, then moved the SetStopLoss() logic from Initialize() to OnBarUpdate like this;

    ...OnBarUpdate()
    if(BarsInProgress ==1)// 1 tick series
    {
    SetTrailStop(etc etc);
    }

    DoSomethingElse at close of bar;

    But that still seems to only fire at close of bar.

    Am I missing something simple?

    Thanks!

    #2
    Originally posted by MXASJ View Post
    Hi Ninja Team,

    This is probably a simple thing but has me scratching my head. I have a simple MA cross strategy with an entry and trail stop running on five min bars, CalculateOnBarClose = false so that it enters and trails on every tick.

    The thing is I want the indicators (the MAs) to be CalculateOnBarClose=true.

    I've tried Add(PeriodType.Tick, 1) with the Strategy COBC set to true, then moved the SetStopLoss() logic from Initialize() to OnBarUpdate like this;

    ...OnBarUpdate()
    if(BarsInProgress ==1)// 1 tick series
    {
    SetTrailStop(etc etc);
    }

    DoSomethingElse at close of bar;

    But that still seems to only fire at close of bar.

    Am I missing something simple?

    Thanks!
    Hi MXASJ, did you already check into this sample here?



    This would allow you to combine OnBarClose and OnEachTick calcs in the strategy using one frame only.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Forgot about that one!

      In the mean time, adding a line to reset my trail stops when flat seems to have solved my issue.

      In OnBarUpdate() before the trade logic:

      PHP Code:
      if (BarsInProgress == || Position.MarketPosition == MarketPosition.Flat
      {
      if(
      useTrailStopSetTrailStop(CalculationMode.TicksStopLoss);

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by gentlebenthebear, Today, 01:30 AM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by Aviram Y, Today, 05:29 AM
      2 responses
      7 views
      0 likes
      Last Post Aviram Y  
      Started by cls71, Today, 04:45 AM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by TradeForge, Today, 02:09 AM
      1 response
      23 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by elirion, Today, 01:36 AM
      2 responses
      14 views
      0 likes
      Last Post elirion
      by elirion
       
      Working...
      X