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

Address multiple timeframes in one script

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

    Address multiple timeframes in one script

    When addressing multiple timeframes, do all those timeframes need to be loaded into a single chart before running the strategy?
    I currently have a script that addresses these instruments
    else if (State == State.Configure)
    {
    AddDataSeries("NQ 03-24", Data.BarsPeriodType.Tick, 300, Data.MarketDataType.Last);
    AddDataSeries("NQ 03-24", Data.BarsPeriodType.Tick, 1000, Data.MarketDataType.Last);
    AddDataSeries("ES 03-24", Data.BarsPeriodType.Tick, 300, Data.MarketDataType.Last);
    AddDataSeries("ES 03-24", Data.BarsPeriodType.Tick, 1000, Data.MarketDataType.Last);
    }


    So NQ 03-24 300 tick is index 0.
    NQ 03-24 1000 tick is index 1, etc...

    Further down I define a MACD for the first two intruments
    MACD1 = MACD(Closes[0], 12, 26, 9); <--- this is the MACD for NQ 300 tick
    MACD2 = MACD(Closes[1], 12, 26, 9); <--- this is the MACD for NQ 1000 tick

    ​Then I use these MACD's in my code in an attempt to paint the background light green when the NQ1000 MACD is Positive and rising.
    if ((MACD2.Avg[0] >= 0)
    &&(MACD2.Diff[0] > 0))
    {
    BackBrush = Brushes.Honeydew;
    }

    So If I open an NQ 300 tick chart and enable this strategy (which has other sections that do things depending upon what the 300 tick is doing),
    I get this odd result.
    The background screen is painted according to what the 300 tick MACD is doing, instead of what the 1000 tick MACD is doing as specified.
    No error is thrown.

    What is the best way to proceed?
    Thanks,

    #2
    I added the 1000 tick NQ to my 300 tick NQ chart. The problem is still the same.

    Comment


      #3
      Hello Berry Trader,

      You have the wrong indexes in your sample, the nq 300 tick or first AddDataSeries would be index 1 and then each after would increment by 1. 0 is your chart series. Do you still see a problem if you change the indexes that you are using?

      JesseNinjaTrader Customer Service

      Comment


        #4
        NinjaTrader_Jesse wrote:
        "0 is your chart series. "
        Ah. Thank you, Jesse.
        So If I have usually have 3 data series on my chart when I load the strategy, Shall I define my strategy data series starting with index [3] ?

        Comment


          #5
          Hello Berry Trader,

          No the script only sees the series you apply it to so that is always series 0, AddDataSeries would start at index 1 always. The additionals series on your chart are completely unrelated to the script.
          JesseNinjaTrader Customer Service

          Comment


            #6
            Thanks, Jesse. This makes sense to me. I'm looking forward to adjusting my script to see what happens.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Segwin, 05-07-2018, 02:15 PM
            14 responses
            1,788 views
            0 likes
            Last Post aligator  
            Started by Jimmyk, 01-26-2018, 05:19 AM
            6 responses
            837 views
            0 likes
            Last Post emuns
            by emuns
             
            Started by jxs_xrj, 01-12-2020, 09:49 AM
            6 responses
            3,293 views
            1 like
            Last Post jgualdronc  
            Started by Touch-Ups, Today, 10:36 AM
            0 responses
            12 views
            0 likes
            Last Post Touch-Ups  
            Started by geddyisodin, 04-25-2024, 05:20 AM
            11 responses
            62 views
            0 likes
            Last Post halgo_boulder  
            Working...
            X