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 Indicator Help

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

    Multi TimeFrame Indicator Help

    I am currently developing multi timeframe indicators. For example, below I developed a simple adx mult timeframe indicator that I can use with range bar types. What I would like to do is adjust this program to be able to receive any type (i.e. minutes, seconds, ticks, etc...) instead of only range. Can anyone give me some guidance on how I would approach this?

    protected override void Initialize()
    {
    Add(PeriodType.Range, range);
    Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "ADXComp Line"));
    Overlay = false;
    CalculateOnBarClose = false;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    if (CurrentBars[0] < BarsRequired || CurrentBars[1] < BarsRequired)
    return;
    double ADXComp = (ADX(BarsArray[1],adxperiod)[0]);
    ADXCompLine.Set(ADXComp);
    }

    #2
    Hi traderjem,

    Thanks for the post and welcome to the NinjaTrader forums! For timing reasons, we support only hard coding additional series. This is controlled with the Add() statements, possible values are available here:
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Hey Ryan

      So are you saying I should ADD each potential period type I want and then send a flag from my properties to tell it which type to use (like in a case statement)?

      Comment


        #4
        That could be one way to do it. There is no supported technique for conditionally adding series to your script but you could add all potential series you need. Then work a case statement into OnBarUpdate() for accessing.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_RyanM View Post
          That could be one way to do it. There is no supported technique for conditionally adding series to your script but you could add all potential series you need. Then work a case statement into OnBarUpdate() for accessing.
          That reminds me -- for a long time now I have wanted the ability to use Add() in OnStartUp(). Such an action, of course, would mean that the properties of whatever is added isn't accessible from the indicator properties. And it would also probably mean that something in OnTermination() would be needed to destroy whatever got added. But this would be a nice way to handle the need to add things conditionally based on the input parameters.

          It strikes me as wasteful of both memory and CPU to add every possible time frame and then use just one of them.

          -A

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by yertle, Today, 08:38 AM
          6 responses
          25 views
          0 likes
          Last Post ryjoga
          by ryjoga
           
          Started by algospoke, Yesterday, 06:40 PM
          2 responses
          24 views
          0 likes
          Last Post algospoke  
          Started by ghoul, Today, 06:02 PM
          3 responses
          16 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by jeronymite, 04-12-2024, 04:26 PM
          3 responses
          46 views
          0 likes
          Last Post jeronymite  
          Started by Barry Milan, Yesterday, 10:35 PM
          7 responses
          23 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Working...
          X