Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Changing default reference lines for indicators

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

    Changing default reference lines for indicators

    Sorry if this is a wrong place to post a question....

    I'd like to change default reference lines for indicators programmatically, e.g. – for Stochastics they drawn at 20 an 80 levels,
    I’d like to be able to change to 30 and 70 for example (or even specify parameters).

    Add(Stochastics(7,14,3));
    //TODO: change default upper and lower lines -??

    I’m sure it’s possible; just don’t see the right method…
    Thanks a lot.

    #2
    Hi practic, welcome to the NinjaTrader support forums.

    You can add those lines to your script and make the 20 / 80 an input for easier adjusting -

    Code:
    [SIZE=2][SIZE=2]Add([/SIZE][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2] Line(Color.DarkViolet, [/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]20[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2], [/SIZE][/SIZE][SIZE=2][COLOR=#800000][SIZE=2][COLOR=#800000][SIZE=2][COLOR=#800000]"Lower"[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2]));
    Add([/SIZE][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2] Line(Color.YellowGreen, [/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]80[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2], [/SIZE][/SIZE][SIZE=2][COLOR=#800000][SIZE=2][COLOR=#800000][SIZE=2][COLOR=#800000]"Upper"[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2]));
    [/SIZE][/SIZE]
    Here's a tip how to create user defined input parameters - http://www.ninjatrader-support2.com/...ead.php?t=5782
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hi,
      thanks for the reply. Unfortunately, I got some errors. This is the portion of the code I'm using in my strategy:
      protectedoverridevoid Initialize()
      {

      Add(Stochastics(
      7,Period,3));

      Add(
      new Line(Color.DarkBlue,69,"Upper"));
      Add(
      new Line(Color.DarkBlue,31,"Lower"));
      CalculateOnBarClose =
      true;
      Add(EMA(
      9));
      Add(EMA(
      25));

      AccountSize=accSize;

      }

      And thiese are the errors I've got:

      Strategy\StochasticPop2.csThe best overloaded method match for 'NinjaTrader.Strategy.StrategyBase.Add(NinjaTrader .Indicator.IndicatorBase)' has some invalid argumentsCS1502 - click for info484Strategy\StochasticPop2.csArgument '1': cannot convert from 'NinjaTrader.Gui.Chart.Line' to 'NinjaTrader.Indicator.IndicatorBase'CS1503 - click for info488Strategy\StochasticPop2.csThe best overloaded method match for 'NinjaTrader.Strategy.StrategyBase.Add(NinjaTrader .Indicator.IndicatorBase)' has some invalid argumentsCS1502 - click for info494Strategy\StochasticPop2.csArgument '1': cannot convert from 'NinjaTrader.Gui.Chart.Line' to 'NinjaTrader.Indicator.IndicatorBase'CS1503 - click for info498


      Any advise?

      Thank you.

      Comment


        #4
        Hi practic, unfortunately this is not possible in a strategy - for plotting lines you can use DrawHorizontalLine() and DrawLine().



        BertrandNinjaTrader Customer Service

        Comment


          #5
          Hi Bertrand,
          unfortunately those methods draw lines on the chart section, not the actual indicator. Is there any way to supply parameters for Stochastics Upper and Lower lines? (See the picture)? Thank you.
          Attached Files

          Comment


            #6
            Hi practic, the issue is that you use this code inside a strategy in NinjaScript and this is not possible. In a NinjaScript indicator this would of course work.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Not a problem. Is it possible to achieve that inside of the indicator code? If I create custom indicator based on Stochastics and so on?

              Comment


                #8
                Yes, that is what I meant practic.
                BertrandNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by WHICKED, Today, 12:45 PM
                2 responses
                16 views
                0 likes
                Last Post WHICKED
                by WHICKED
                 
                Started by GussJ, 03-04-2020, 03:11 PM
                15 responses
                3,272 views
                0 likes
                Last Post xiinteractive  
                Started by Tim-c, Today, 02:10 PM
                1 response
                8 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by Taddypole, Today, 02:47 PM
                0 responses
                2 views
                0 likes
                Last Post Taddypole  
                Started by chbruno, 04-24-2024, 04:10 PM
                4 responses
                51 views
                0 likes
                Last Post chbruno
                by chbruno
                 
                Working...
                X