• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.


No announcement yet.

Partner 728x90


RSI Overbought Oversold Strategy not being Populated

  • Filter
  • Time
  • Show
Clear All
new posts

    RSI Overbought Oversold Strategy not being Populated

    I am creating my first strategy and trying to perform an if else if statement between overbought and oversold of RSI and Stochastics. But when I enable the strategy on the chart, RSI and Stochastics is not populated. please see the attached code below:

    public class RSITestv2 : Strategy
    private RSI RSI1;
    private Stochastics Stochastics1;

    protected override void OnStateChange()
    if (State == State.SetDefaults)
    Description = @"Enter the description for your new custom Strategy here.";
    Name = "RSITestv2";
    Calculate = Calculate.OnBarClose;
    EntriesPerDirection = 1;
    EntryHandling = EntryHandling.AllEntries;
    IsExitOnSessionCloseStrategy = true;
    ExitOnSessionCloseSeconds = 30;
    IsFillLimitOnTouch = false;
    MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
    OrderFillResolution = OrderFillResolution.Standard;
    Slippage = 0;
    StartBehavior = StartBehavior.WaitUntilFlat;
    TimeInForce = TimeInForce.Gtc;
    TraceOrders = false;
    RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
    StopTargetHandling = StopTargetHandling.PerEntryExecution;
    BarsRequiredToTrade = 20;
    // Disable this property for performance gains in Strategy Analyzer optimizations
    // See the Help Guide for additional information
    IsInstantiatedOnEachOptimizationIteration = true;
    else if (State == State.Configure)
    else if (State == State.DataLoaded)
    RSI1 = RSI(Close, 14, 3);
    Stochastics1 = Stochastics(Close, 7, 14, 3);

    protected override void OnBarUpdate()
    if (BarsInProgress != 0)

    if (CurrentBars[0] < 1)

    // Set 1
    if (
    // Overbought
    ((RSI1.Avg[0] >= 70)
    || (IsFalling(Stochastics1.D) == true)))
    Draw.ArrowUp(this, @"RSITestv2 Arrow up_1", false, 0, 0, Brushes.Maroon);

    // Set 2
    else if (
    // Oversold
    ((RSI1.Avg[0] <= 30)
    || (IsRising(Stochastics1.D) == true)))
    Draw.ArrowDown(this, @"RSITestv2 Arrow down_1", false, 0, 0, Brushes.DarkGreen);
    I followed the youtube video from NinjaTrader - https://www.youtube.com/watch?v=JZpo01eSO9c

    What am I doing wrong to not have RSI and Stochastic to not show up on the chart?
    Attached Files
    Last edited by w0lverine; 04-03-2019, 04:54 AM.

    Hello w0lverine,

    Thanks for your post.

    The video is showing the use of the NT7 strategy wizard. Your code shows you are using NT8. I am not sure if you are using the NT8 strategy builder or are coding directly in Ninjascript so I will provide solutions for both.

    If I understand correctly, you are expecting the RSI and the Stochastics to be drawn on the chart when enabling the strategy.

    For Ninjascript created code, to accomplish this you would need to use AddChartIndicator(), please see the help guide here: https://ninjatrader.com/support/help...tindicator.htm Example, in State.DataLoaded you would have AddChartIndicator(RSI1);

    If using the strategy builder, then when selecting the indicator in the strategy builder, in the parameters of the indicator is the checkbox "Plot on chart" that must be checked in order to automatically display the indicator. You need only check one occurrence of the indicator to have it displayed (so if you have 10 sets using the RSI with the same values no need to check plot on chart for all 10, only 1 needs to be checked in order to see the indicator, otherwise all 10 are displayed on top of each other).

    The code for drawing the arrows will draw arrows at the price (Y value) level of 0 which will likely not be visible on the chart. You would need to use some price value reference, such as above or below the bar where the condition occurred. Also, by default, the draw objects will only show the latest occurrence. To see all of the historical markers you would need to create unique draw objects by using a unique tag name. Here is a link to a short video, in the strategy builder, showing how to create unique tag names and locate the Y value of the draw objects. https://Paul-ninjaTrader.tinytake.co...A4M184NTkwOTg3
    Paul H.NinjaTrader Customer Service



      Yes you are correct, I am using NT8 and the youtube video as the guideline while I used the NT8 strategy builder. It was confusing at first, but once I got the hang of it, I was able to translate what he was doing with Strategy builder for NT8 and the if else if statements were the same at the end of the day.

      Yes, I am expecting the RSI and stochastics to be drawn on the chart when enabling the strategy.

      And that is my issue, I did not check the box "plot on chart".. Thank you!

      As for drawing the arrows... I did not know that. I'll dig more into that today. Thanks for looking forward on my solution.


      Latest Posts


      Topics Statistics Last Post
      Started by mtamaku, Today, 09:19 AM
      0 responses
      Last Post mtamaku
      by mtamaku
      Started by traderMNQ, Today, 09:00 AM
      3 responses
      Last Post NinjaTrader_ChrisL  
      Started by jransom, Today, 09:08 AM
      0 responses
      Last Post jransom
      by jransom
      Started by Irukandji, Today, 08:27 AM
      1 response
      Last Post NinjaTrader_Manfred  
      Started by brunoviveiros, Today, 08:18 AM
      0 responses
      Last Post brunoviveiros