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 Jon17, Today, 04:33 PM
      0 responses
      1 view
      0 likes
      Last Post Jon17
      by Jon17
       
      Started by Javierw.ok, Today, 04:12 PM
      0 responses
      4 views
      0 likes
      Last Post Javierw.ok  
      Started by timmbbo, Today, 08:59 AM
      2 responses
      10 views
      0 likes
      Last Post bltdavid  
      Started by alifarahani, Today, 09:40 AM
      6 responses
      41 views
      0 likes
      Last Post alifarahani  
      Started by Waxavi, Today, 02:10 AM
      1 response
      20 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Working...
      X