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

Plot multi-timeframe in one chart

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

    Plot multi-timeframe in one chart

    Hi,

    I'm using a 1-min stock chart. In my script I have added a second time-frame, namely the daily. I would like to see the ATR of the daily-timeframe on the 1min chart. Is this possible?

    I have added this in the Initialize():

    Add(PeriodType.Day, 1);

    Add(ATR(Closes[1],5));
    ATR(Closes[1],5).Plots[0].Pen.Color = Color.Black;
    ATR(Closes[1],5).Plots[0].Pen.Width = 1;

    So I would think the Closes[1] would mean I'm talking to the first added timeframe, namely the daily. But it still shows the 1min values.

    Any help is appreciated.

    #2
    Hi siroki, the Add() method would be meant to add complete indicators for display in strategies. You could not use this way in an indicator or pass a BarsArray to work on in. What you could do is Add in the daily and then calculate the ATR value in the OnBarUpdate in your 1 min chart.

    So for example -

    if (BarsInProgress == 0 && (CurrentBars[0] > 0 && CurrentBars[1] > 0))
    Plot0.Set(ATR(BarsArray[1], 14)[0]);
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thanks for your reply. I'll give it a try.

      Comment


        #4
        Awesome, it works. Didn't get the plot to work because I'm not fully familiar with custom adding plots and adding indicators to it. But I want to perform calculcations with it anyway, so for now i'm happy.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Brevo, Today, 01:45 AM
        0 responses
        2 views
        0 likes
        Last Post Brevo
        by Brevo
         
        Started by aussugardefender, Today, 01:07 AM
        0 responses
        3 views
        0 likes
        Last Post aussugardefender  
        Started by pvincent, 06-23-2022, 12:53 PM
        14 responses
        238 views
        0 likes
        Last Post Nyman
        by Nyman
         
        Started by TraderG23, 12-08-2023, 07:56 AM
        9 responses
        384 views
        1 like
        Last Post Gavini
        by Gavini
         
        Started by oviejo, Today, 12:28 AM
        0 responses
        4 views
        0 likes
        Last Post oviejo
        by oviejo
         
        Working...
        X