Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Need help to create sound alert when percentage of renko bar closes above/below SMA

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

    Need help to create sound alert when percentage of renko bar closes above/below SMA

    hi,

    I was wondering if you could help me with a issue i am having while creating a new ninjascript strategy in NinjaTrader. Basically i am using a 10 wicked renko bar for my strategy and i would like a simple sound alert to activate when i get 90% of the renko bar close above or below a 14 day SMA.

    i have managed to create a sound alert when the 10 wicked renko bar closes above or below the 14 day SMA, but what i realy want is the alert to activate when at least 90% of the bar closes below or above the 14 day SMA.

    Could you please tell me how i would create this in my ninjascript strategy if possible.

    thanks
     
    tom


    #2
    Welcome to our forums Tom - you would first need to calculate what 90% of the bar is for your script. So for example calculate what 90% of the barsrange would be and subtract / add to the extremes to know your level to compare to the SMA then.

    Comment


      #3
      hi Bertrand,

      thank you for your welcome and reply.

      I am new to strategy development and I used the strategy wizard within NinjaTrader to help me create my existing strategy. Would it be possible to do as you say using the strategy wizard as I don't know how to write any code.

      thank you again

      tom

      Comment


        #4
        Hi Tom, would unfortunately need custom coding, as you would need to be able to achieve some math operations for this that would be out of the scope of the wizard interface.

        I haven't really tested it much, however a simple approach to do this could be -

        double myVal1 = 90 * ((High[0] - Low[0]) / 100);
        double myVal2 = High[0] - myVal1;

        if (CrossAbove(Close, SMA(20), 1) && Close[0] > Open[0] && myVal2 >= SMA(20)[0])
        DrawDot("tag" + CurrentBar, true, 0, myVal2, Color.Blue);

        Here we basically calculate what 90% of the candle would be so we can check if that level is equal or greater to the SMA on up crossover. To use this snippet though you would need to unlock your strategy script and manually work that in, before doing that I would suggest to make a copy of the existing script first, Just select the view code button, right click in the code and select to 'Save as'.

        Comment


          #5
          hi Bertrand,

          thank you for your reply and the snippet.

          I have managed to unlock my strategy script but am unable to insert the code you gave me as it keeps coming up with errors, could you please tell me where to insert the new snippit of code you sent me?

          I have attched a copy of my strategy, i have been trying to replace the:
          if (CrossAbove(SMA(ShortSMA), SMA(LongSMA), 1) section with the code you sent me as this is the section i would like to replace.

          The(shortSMA)represents 1, i used this to represent price movement, and the (LongSMA)represents 14.

          thank you for your help

          tom
          Attached Files

          Comment


            #6
            Hi Tom, as a coutesy to get started, please check into the attached script where I've included the 90% detection in the conditions as example to work from.
            Attached Files

            Comment


              #7
              Thank you very much for your help, I will get started on working with this.

              regards

              tom

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              668 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              377 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              110 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              575 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              580 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X