Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Drawing objects disappear going from Daily to 30 min multi timeframe

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

    Drawing objects disappear going from Daily to 30 min multi timeframe

    Hi. I have a problem where what ever my strategy draws programmatically, disappears when I go from for example a daily chart to 30 min chart.

    The chart is initially added with a daily chart displayed. Because I can manually change the time frame on the GUI, I add daily, 30 min and 15min to my strategy so I can program events and it won't change.

    I want the arrows/dots I "draw" to display on whatever chart I select on the GUI.

    PROBLEM: If I change from a daily chart, all my drawing dots disappear. How can I keep them on the chart if I select 30 min chart to view? (am I assuming that is BarsInProgress == 0 the display)

    Initialize()
    Add(PeriodType.Day, 1);
    Add(PeriodType.Minute,
    30);
    Add(PeriodType.Minute,
    15);

    OnBarUpdate()
    if(BarsInProgress == 0) // this is the display

    if(BarsInProgress == 1) // daily chart

    if(BarsInProgress == 2) // 30 min chart

    if(BarsInProgress == 3) // 15 min chart
    if some logic
    drawdot (this code works)

    I add the Daily again

    #2
    DaFish,

    This is expected unfortunately. When you change your chart time frames, it will reload the NinjaScript strategies / indicators. You would need to likely do some work-around to have persistent drawing objects, and then also ensure you can clean them up when you exit your strategy. Unfortunately either wouldn't be supported, however you could take a look around the forum for other topics like this, as well as research at places like BigMikes Trading forum.

    I have included some links below you might find helpful in figuring out a way to do this.







    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the quick reply Adam.

      If I put all my code in BarsInProgress == 0 (the display) I seem to remember that my dots did draw on multiple timeframes. I'll test again....

      I can't be the only one that has this issue. Can you please describe the "best practices" way to program multi time frame in the manner I am doing.

      I want to have the coding internally done on the 2 or 3 timeframes, but display the chart on the gui on any selected time frame I choose AND see my dots. There has to be a way.

      Please advise.

      Comment


        #4
        DaFish,

        The issue here is that the strategy completely resets itself when you change time frames and recalculates everything.

        The multi-timeframe addition is designed for example so that a strategy can access daily bars when its working on minute bars. It wasn't really designed to enable hot-switching between chart styles while keeping drawing objects persistent from one time frame to another.
        Adam P.NinjaTrader Customer Service

        Comment


          #5
          Thanks Adam. Given your reponse, I thought it would mean that I could fix the display GUI on maybe 15 min chart. So I created a new chart of AAPL, set to 15 min, and then applied my strategy to that which would display my dots.

          I don't get any dots on my new 15 min chart - I didn't change any screens or anything.

          Once I change my chart back to DAILY, I get all my dots..... why would this be happening?

          Originally posted by NinjaTrader_AdamP View Post
          DaFish,

          The issue here is that the strategy completely resets itself when you change time frames and recalculates everything.

          The multi-timeframe addition is designed for example so that a strategy can access daily bars when its working on minute bars. It wasn't really designed to enable hot-switching between chart styles while keeping drawing objects persistent from one time frame to another.

          Comment


            #6
            DaFish,

            Likely I'd need to see more of your code here, can you post your if ( BarsInProgress == 0) section?
            Adam P.NinjaTrader Customer Service

            Comment


              #7
              Hi Adam, code attached.

              I don't know why it won't display multi timeframe. I can display things on Weekly/Daily charts though.

              I hope you can find the problem.

              Thanks

              Originally posted by NinjaTrader_AdamP View Post
              DaFish,

              Likely I'd need to see more of your code here, can you post your if ( BarsInProgress == 0) section?
              Attached Files

              Comment


                #8
                Hi Adam, I think it maybe related to the time frame....

                my code I posted spits out a log entry:

                AAPL:Minute:30:MFNTMultiTF:Initializing - bars[0], Display period set: 30, Curbar:0, 9/25/12 9:47:30 PM
                AAPLay:1:MFNTMultiTF:Initializing - bars[1], Long period set: 1, Curbar:0, 9/25/12 9:47:30 PM
                AAPL:Minute:30:MFNTMultiTF:Initializing - bars[2], Medium period set: 30, Curbar:0, 9/25/12 9:47:30 PM
                AAPL:Minute:15:MFNTMultiTF:Initializing - bars[3], Short period set: 15, Curbar:0, 9/25/12 9:47:30 PM

                If my selected time frame OnBarUpdate=0 is shorter than my time frame for OnBarUpdate=1, then nothing draws, and nothing is printed in my logs.

                Is there something I need to know about this?

                Originally posted by NinjaTrader_AdamP View Post
                DaFish,

                Likely I'd need to see more of your code here, can you post your if ( BarsInProgress == 0) section?

                Comment


                  #9
                  DaFish,

                  It could be you lack the historical data for these other time frames. You may want to try to load a few charts of historical data in the time frames you need with your Tools > Options > Data > "Save chart data as historical" option enabled.
                  Adam P.NinjaTrader Customer Service

                  Comment


                    #10
                    HI Adam, I have more info for you. I actually have this working.... IF all 3 timeframes are intraday.

                    I changed the order... making the fast periods first.
                    Add(PeriodType.Minute, 5);
                    Add(PeriodType.Minute, 15);
                    Add(PeriodType.Minute, 30);

                    I then do the following order:
                    OnBarUpdate()
                    if(BarsInProgress == 0) // this is the display


                    if(BarsInProgress == 3) // 30 min chart

                    if(BarsInProgress == 2) // 15 min chart

                    if(BarsInProgress == 1) // 5 min chart
                    if some logic
                    drawdot (this code works)

                    Now on the GUI, I can change to daily, 30 min, 15 min... weekly... my DOTS will appear on any timeframe.

                    WHAT IS NOT WORKING:
                    If I change the last time frame from 30 min (intraday) to a daily chart - my chart will only display arrows on a daily chart on the GUI. If I go to intraday, I get no dots, and I get no messages either on the output log. - I have a message on the output log that will display a message if there are not enough bars - I should see at least one of those messages. I dont' see any.

                    Add(PeriodType.Minute, 5);
                    Add(PeriodType.Minute, 15
                    );
                    Add(PeriodType.Day, 1);


                    Any thoughts given this info?

                    Thanks for your help.


                    Comment


                      #11
                      Hi DaFish, how many days are you loading up for the primary chart? There's a BarsRequired default setting of 20 bars that have to be fullfilled for all series your call to start processing any OBU() call in your code.

                      Comment


                        #12
                        I arbitrarily set 250 bars per chart... Think I should go 2500 just to check to see if that is it?

                        Comment


                          #13
                          Yes, please go a step higher there and recheck - also what if you added a 1440 minute chart emulating the daily, same outcome observed?

                          Comment


                            #14
                            Originally posted by NinjaTrader_Bertrand View Post
                            Yes, please go a step higher there and recheck - also what if you added a 1440 minute chart emulating the daily, same outcome observed?
                            HI I thought I would just put in a closing remark on this thread for others.

                            When I changed from Daily to say 15 min chart, the chart defaulted to 5 days of data. This was not enough to run my strategy/indicator. When Bertrand and I worked though the chart and I change the setting to 60 days of data, the system worked perfectly.

                            One thing to note, I had debug comments in, and they were not getting executed so I didnt' know I was missing the data. When I upgraded to the latest release, I was finally getting messages that I didn't have enough data in the output window.

                            Closed, a BIG thanks to Bertrand and Adam for helping me so much.

                            Comment


                              #15
                              Originally posted by DaFish View Post
                              HI I thought I would just put in a closing remark on this thread for others.

                              When I changed from Daily to say 15 min chart, the chart defaulted to 5 days of data. This was not enough to run my strategy/indicator. When Bertrand and I worked though the chart and I change the setting to 60 days of data, the system worked perfectly.

                              One thing to note, I had debug comments in, and they were not getting executed so I didnt' know I was missing the data. When I upgraded to the latest release, I was finally getting messages that I didn't have enough data in the output window.

                              Closed, a BIG thanks to Bertrand and Adam for helping me so much.
                              Thanks for the kind words, we're glad to hear the script works now as expected for you.

                              All the best.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              656 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              373 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              109 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              574 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              579 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X