Announcement

Collapse
No announcement yet.

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?

      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.

          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 Mindset, 04-21-2026, 06:46 AM
            0 responses
            89 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by M4ndoo, 04-20-2026, 05:21 PM
            0 responses
            135 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by M4ndoo, 04-19-2026, 05:54 PM
            0 responses
            68 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by cmoran13, 04-16-2026, 01:02 PM
            0 responses
            119 views
            0 likes
            Last Post cmoran13  
            Started by PaulMohn, 04-10-2026, 11:11 AM
            0 responses
            69 views
            0 likes
            Last Post PaulMohn  
            Working...
            X