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

BarsArray issue

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

    BarsArray issue

    Hello,
    I'm working on a multi-time frame indicator. I'd like to have an indicator taking data from say a 12 range print on a 4 range. I worked it out with a SMA, but when I try to apply the same rules to this SuperTrend indicator I get nothing. Here is my code:
    Code:
    {
            #region Variables
                private DataSeries UpTrend;
            #endregion
            protected override void Initialize()
            {
               Add(new Plot(Color.FromKnownColor(KnownColor.Purple), PlotStyle.Line, "SMALine"));
                Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "UpTrend"));
                Overlay                = true;
                Plots[0].Pen.Width = 4;
                Plots[0].Pen.Width = 4;
                Add(PeriodType.Range, 12);
                Add(PeriodType.Range, 12);
                UpTrend = new DataSeries(this);
            }
            protected override void OnBarUpdate()
            {
                if (CurrentBars[0] < BarsRequired || CurrentBars[1] < BarsRequired || CurrentBars[2] < BarsRequired )
                return;
                
                SMALine.Set (SMA(BarsArray[1], 14)[0]) ;
                UpTrend.Set (SuperTrend(BarsArray[2],14, 2.618, true).UpTrend[0]) ;
            }
    Can anyone offer some help? Thank you.
    Attached Files
    Last edited by CaptainAmericaXX; 01-04-2013, 08:35 PM.

    #2
    Ok, I figured out the problem with the 2nd indicator. The public DataSeries in the Properties was labeled incorrectly. Now if someone could show me how to turn off the Uptrend line in the SuperTrend indicator when the Downtrend line is taking over I'd be forever grateful!
    Here is the SuperTrend .zip.
    Attached Files
    Last edited by CaptainAmericaXX; 01-04-2013, 09:17 PM.

    Comment


      #3
      Originally posted by CaptainAmericaXX View Post
      Ok, I figured out the problem with the 2nd indicator. The public DataSeries in the Properties was labeled incorrectly. Now if someone could show me how to turn off the Uptrend line in the SuperTrend indicator when the Downtrend line is taking over I'd be forever grateful!
      Here is the SuperTrend .zip.
      Where in the code do we see when one line is taking over from the other?

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by judysamnt7, 03-13-2023, 09:11 AM
      4 responses
      59 views
      0 likes
      Last Post DynamicTest  
      Started by ScottWalsh, Today, 06:52 PM
      4 responses
      36 views
      0 likes
      Last Post ScottWalsh  
      Started by olisav57, Today, 07:39 PM
      0 responses
      7 views
      0 likes
      Last Post olisav57  
      Started by trilliantrader, Today, 03:01 PM
      2 responses
      21 views
      0 likes
      Last Post helpwanted  
      Started by cre8able, Today, 07:24 PM
      0 responses
      10 views
      0 likes
      Last Post cre8able  
      Working...
      X