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

How to set alert based on MA cross?

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

    How to set alert based on MA cross?

    To the developers: I have looked through the help file, how to set alert in Market analyzer, but i don't think that will accomplish what i want to do.

    I want to set a simple visible + audible alert on a chart when the current bar price crosses above/below a certain SMA line, that is the only condition. Should that be done under a strategy or there is another simpler way, how?

    Thanks for the help.

    #2
    ju1234, you can do this in an indicator.

    You can utilize the CrossAbove() and CrossBelow() methods to identify crossovers:
    Code:
    // do something if the close of the current bar crosses above 20 EMA within the last bar
    if (CrossAbove(Close, EMA(20), 1))
    {
     // do something, like draw an alert or play a sound
    
    }
    To create a visual alert, you could do something like draw a dot with DrawDot():
    Code:
    // Paints a red dot on the current bar 1 tick below the low
    DrawDot("tag1", true, 0, Low[0] - TickSize, Color.Red);
    Lastly, for an audio alert, please see the PlaySound() help page:
    Code:
    // Plays the wav file mySound.wav
     PlaySound(@"C:\mySound.wav");
    AustinNinjaTrader Customer Service

    Comment


      #3
      If i place both up and down: price crossabove SMA50
      Price crossbelow SMA50 as two conditions in the same strategy,

      will that work?

      Are above two conditions read by the system as AND or any of the two?

      I am thinking that the system is going to look for both (which is not possible) and therefore not trigger.

      Am i right? and that means the two should be created and applied as two separate strategies, right?

      Comment


        #4
        Hello,

        You can only EnterLong() as many times as you would like with the strategy settings.

        For example, if you start the strategy with the settings of Entries Per Direction set to 1. You can only Call EnterLong() once and then go long once. You can then call EnterShort() to reverse your position.

        If you set Entries Per Direction to 2, if you call EnterLong(), and Then EnterLong() again you will have 2 entries allowed. However a third call to EnterLong() would be ignored.

        Let me know if I can be of further assistance.

        Comment


          #5
          I don't think you understood my question correctly.

          Let us, for now not worry about entry long or short. Just use the strategy to trigger say an alert. Here is an example:

          I entered in the wizard (i have no ability to enter code directly) two conditions in the conditions section: first line If Price close crosses above SMA50
          Second Line: If price close crosses above SMA100.

          Then .....alert.

          First question that i have not asked before: entering the above two conditions seem to trigger an alert only when the current bar passes through both line simultaneously and not when the close price is above both lines. What i want is to trigger the alert when the price is above both lines for the first time rather than the same price bar penetrating both lines simultaneously. How?

          Now, going back to the question I had asked earlier: To make it simple, In the conditions, I enter: If price close crossaboveSMA50, second line I enter If price close crossbelow SMA50 THEN ..............

          Now I am thinking putting these two conditions in the same panel would be incompatible therefore will not trigger.
          Instead, if i enter them separately in SET 1 and SET 2, it will work correctly as two sets of conditions triggering two sets of actions. Right?

          Thanks.

          Comment


            #6
            Hello,

            Correct you would need to add these as their own set if you want them to run seperately.

            As if you add them under the same set. ALL The conditions must occur for the Do The Following to execute.

            Let me know if I can be of further assistance.

            Comment


              #7
              Please answer my "First question" also in my last post. Thanks.

              Comment


                #8
                Hello,

                The answer is the same for both. You would need two sets to do this.

                Most likely in the first set I would then set a variable to true. Then in the second set check to make sure the variable is true indicating the first condition occured. Then when the second condition occured both would have occured and you can do the following:

                You would then also need a set to set this variable back to 0 or false when you want to recheck for the condition.

                Comment


                  #9
                  OK. That sound complicated. I am not really sure how i set a variable etc. Is there an example that might help me accomplish this. Thanks.

                  Comment


                    #10
                    Hello,

                    Unfortunately not a specific example for what your trying to do. However its not too too bad.



                    Please see this page: How to use user defined inputs & variables

                    For further information on how to do this.

                    If your still running into issue coding this yourself.

                    You can contact one of our NinjaScript consultants to assist you with coding this or you can use our NinjaScript guide and forums to code this indicator yourself if you are a programmer.

                    NinjaScript Consultants:

                    NinjaScript Help Guide:

                    NinjaTrader Support Forum:



                    Let me know if I can be of further assistance.

                    Comment


                      #11
                      Thank you. I will work on it.

                      ANOTHER question: The indicator RSI (Close,14.3) built into NT plots two lines. I wanted to use a single line plot (I assume that would be no averaging). How do i modify this existing RSI. Thanks.

                      Comment


                        #12
                        Hello,

                        You can set a plot line to transparent in color if you just want to get rid of a plot. No custom programiing needed if I understand what your trying to do correctly.

                        I look forward to assisting you further.

                        Comment


                          #13
                          When applying the RSI to a chart, I see "period" selection = 14, that is the only number that needs to be kept, If I choose the "Smooth" number to 0, instead of present 3, will that not remove the smoothing line? The period selection is what calculates the RSI, correct? Thanks.

                          Comment


                            #14
                            I am also trying to right a condition in the wizard:

                            RSI 14 should be less than 90. In the wizard on the left I selected RSI, set the parameters in it, 14, smooth to 0, in the middle selected <, in the right hand panel it comes up blank without any place to right in the number. What am i doing wrong? Thanks.

                            Comment


                              #15
                              Hello,

                              Yes setting this to 0 should remove the smoothing.

                              Also, to compare against a number in the condition builder please use Misc->Numeric Value.

                              Let me know if I can be of further assistance.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by rbeckmann05, Today, 05:50 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post rbeckmann05  
                              Started by doihaveto13, Today, 05:45 AM
                              0 responses
                              2 views
                              0 likes
                              Last Post doihaveto13  
                              Started by giulyko00, 04-24-2024, 12:03 PM
                              9 responses
                              43 views
                              0 likes
                              Last Post giulyko00  
                              Started by memonic, Yesterday, 01:23 PM
                              2 responses
                              25 views
                              0 likes
                              Last Post memonic
                              by memonic
                               
                              Started by merc410, Today, 03:41 AM
                              2 responses
                              18 views
                              0 likes
                              Last Post merc410
                              by merc410
                               
                              Working...
                              X