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 timmbbo, Today, 08:59 AM
          1 response
          2 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by KennyK, 05-29-2017, 02:02 AM
          2 responses
          1,281 views
          0 likes
          Last Post marcus2300  
          Started by fernandobr, Today, 09:11 AM
          0 responses
          3 views
          0 likes
          Last Post fernandobr  
          Started by itrader46, Today, 09:04 AM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Started by bmartz, 03-12-2024, 06:12 AM
          5 responses
          33 views
          0 likes
          Last Post NinjaTrader_Zachary  
          Working...
          X