Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy Wizard Help

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

    Strategy Wizard Help

    Hi, can someone help me out with this strategy developing?

    Here's what I am trying to do:

    1) Use BrooksBars (indicator that detects insidebars) as entry long or short entries.

    What I need is to go long or short when the price moves 1 tick above or below the high or low of the indicator detected in the prior bar.

    Example: BrooksBars detects an inside bar with a high of 1950.50 and a low of 1949.50.

    Action: If price moves to 1950.75 go long
    If price moves to 1949.25 go short

    When triggered:
    Profit Target: +1 tick
    Stop Loss: -3 ticks

    The trigger has to happen in the very next bar, if don't, the orders won't be activated (most likely because the "execution" candle will be inside the prior bar which was the signal)

    Anyone can help to work it out inside the strategy development wizard?

    Thank you.

    #2
    Hello monsieur,

    Thanks for your post.

    Regrettably the Brooks bar indicator does not contain an output that can be used in a strategy. You would need to modify the Brooks bar indicator code to output a signal that could be then accepted by a strategy.

    If you would like to do this yourself (modification of an indicator) then it may be best for you to post in the indicator thread what you want to do.

    Alternatively, if you are interested in having a 3rd party programmer providing what you need (modification to the brooks indicator or modification to the brooks indicator and creating your strategy), please let us know and we can provide references to 3rd party programmers.

    Comment


      #3
      help on strategy wizard use

      Hi all,
      please can anyone help on how to tell to NT7 Strategy Wizard to enter a long position when MACD crosses above its smooth line (MACD and smooth line of this example are derived from TDMACD an indicator I found in another forum, but I think my question may apply to any other oscillator as well) but only when this crossover happens within n bars from the bar at which MACD has detached from its last lower minimum value calculated over the last m bars.
      On the attached example-image I have tried to set n = LookbackPeriod and m = MinMaxPeriod in the anaDonchianChannel indicator. I have used the anaDonchian because the default Donchian of NT was not accepting the above instruction from the wizard.
      But all this doesn't seem to work anyway ....

      The position should be reversed to short when the opposite happens, ie. at a cross below within n bars from the upper border of the DonchianChannel with a period of m bars.
      Is it possible to modify the instructions shown on the attached wizard in order to obtain what described above?
      Thanks. GT



      here is the view code of the condition I have tried to implement with the strategy wizard:

      // Condition set 2
      if (CrossAbove(TDMACD(MACDfast, MACDslow, MACDsmooth), TDMACD(MACDfast, MACDslow, MACDsmooth).Avg, 1)
      && anaDonchianChannel(TDMACD(MACDfast, MACDslow, MACDsmooth), MinMaxPeriod, anaDonchianInput.Use_HighLow).Lower[0] == TDMACD(MACDfast, MACDslow, MACDsmooth)[LookbackPeriod])
      {
      EnterLong(DefaultQuantity, "");
      }
      Attached Files

      Comment


        #4
        Hello guidoisot,

        Thanks for your post.

        With the strategy wizard you are a bit limited in the code you can create. To accomplish your goals you could unlock your code and work directly in the ninjascript/C# language.

        Then you could compare the Donchian channels current value to its previous value and if it makes a new high or low, set a variable to capture the bar number, later on when the Macd crosses, compare the saved bar number to the current bar number and through subtraction determine if you should then take the trade.

        Comment


          #5
          how to insert a bar counter into a script

          Hello Paul,
          thank you for your reply.
          I got another similar indication on this script problem, here

          where I have replied attaching my attempt to complete the strategy.
          I hope I can make it by myself, otherwise I will try to contact you again.
          Thank you . Best regards. Guidoisot
          Attached Files

          Comment


            #6
            Hello @NinjaTrader_Paul,
            I have received the corrections shown on the attached .cs
            However it appears that there are new errors not referenced by NinjaTrader help.
            Please can you give some hint on how to overcome this?
            If this were ok with you, I would then share your insights about this strategy also on the other forum.
            With regard to this example, I would like to add that since I am also trying to get familiar with NT8, maybe this script could be picked up for showing either how to migrate from NT7 to NT8 or how to build in parallel such a simple strategy on both versions of NT. Maybe this exercise could benefit other beginners, it could exemplify whether it would be simpler building this kind of scripts on NT8 compared to NT7, it would be a good opportunity for me to start practicing on NT8.
            Thank you. GT
            Attached Files

            Comment


              #7
              Hello guidoisot,

              Thanks for your reply.

              The errors as listed are on line 55 and 72 which are your "if" statements. The issue is that you do not have the correct requirements for the 3rd party indicator being used. I think this can easily be corrected and you can use the strategy wizard to create the solution.

              Just above line 55, type "if ( then right mouse click and select "insert condition", which will bring up the strategy wizards condition builder, use that to create the if statement using all of the correct parameters. When you click Okay the wizard will then post the code in for you and all you need do is add ) at the end of the statement. Next delete the current "if" statement on line 55 and your new if statement should be good to go. Repeat the process for line 72.

              To help you see the process, I've created a short video: http://screencast.com/t/V2l9jju0gW Please note that in the video I do not have the same indicators so i cannot show you exactly but it looks like you are quite familiar with the strategy wizard so i think you will have great benefit from this tip.

              Regarding NT8, as you are new to coding I think this would be difficult and recommend that you wait until the full strategy wizard is implemented in NT8. However if you want to see examples, you can see any number of NT7 to NT8 strategy conversions in the NT8 strategy file sharing forum. In addition you would want to review the code breaking changes as well here: http://ninjatrader.com/support/helpG...ng_changes.htm

              Comment


                #8
                Hello Paul,
                thank you very much for your very helpful reply with the interesting screencast. I have tried to implement the changes. I have also changed the oscillator. It looks like the script is now compiling, but from backtesting it there are no trades coming out. Please can you perhaps give a look to help me in finding out is wrong with the script?
                On a longer term perspective my plan, after having this strategy working, would be checking out which are the most effective oscillators, ….. volume oscillators?, momentum oscillators?, relative strength oscillators? ….then further filtering trades by integrating the strategy with a supply demand criteria (take longs only when there is also a bounce on a support zone, and the reverse for shorts on a resistance zone). Initially I would like to test all this on a daily timeframe and on a portfolio of highly traded instruments, such as main ETFs or main stocks, for ex S&P100. It looks like a very long way to go, but anyway it is also great fun for me to use NinjaTrader for all this.
                Thanks.
                Best regards.
                Attached Files

                Comment


                  #9
                  Hello guidoisot,

                  Thanks for your reply and glad we were able to help. Learning the strategy wizard first as you have will help you going forward in your coding as you can always pull those conditions and actions in.

                  To further assist you in debugging your code, you will want to add "Print" statements to understand what parts of the code are executing and which ones are not. The output of the Print statement goes to the Tools>output window.



                  For example on your first if statement:

                  Code:
                  			// Condition set 1 - MIN line is not falling anymore
                  				if(MIN(anaAwesomeOscillator(5, false, 34, 5).Oscillator, 60)[0] >= MIN(anaAwesomeOscillator(5, false, 34, 5).Oscillator, 60)[1])
                  			{
                  
                                            [COLOR="Blue"] Print ("Time: "+Time[0]+" Condition 1 is True!");[/COLOR]
                  				
                  				// Condition set 1.2
                  In the above example Time[0] will provide the end time of the bar(s) where condition 1 was true. This then lets you know that at least condition 1 was true. You can continue the example in your other conditions. You can also print out values to understand what the conditions actually were.

                  Other debugging tools would be to drawdots or other objects on the chart when the various conditions are true, such as DrawDots ("test"+CurrentBar, true, 0, Low[0] - 3 *TickSize, Color.Red); will draw a red dot 3 ticks below the low of the current bar. This then shows you on the chatrt when that particular condition is true. when you have a number of conditions you can use different colored dots at various heights to see when all of your conditions line up.

                  Debugging can be frustrating so take your time and help yourself out by using both Print and drawdots. The more things you can put on the chart and/or print out the more confirmations you will have and not need to ask why is it not working.

                  Please also review our debugging scripts reference here: http://ninjatrader.com/support/forum...ead.php?t=3418

                  Comment


                    #10
                    Hello Paul,
                    thank you for your reply.
                    - inserted the line of code with the print statement.
                    - saved the script so modified (image attached).
                    I understand that now, in case the statement on line 65 was true, I should (somehow) find the phrase "Condition 1 is True" written on the Tools/Output Window.
                    I apologize, but about this I whould need to ask a few questions:
                    1. how do I launch the test? The debugging procedure?
                    2. from the strategy analyzer?
                    3. how do I open the output window, sometimes I have to restart NT, because it goes in "aborting mode" and it gets stacked there.
                    4. or should I select "debug mode" from the right click menu? And then how should I proceed?
                    5. what is debug mode?
                    6. what is the meaning of: "Time: "+Time[0]+" on the initial part inside the print statement parentheses ?

                    I have tried to look for explanations on the help, or for some videos on YouTube, but I did not find much.
                    Do you know if anyone retails some kind of good DVD tutorial with a logical sequence of video lessons, designed to be a structured guide for beginners in exploring specifically the use of C# applied to ninjatrader. For example something more practical, more extensive, and more “strategy example based” than the content of
                    this video https://www.youtube.com/watch?v=O5ZqZBBG_k4
                    I am sure that on NT help there is almost everything one needs, but I find it kind of difficult to spot the right place for the simple short answers I need to my newbie's doubts. I would find much easier a learning approach to NT by examples. Have you ever considered of increasing in the platform the library of sample strategies available (now there are only 4 of them) and associate to each one an explanatory video ?
                    Thank you.
                    GT
                    Attached Files

                    Comment


                      #11
                      Hello guidoisot,

                      Thanks for your reply.

                      To bring up the "output window", in the NinjaTrader control center go to tools>Output Window.

                      To see the output of the Print statements you simply run the strategy (strategy analyzer, or live or market replay) and when the conditions are met the print statement will send its output. to that window.

                      The meaning of "time:" is a string that is printed in this case as a label. Time[0] will provide the closing time of the bar: http://ninjatrader.com/support/helpGuides/nt7/?time.htm Note that in the example they also show the use of Print statements.

                      The debug selection in Ninjascript is only relevant if you have attached a 3rd party debugger that supports .net such as visual studio. Please do not turn that on or if you have uncheck it and recompile.

                      Regrettably there is no one guide that shows you both C# programming and Ninjascript from the ground up so to speak. The Helpguide does provide references for learning here: http://ninjatrader.com/support/helpG..._resources.htm Please be sure to follow all of the links.

                      The current NT8 strategy library is only 4 as you have noted but it is a work in progress and of course it is open for all members to post their NT8 strategies. We support both NT7 and NT8beta so this is keeping us pretty busy day to day but over time the library will grow as we had converted strategies and/or members share theirs.

                      Please note that in the reference section we have converted all of the reference samples to NT8 so those are another source that is of great assistance: http://ninjatrader.com/support/forum...splay.php?f=30

                      We do offer live training sessions daily and the schedule can be checked here: http://ninjatrader.com/PlatformTraining

                      In particular you may want to attend the Ninjascript editor 401 training. Here is a recorded session of that: https://www.youtube.com/watch?v=K8v_...D7105&index=11

                      Comment


                        #12
                        cannot get rid error on strategy built with strategy wizard

                        Hello, please could anyone help on how to solve the compile errors on the attached strategy samples?
                        thank you.
                        Attached Files

                        Comment


                          #13
                          Hello guidoisot,

                          Thanks for your post.

                          For your strategy "DetachCross", on line 50 you have Add(MAX(UltimateOscillator(7, 14, 28)), 60); If you compare that to line 49: Add(MIN(UltimateOscillator(7, 14, 28), 60)); Note the difference in parenthesis location.

                          For the strategy "DetachCrossUltimate" In the DrawDot statement you have a color called Color.HotTrack which is not a recognized color.

                          For both strategies you are using the JMA which according to the error messages does not exist in your system.

                          Comment


                            #14
                            Thank you very much. Guido.

                            Comment


                              #15
                              Hello Paul,
                              finally this script is compiling. I corrected, double checked, triple checked …. several times each single item written in the “protected override void Initialize()” container, but I had to give up, because I have not been able to bypass the persistence of the “.. argument not valid” error messages. In order to achieve this I created with the wizard the "DetachCrossUltimate" strategy (compiling) as a clone of the main strategy "DetachCross". The only difference between these two strategies was that the clone did not include the bar counter function (not supported by the wizard). Then I copied from the clone and pasted/replaced into the main strategy those parts that on the main script where persistently giving “argument errors”.
                              However now that I could backtest a couple of times the strategy I have found out it is not doing what I wished. It appears that the logic applied by the bar counter method is not sufficient to guarantee trade execution only within n bars (the “DistanceCross” variable) next to a detachment of the oscillator from either one of the two border lines represented by its MIN and MAX values (calculated over m periods, the “MinMaxPeriod” variable). If the MIN line moves up, then at the first new crossabove of the oscillator to its SMA a new long is executed. The reverse happens for shorts. My goal instead was triggering an execution only when the oscillator had touched, not earlier than n bars, either one of its MIN or MAX border lines.
                              I am now trying to figure out how to modify the strategy for achieving this goal.
                              I attach the .cs of the strategy.
                              Thank you.
                              Attached Files

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              558 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              324 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
                              545 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              547 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X