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

Cannot plot Trailing ATR

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

    Cannot plot Trailing ATR

    Hello NT forum,

    I am having issues in adding a new plot to my strategy. I am using the following function:

    Add(new Plot(Color.Blue, PlotStyle.Dot, "ATR"));

    I've added "ATR" to my #region Variables as:
    // Wizard generated variables
    privateint shortSMA = 20; // Default setting for ShortSMA
    privateint longSMA = 40; // Default setting for LongSMA
    privateint ATR = 20; // default for ATR

    Here are the errors I get when I try to plot the following.. PLEASE HELP!

    CalculateOnBarClose = true;
    AccountSize =
    1000000; //account size
    Add(MAEnvelopes(1.5, 3, 20));
    Add(SMA(
    40));
    Add(SMA(
    10));
    Add(
    new Plot(Color.Blue, PlotStyle.Dot, "ATR"));
    BarsRequired = (
    1);

    The best overloaded method match for 'NinjaTrader.Strategy.StrategyBase.Add(NinjTrader. Indicator.IndicatorBase)' has some invalid arguments

    Code CS1502

    and

    Argument '1': cannot convert from NinjaTrader.Gui.Chart.Plot' to 'NinjaTrader.Indicator.IndicatorBase'

    Code CS1503

    #2
    Hello antonio_zeus,

    Thank you for your post.

    I recommend starting out by naming your int differently than 'ATR'. ATR is already used to call the method for the ATR indicator, and this can cause errors going forward using an int with the same name as an indicator method.

    If this does not resolve the errors please respond with the code used to set your plot.
    Example:
    Code:
    yourPlot.Set(yourValues);
    I look forward to your response.

    Comment


      #3
      Hello and thank you for getting back to me.

      Unfortunately, this still didnt work. Also, let me know if these variables should be under Initialize() or onBarUpdate(). I ask this because technicaly speaking I want my plots to update on every bar.

      Thank you very much.


      I attached the actual code since it was too long.
      Attached Files

      Comment


        #4
        Hello antonio_zeus,

        Thank you for your response.

        This is a strategy so a different approach is required for plotting. Please refer to the following link for a reference sample on how to plot from within a strategy: http://www.ninjatrader.com/support/f...ead.php?t=6651

        Please let me know if I may be of further assistance.

        Comment


          #5
          Thanks for the quick reply (again).

          The thing is, your link states that it cannot appear when backtesting from a chart... This is going to be difficult since I would like to see it on my chart for the purpose in seeing how it works with my strategy.

          Maybe another question would be this... how do I plot a trailing ATR on price as opposed to the bottom of the chart.

          Would I still need to make a custom indicator? Maybe this will help.

          Comment


            #6
            Hello antonio_zeus,

            Thank you for your response.

            Once the Backtest has completed you can then apply the indicator (ATR) to the chart in the Strategy Analyzer chart tab by right clicking in the chart and selecting Indicators.

            Are you looking to program the ATR to plot on the price?

            You can right click in your chart > select Indicators > ATR > and set the Panel to Same As Input Series > OK. This will apply it to the price's panel, you can also set the Scale Justification to Overlay so that the ATR is on the price panel but on it's own scale.

            Comment


              #7
              thank you! That works. I can always backtest my strategy and then ADD the ATR trailing stop after.

              Appreciate it!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Rapine Heihei, Today, 08:19 PM
              1 response
              8 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by Rapine Heihei, Today, 08:25 PM
              0 responses
              6 views
              0 likes
              Last Post Rapine Heihei  
              Started by f.saeidi, Today, 08:01 PM
              1 response
              9 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by Rapine Heihei, Today, 07:51 PM
              0 responses
              8 views
              0 likes
              Last Post Rapine Heihei  
              Started by frslvr, 04-11-2024, 07:26 AM
              5 responses
              98 views
              1 like
              Last Post caryc123  
              Working...
              X