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

Simple MACD Strategy Problem

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

    Simple MACD Strategy Problem

    Greetings,

    I have a very simple MACD based strategy that I would like to code for automation. I have hired a Ninja Script Consultant to write the code and so far he has been unable to get it to work properly. This is surprising and very frustrating to both of us considering how simple a strategy it is. Instead of giving you the specifics of what is going wrong, I would like to ask you a more general question: do you think that the following strategy is something that can be coded correctly for Ninja Trader or not...

    Trading Strategy For The S&P E-Mini:
    • Entry is based on a crossover/under of the MACD on a standard candle chart, either Long or Short. Crossover/under (entry signal) must be confirmed by the close of the bar that the crossover occurs on. Then, entry is immediate at the open of the next bar as a Market Order.
    • Strategy must ignore any subsequent MACD crossovers until an active trade is complete (one trade at a time..).
    • A Stop Limit Order is set at 3 points and the Profit Target (Limit Order) is set at 2 points. Stops and Profit Targets must be entered simultaneously along with the execution (entry) of the trade and be on an OCO basis.
    • Start and end times are at the open and close of the Day Session. Maximum losses for the day is 2 trades and maxium total trades for the day is 6.

    That's it. It's really very very simple and we can't seem to make it work. Do you see any reason why this cannot be coded?

    Thanks,

    Brian

    #2
    Brian,

    Are you by chance working with MooreTech? If your case is the same as his, what you need to do is compare the indicator with the correct settings. From the screenshot you had before you were using MACD with CalculateOnBarClose = true while your strategy was running CalculateOnBarClose = false. This will of course show up differently. You need to run both on false or both on true. Then you will be comparing apples to apples.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Yes Josh, I am working with Moore Tech. I don't know which screen shot you are referring to but I assure you I have been running both as true and it DOES NOT work!

      Actually Tyler instructed me today to try changing the chart to false and keep the strategy at true!!! I don't know why he would have suggested this giving what you are telling me...And I can't run both as false since my strategy requires that the MACD cross must be confirmed by the close of the bar as stated in the parameters of the strategy I wrote out earlier.

      Are you sure you are understanding the order entry dynamics I outlined?

      The only other thing I have been running on the chart is a bar timer...I could try removing that if you think it may be a problem. Or perhaps this too has to be set as true for calculateonbarclose???

      So again, this strategy does not work properly running both the chart and the strategy MACD settings as true.

      I am assuming that you are indeed affirming that Ninja is perfectly capable of running the strategy I have outlined? And if that is the case, then there must be a problem with the code, or possibly as Tyler suspects, a compatibility issue with Vista...

      Thanks,

      Brian

      Comment


        #4
        Brian,

        I don't know what other screenshots are out there between your discussion with Tyler. There is no problem with NinjaTrader running a strategy as you have outlined provided it is coded correctly. Since Tyler says he is unable to reproduce on his end it is likely an issue not based on coding.

        I cannot assist in this case based on the generalities we are discussing on right now. What I need you to do is post screenshots of your exact setup and what you feel is not working as expected. Also include exact steps as to how you are loading your strategy, loading your indicators, etc.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          OK. Attached is the first trade of the day.
          • Entry is too early
          • Stops and Profit Targets are not entered immediately (waits until close of the bar)
          • Profit Target is exceeded by 1.25 points (because of lagging entry...)
          I open Ninja Trader. My chart/workspace is saved and appears. I log onto the simulation account. From the chart I click on the strategy button. All parameters are preset and I click OK.

          Please let me know what other information you need.

          Thank You,

          Brian
          Attached Files

          Comment


            #6
            diamondpearl,

            The cross looks like it happened on the bar I marked. Being a cross on the bar I marked the trade occurred exactly when it should have. Depending on how your stop is actually programmed different behaviors may occur. Slippage is a very real possibility in all cases. Only way you can quantify if the cross is accurate or not is by printing out values or manually checking those MACD values. Looking on the Data Box will not suffice since those are rounded values. You need to see the values as printed out from either an indicator or a strategy.
            Attached Files
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              OK. Please tell me the process of how I can quantify the MACD values by printing them or checking them manually...

              Also, assuming the cross is correct, then the bar where the order was entered at opened at 828.25 and I got filled at 830.50! That's alot of slippage! ...but I suppose the market could have been moving really fast at that point...

              And lastly, why are the stops and targets not being entered immediately?

              Thanks,

              Brian

              Comment


                #8
                I cannot discern anything as to what the expected behavior of your stops/targets will be. You will need to discuss this with Tyler. From the screenshot it would appear he is using explicit sell orders instead of SetStopLoss() or SetProfitTarget() orders to close out your positions.

                To check the MACD values you need to create an indicator and just run a Print() statement through it. You may want to work with Tyler to quantify out the strategy he has created here. Tell him to add prints to the strategy in a fashion that both of you can use to quantify the trade condition.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  OK Josh. Attached is VERY clear example of a trade that is being entered too early. You don't need to check the values on this one...

                  Let me know what you think now.

                  Thanks
                  Attached Files

                  Comment


                    #10
                    Please take a screenshot of your Strategy selection window with all the strategy settings as well as a screenshot of your Indicator selection window with the settings for your MACD indicator.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      Sorry, but, please instruct me on how to do that...

                      thanks

                      Comment


                        #12
                        Ctrl+S on your chart to open your strategy selection window. Press the PrntScrn button on your keyboard. Open up Paint in Windows (Start Menu -> Run -> mspaint) and press Ctrl+V to paste. Save the screenshot as a jpeg and then go ahead and attach it. If the file is too big for the forums please upload it to tinypic.com or any other image hosting website and link me to it from there.

                        Do the same with Ctrl+I for the indicators with the MACD selected while showing all of the settings on the right hand side.
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          Ok, here's the links...



                          Comment


                            #14
                            I see. To proceed forward I will need to see code. I suggest we take this off the forums since you are paying for the code. Please email me the strategy at josh[dot]peng[at]ninjatrader[dot]com. If the code is in a protected format please contact Tyler to release the code to me. Thank you.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              help with macd strategy

                              Originally posted by NinjaTrader_JoshP View Post
                              I see. To proceed forward I will need to see code. I suggest we take this off the forums since you are paying for the code. Please email me the strategy at josh[dot]peng[at]ninjatrader[dot]com. If the code is in a protected format please contact Tyler to release the code to me. Thank you.
                              I WANT TO MAKE A MACD CROSS OVER STRATEGY
                              I WANT WHEN THE diff line cross -0.02 a sell order is place followed with a trail and stop
                              I WANT WHEN THE diff line cross 0.02 a buy order is place followed with a trail and stop

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by jeronymite, 04-12-2024, 04:26 PM
                              3 responses
                              39 views
                              0 likes
                              Last Post jeronymite  
                              Started by bill2023, Today, 08:51 AM
                              2 responses
                              15 views
                              0 likes
                              Last Post bill2023  
                              Started by sidlercom80, 10-28-2023, 08:49 AM
                              167 responses
                              2,260 views
                              0 likes
                              Last Post jeronymite  
                              Started by warreng86, 11-10-2020, 02:04 PM
                              7 responses
                              1,362 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by Perr0Grande, Today, 08:16 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post Perr0Grande  
                              Working...
                              X