Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to set alert based on MA cross?

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

    #46
    Hello,

    Goto Control Center->File->Utilities->Export NinjaScript.

    Then export it out.

    It will be located at My Documents->NinjaTrader 7->bin->custom->ExportNinjaScript.

    PLease send me the file with the .zip extension that is created.
    BrettNinjaTrader Product Management

    Comment


      #47
      This strategy has 6 sets of conditions/actions in it. I have tried to set a variabl0=0 type thing and then entry long, exit strategy followed by check for flat and then short entry etc.

      It seems to work in some parts of the chart and not others. If you can please check it for correct form etc.

      Thanks.
      Attached Files

      Comment


        #48
        Hello,

        Please check your ExitLong() and ExitShort().

        You have in there no name for it the entry signal. Your entry signal name is "S" for the EnterLong().
        BrettNinjaTrader Product Management

        Comment


          #49
          Thank you. Does every thing else look ok?

          I was particularly concerned about the variable0=0 thing. That is supposed to prevent repeated signal after teh first fill, right?

          What I am trying to do is enter long/short based on the SMA50 and exit that position before another signal is taken.

          One problem i have seen with this is: say a short is generated by the system and then price keeps going up but the price never touches the SMA50 line to generate a new buy signal and the short never exits even though price has moved way high. How can i rectify that situation.

          If you don't mind, can you please run this strategy on a 1 minute or 5 minute chart of ES or oil and see if you notice any other problems.

          Other viewers in the forum are also welcome to review it and make suggestions. Thanks.

          Comment


            #50
            Hello,

            I'm unable to review the entire code and its logic. If you have a specific question I can answer this. However as far as the code creation I cannot assist with Unfortunaley as this is what we have NinjaScript consultants for.

            Let me know if I can be of further assistance.
            BrettNinjaTrader Product Management

            Comment


              #51
              Specific problem, if you can address it please, say a short is generated by the system and then price keeps going up and up price never touches the SMA50 line again to generate a new buy signal, so the short never exits even though price has moved way high. How can i rectify that situation.

              Another question: I want to put trading hours parameter in it. THE SAMPLE TIME FILTER you guys have on this iste is in the code format and does not open in the wizard format. Is there a wizard version so i can modify it myself.

              Looking at the wizard: there is the choice of time in the left panel, then the comparators are same as usual (there is no from to format). Will i be writing it then as Time > 90000 AND Time <160000. Is this right?

              Comment


                #52
                ju1234, so you mean there's no exit / reverse signal generated to get you out of the short? You could address this by a stop loss. The time filter sample is meant for coding yes, but you can achieve the same in the wizard like you found - those conditions would allow triggering then between 900 and 1600 -

                Comment


                  #53
                  Is the time supposed to be local time (AS set on the computer clock) or chart time?

                  Comment


                    #54
                    I notice that "Look back period" is available only with CrossAbove or CrossBelow.

                    I want to express this condition: If SMA50 > SMA100, for any of the last 5 bars (it may not be true for the current bar, could be true for bar 2 or 3 and so on).

                    How would do this in the Wizard. Thanks.

                    Comment


                      #55
                      Time filter

                      Using the Help Guide "How to create time comparisons" I ran into the following problem:

                      Instructions show to select "Time series" and the relational >" But when i do this, only relational tath are available are == or 1=, the > or < is not available.

                      If I use the "Time value" from the left panel and enter the time numerical, then i can choose the > or < relational, but then in the right panel if I choose "True" it says "invalid".

                      Can you please guide, how I can apply a strategy only during 9AM to 4PM. Thanks.

                      Comment


                        #56
                        OK. I was able to add the time criteria in by directly editing the code. I added the time constraints to the "Conditions" part of the code. After that i applied the strategy to a chart, 24 hour chart. It seems to work and produced the signals in the chart, not only during the time constraints i put in the code 6:00 to 1:30 PM, but through out the 24 hour period.
                        This is the line I added to each of the sets. The little red line that appears below the editing window that tells you if the coding is right or not was ok.

                        && (ToTime(Time[0]) >= 060000 && ToTime(Time[0]) <= 133000)

                        Thanks.

                        Comment


                          #57
                          I have a strategy that has been working fine. In the wizard, I deleted two sets out of the six sets there were in this strategy and tried to save it with a new name. It says "error generating strategy". On the bottom of the code page it shows the error:

                          Invalid expression term '&&' code "CS1525- click for info Line 89 column 5


                          Clicking on the CS1525 says no info available. The line 89 has only a + sign followed by boxed in line written "wizard settings, neither change nor remove". No other line shows any error.

                          Please tell me how i can fix this. Thanks.

                          Comment


                            #58
                            Hello,

                            Time is your local PC time.

                            Also on the generation issue. This could be a strange bug ou ran into. Can you please go back into the strategy wizard and then press the view code button. Then send me everything in OnBarUpdate() with a copy and paste.

                            I look forward to assisting you further.
                            BrettNinjaTrader Product Management

                            Comment


                              #59
                              I don't quite understand the method of sending you the file. I have the script open with the error code showing on the bottom. Where do i find "in onbarupdate()"? Do i just copy the contents of the "viewcode" window and paste it into the message directly?

                              Comment


                                #60
                                Hello,

                                Can you please send me a note to support at ninjatrader dot com and reference this forum post and put attn: brett in the subject line.

                                I look forward to assisting you further.
                                BrettNinjaTrader Product Management

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                576 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                334 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                101 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                553 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                551 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X