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

Indicator on ZeroLine

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

    Indicator on ZeroLine

    Can you please tell me how I plot Close>SMA and Close<SMA on ZeroLine with diferente colors?

    Best

    #2
    RitaPacheco, you would need to custom code an oscillator for this purpose (the close substracted from the SMA value) and then set then colors according to the relation to the 0 value -

    http://www.ninjatrader-support.com/H...verview18.html (tutorial 5 would be closest here for how to start)
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Sorry I don't want an oscilate with values up and down to zero line.

      I want only the zero line with 2 colors: one for close>SMA and other for close<SMA

      I think what you told me to do is a colored line for up and other for down, isn't it? Like Tutorial no.5

      Best

      Comment


        #4
        Then you would just need 2 Plots with your needed colors and use then one plot for each condition (Close being greater / smaller than 0). As value for the Plots you can just set 0 and choose for example to plot those as a dot or square.

        BertrandNinjaTrader Customer Service

        Comment


          #5
          I can not to do this indicator to have above/below SMA with 2 diferent colors on ZeroLine. It densn't work yet Where do I put the 2 formulas: SMA - Close<>0 , I put them on protected override void OnBarUpdate() and put the plot after each formula. I have defenided on protected override void Initialize() Plot:

          Plots[0].Min = 0;
          Plots[1].Max = 0;;

          I already understand that Above and Below plot are setting to zero as Above.Set (0)

          Thanks


          protected override void OnBarUpdate()
          {
          // Are there enough bars
          if (CurrentBar < Period) return;
          //find Close above SMA
          if(SMA(period)[0]- Close[0]>0);
          // Set the plot values
          AboveZero.Set(0);

          //find Close below SMA
          if(SMA(period)[0]- Close[0]>0);

          BelowZero.Set(0);
          }

          Comment


            #6
            Hello,

            Your two if statements are exactly the same. Could that be it?
            DenNinjaTrader Customer Service

            Comment


              #7
              Sorry Bertrand

              In fact the two if statements ware exactly the same, even so changed them it doesn't work. only show 1 color on Zero Line the Below color (2nd on order) there is samethig wrong.

              Thanks



              protected override void OnBarUpdate()
              {
              // Are there enough bars
              if (CurrentBar < Period) return;

              if(SMA(period)[0]- Close[0]>0);
              // Set the plot values
              AboveZero.Set(0);

              if(SMA(period)[0]- Close[0]<0);

              // Set the plot values

              BelowZero.Set(0);
              }

              Comment


                #8
                Rita, that code should do the trick. I had an indicator exactly like this laying around so I've attached it here for you. You can import the .zip file by going to File -> Utilities -> Import NinjaScript and then selecting the .zip file.
                Attached Files
                AustinNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by quantismo, 04-17-2024, 05:13 PM
                3 responses
                25 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by ScottWalsh, 04-16-2024, 04:29 PM
                7 responses
                34 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by cls71, Today, 04:45 AM
                0 responses
                5 views
                0 likes
                Last Post cls71
                by cls71
                 
                Started by mjairg, 07-20-2023, 11:57 PM
                3 responses
                214 views
                1 like
                Last Post PaulMohn  
                Started by TheWhiteDragon, 01-21-2019, 12:44 PM
                4 responses
                547 views
                0 likes
                Last Post PaulMohn  
                Working...
                X