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 jeronymite, 04-12-2024, 04:26 PM
      3 responses
      44 views
      0 likes
      Last Post jeronymite  
      Started by Barry Milan, Yesterday, 10:35 PM
      7 responses
      20 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by AttiM, 02-14-2024, 05:20 PM
      10 responses
      179 views
      0 likes
      Last Post jeronymite  
      Started by ghoul, Today, 06:02 PM
      0 responses
      10 views
      0 likes
      Last Post ghoul
      by ghoul
       
      Started by DanielSanMartin, Yesterday, 02:37 PM
      2 responses
      13 views
      0 likes
      Last Post DanielSanMartin  
      Working...
      X