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

Multiple Time SMA Indicator

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

    Multiple Time SMA Indicator

    The below example was taken from the Help Guide refering to a boolean.

    protected override void OnBarUpdate()
    {
    if (BarsInProgress == 0)
    {
    if (CCI(20)[0] > 200 && CCI(BarsArray[1], 20)[0] > 200
    && CCI(BarsArray[2], 20)[0] > 200)

    {
    // Do something
    } }
    }

    Also, all examples seen so far explains how to do a multiple time indicator with booleans, but what I'm looking is how to code a multiple time indicator with SMAs. Example:

    if SMA(5) CrossAbove SMA(10) from a 60 Min chart;
    //Do something...

    Also, Does NT 6.5 supports the following?:

    if SMA(5) CrossAbove SMA(10) from a 60 Min chart && CCI(BarsArray[2], 20)[0] > 200)
    //Do something...

    #2
    There are no reference samples on multi-time framed indicators since it is currently not supported. All the multi-time frame features are currently for strategies.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Perhaps I do not clearly understand your question, but here is an example of how to do what you are asking:
      if SMA(5) CrossAbove SMA(10) from a 60 Min chart;
      //Do something...
      In the Initialize() method include the following statement to create a time period for your 60 Min price data (not really a chart as the only chart you will see will be the one in the time frame you run the stategy in).
      Code:
      [FONT=Courier New][SIZE=2][COLOR=#008000]
      Add(PeriodType.Minute,60);
      [/COLOR][/SIZE][/FONT]
      Then in the OnBarUpdate() method, assuming that the above PeriodType was the first one added - so the BarsArray index will be 1. You can code your statment as:

      if (CrossAbove(SMA(BarsArray[1],5), SMA(BarsArray[1],10,1)
      do something;
      And this will provide a condition that will be true each time the 60 minute SMA(10) crosses above the 60 minute SMA(10), or false otherwise.

      I hope this helps.

      Comment


        #4
        Yes you can do it with a strategy, though a little coarse.
        I use DrawDot or Triangle or Diamond, once you do the Add( PeriodType.Minute, 60 ) or whatever you want in initialize.

        I haven't been able to get the DrawLine to work yet but haven't spent much time with it either.

        It would be nice if you could set a size for DrawDot... etc. They are too large in size now.

        Also doing a draw with a strategy sets a boundary for your chart. It must remain in viewing area of chart. It would be nice if it would be allowed to scroll off the screen, then you could shrink the axis if you wanted to see it.
        Sometimes another period indicator is far away from price and don't need to see it. In TradeStation you can set a flag to turn off Include All Indicators in view ( I understand that this is technically a strategy not an indicator, just using a strategy to act as surrogate indicator from anther time period )

        Comment


          #5
          If you don't want your draw objects to influence your chart scale you will need to turn the AutoScale property on them off.
          Josh P.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by burtoninlondon, Today, 12:38 AM
          0 responses
          5 views
          0 likes
          Last Post burtoninlondon  
          Started by AaronKoRn, Yesterday, 09:49 PM
          0 responses
          14 views
          0 likes
          Last Post AaronKoRn  
          Started by carnitron, Yesterday, 08:42 PM
          0 responses
          11 views
          0 likes
          Last Post carnitron  
          Started by strategist007, Yesterday, 07:51 PM
          0 responses
          13 views
          0 likes
          Last Post strategist007  
          Started by StockTrader88, 03-06-2021, 08:58 AM
          44 responses
          3,982 views
          3 likes
          Last Post jhudas88  
          Working...
          X