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

Cross Over Indicator

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

    Cross Over Indicator

    Hi,
    I have used the NT7 Strategy Wizard & Indicator Wizard to create a EMA cross above/below indicator which draws the Up/Down arrows on the chart. It is working fine.

    The next step is to make the Market Analyzer identify and report the cross above/below or no cross over. I have read articles in Ninja Support Forum which says that this is possible. The advice is to detect the cross above and plot 1, detect cross below and plot -1 and 0 when no cross over.

    I am quite familiar with the structure and sections of script that were created by the wizards and able to start and modify the script using the available Edit NinjaScript Indicator feature. I am thinking of making a copy of the above indicator which draws the up/down arrows and adding lines to the script to achieve my objective.

    Please advice on the lines to add to the Indicator script to plot the 1, -1 & 0 for the specific conditions detected, thank you

    #2
    Hello joeralp,

    You would need to add a Plot to the indicator for this purpose if it does not have one currently. For an example of a plot in an indicator, you could see the Bollinger and its Upper plot. You would need both the AddPlot() syntax to add a Plot and a public property to expose the plot. The bollinger shows both parts of this concept.

    We have the following documentation on the AddPlot syntax here here: http://ninjatrader.com/support/helpG...ghtsub=addplot

    Once you add the plot, you would likely need to set the value of the plot to 1 or -1 where the current logic draws up or down arrows.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post
      Hello joeralp,

      You would need to add a Plot to the indicator for this purpose if it does not have one currently. For an example of a plot in an indicator, you could see the Bollinger and its Upper plot. You would need both the AddPlot() syntax to add a Plot and a public property to expose the plot. The bollinger shows both parts of this concept.

      We have the following documentation on the AddPlot syntax here here: http://ninjatrader.com/support/helpG...ghtsub=addplot

      Once you add the plot, you would likely need to set the value of the plot to 1 or -1 where the current logic draws up or down arrows.

      I look forward to being of further assistance.
      Hi, Jesse, thanks for guidance for creating the Plot for Market Analyzer
      to report crossover of Fast & Slow EMA, I have added the following lines
      to the new Indicator that successfully drew the Up and Down Arrows on
      the chart.

      In Initialize section,
      new line = Add(new Plot (Color.Transparent, "EMAXoPlot"));
      new line = EMAXoPlot.Set(0);

      In OnBarUpdate section
      If CrossAbove...... - new line = EMAXoPlot.Set(1);
      if CrossBelow...... - new line = EMAXoPlot.Set(-1);

      In Property section
      new line - [Browsable (false)]
      new line - [XmlIgnore()]
      new line - public DataSeries EMAXoPlot
      new line - { get {return Values[1]; }}

      This script finally compiled without any errors

      In Market Analyzer - new Indicator column created for the new Indicator with 3 x cell conditions
      a) Change cell if value equals 0 with "None" text output
      b) Change cell if value equals 1 with "Xup" text output
      c) Change cell if value equals -1 with "Xdn" text output

      This did NOT work, the column in the Market Analyzer displays #checklog#
      Please advice, thanks

      Comment


        #4
        Hello,

        Thank you for the reply.

        Could you export the file as you have it now for me to review the logic being used? Based on what you have described I would not expect the script to work as the syntax provided seems to be invalid. If you can provide the file, I could see what you have already done and try to recommend changes where I can.



        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Cross Over Indicator

          Originally posted by NinjaTrader_Jesse View Post
          Hello,

          Thank you for the reply.

          Could you export the file as you have it now for me to review the logic being used? Based on what you have described I would not expect the script to work as the syntax provided seems to be invalid. If you can provide the file, I could see what you have already done and try to recommend changes where I can.



          I look forward to being of further assistance.
          Hi, Jesse, I have attached the file to this message for your info and further action, thanks
          Attached Files

          Comment


            #6
            Please note that I am using NinjaTrader 7

            Comment


              #7
              Hello joeralp,

              Thank you for providing the file. For future NT7 items, pelase ensure to post in the NT7 forums. I have moved this to the correct forum.

              Regarding the script, there are two problems.

              The first is where you are setting the plot to 0, this would need to go in OnBarUpdate. Initialize is called before the OnBarUpdate method and should not be used to set plots or other items that are synced with the CurrentBar.

              Code:
               protected override void OnBarUpdate()
                      {
              			EMAXoPlot.Set(0);
              The next item is the public property you have declaried for the plot or EMAXoPlot. This has an index of 1 currently but you have only added one plot, the index would start at 0 so this would need to be reset to 0:

              Code:
              [Browsable(false)]
              [XmlIgnore()]
              public DataSeries EMAXoPlot
              {
              	get { return Values[B][0][/B]; }
              }
              After making these changes and refreshing the MA, you should see that it shows 0 instead of #check log#, once the condition is reached it should then report the other values you have set. setting 0 at the top of OnBarUpdate is required, if you do not you will see the Close price instead.

              I look forward to being of further assistance.
              JesseNinjaTrader Customer Service

              Comment


                #8
                Hello Jesse,

                I have made the correction and everything works fine now,

                An observation - when creating the relevant "Column" on the Market Analyzer, must ensure that the "Indicator > Plot" is set to the newly created Plot i.e. "EMAXoPlot" in my case

                Thanks so much for your help.
                Last edited by joeralp; 02-03-2017, 09:07 PM.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Mestor, 03-10-2023, 01:50 AM
                16 responses
                388 views
                0 likes
                Last Post z.franck  
                Started by rtwave, 04-12-2024, 09:30 AM
                4 responses
                31 views
                0 likes
                Last Post rtwave
                by rtwave
                 
                Started by yertle, Yesterday, 08:38 AM
                7 responses
                29 views
                0 likes
                Last Post yertle
                by yertle
                 
                Started by bmartz, 03-12-2024, 06:12 AM
                2 responses
                22 views
                0 likes
                Last Post bmartz
                by bmartz
                 
                Started by funk10101, Today, 12:02 AM
                0 responses
                7 views
                0 likes
                Last Post funk10101  
                Working...
                X