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 jclose, Today, 09:37 PM
      0 responses
      4 views
      0 likes
      Last Post jclose
      by jclose
       
      Started by WeyldFalcon, 08-07-2020, 06:13 AM
      10 responses
      1,413 views
      0 likes
      Last Post Traderontheroad  
      Started by firefoxforum12, Today, 08:53 PM
      0 responses
      9 views
      0 likes
      Last Post firefoxforum12  
      Started by stafe, Today, 08:34 PM
      0 responses
      10 views
      0 likes
      Last Post stafe
      by stafe
       
      Started by sastrades, 01-31-2024, 10:19 PM
      11 responses
      169 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Working...
      X