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 funk10101, Today, 09:43 PM
      0 responses
      6 views
      0 likes
      Last Post funk10101  
      Started by pkefal, 04-11-2024, 07:39 AM
      11 responses
      37 views
      0 likes
      Last Post jeronymite  
      Started by bill2023, Yesterday, 08:51 AM
      8 responses
      44 views
      0 likes
      Last Post bill2023  
      Started by yertle, Today, 08:38 AM
      6 responses
      26 views
      0 likes
      Last Post ryjoga
      by ryjoga
       
      Started by algospoke, Yesterday, 06:40 PM
      2 responses
      24 views
      0 likes
      Last Post algospoke  
      Working...
      X