Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Multi Timeframe Strategy Help Request

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

    Multi Timeframe Strategy Help Request

    Hello support and members of the forum,

    I have created a Multi Timeframe strategy which is running on a 1 Tick chart and has conditions based on an indicator which is running on a different PeriodType.
    The strategy is set to Calculate On Bar Close = False, but the indicator running on the different PeriodType in BarsArray[1] seems to be Calculating On Bar Close = True.

    Below I will provide the script I have right now, perhaps someone could assist me in finding the issue.

    protected override void Initialize()
    {
    CalculateOnBarClose = false;
    Add(Indicator(Type, Period));
    Add(Indicator(Type, Period));
    Add(PeriodType.Custom9, 20);

    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Condition set 1
    if (Indicator(BarsArray[1], Type, Period).Diff[0] > 0
    && CurrentBar!=savedLongBar
    && ToTime(Time[0]) >= ToTime(0, 5, 0)
    && ToTime(Time[0]) <= ToTime(21, 55, 0)
    && Closes[1][0] > Opens[1][0] +17*TickSize)

    {
    EnterLong(DefaultQuantity, "L");
    savedLongBar = CurrentBar;
    }


    So the problem is that the indicator running on the added PeriodType still Calculates On Bar Close = True. Perhaps it has to do with the "savedLongBar" methods, something that I also would like to run on the added PeriodType.

    #2
    Hello otislauwaert,

    Thanks for the post.

    A parent script will always use its own Calculate mode. This means that the CalculateOnBarClose property in the embedded script will need to be the same as the parent script. For an example of how to separate some logic to run on bar close and some logic to run on eack tick, see this reference sample:



    Bracketing logic within "FirstTickOfBar" will effectively run that logic "On Bar Close" the rest of the logic within OnBarUpdate not bracketed will be executed OnEachTick.

    Please let me know if I can assist further.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hello Chris,

      The parent strategy is set to COBC = False.
      The problem is that the Add(PeriodType.Custom9, 20); is not calculating on each tick, like the parent strategy is doing.

      Comment


        #4
        Hello otislauwaert,

        Thanks for the reply.

        I'm thinking the error is coming from the custom bar type that you are using. Could you please post that here so I can test? You may also go to Help>Email support and attach the file from there. If you do email the script, please past the link to this forum post in the body of the email.

        I look forward to your reply.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Hello Chris,

          I am using the NT Renko Candle bars. If I open a separate chart with this period type and load the indicator on it with COBC = False, it does as should.
          You can try it, I have attached the file.
          Attached Files

          Comment


            #6
            Hello otislauwaert,

            Thanks for the reply.

            I tested bar type and the bar is updating on each tick. If you have made changes in the Initialize method, be sure to remove the strategy then add it back to make a completely new instance of the strategy on the chart.

            Please let me know if that works for you.
            Chris L.NinjaTrader Customer Service

            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