Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MACD Trigger Immediately?

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

    MACD Trigger Immediately?

    Hello all,

    Here is a screenshot of what I am talking about to hopefully make this easier:

    World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.


    As you can see, the MACD crossed over, but the program doesn't take an entry until the open of the next candle.

    Is there any way to take a position as soon as the indicator crosses over? Also, is there any way to take a position say after the indicator has crossed over for a set timeframe (15,30, mins etc.)

    Lastly, how do I get rid of afterhours data and trading for both the chart and this particular strategy?

    Thanks for the help guys,

    Loren

    #2
    And I didnt want to make a thread, but I now have another question. Keep in mind I am a beginner at anything of this nature, so any and all help will be appriciated...

    Here is the current setup I have:
    World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.


    This is setup is currently triggering both entries and exits on crossovers. It seems to ignore the stops I have in place.

    Ideally, I would like to create some sort of a conditional order system as follows:

    Crossover triggers the initiation of a position. Immediately the following orders are triggered in a one cancels other fashion:
    x% target price to dump half the position
    x% firm stop price to dump entire remaining position
    x% trail stop price to dump entire remaining position

    To me, this sounds essentially impossible to accomplish. If someone could send me in the right direction that would be awesome.

    Thanks for all the help you guys have given me over the past few days, and let me know if you have any more questions,

    Loren

    Comment


      #3
      Hi Loren1711, thanks for your posts.

      1. The MACD trigger behavior is expected, in backtesting we have to wait for the bar to be closed, then we can proceed to place orders on the next bar. Althought a bit more advanced, this reference sample shows how achieve a finer resolution in backtesting - http://www.ninjatrader-support2.com/...ead.php?t=6652

      2. You could for example use CountIf() to go only long when there have been for example 8 bars over the last 10 bars where the MACD was above its trigger - http://www.ninjatrader-support.com/H...6/CountIf.html

      3. Please double click on the chart and adjust your session time in the Chart properties, this will then exclude the data you don't need for your strategy - http://www.ninjatrader-support.com/H...roperties.html

      4. Your TrailStops won't activate because you set the percent value too high, please try for example 0.03 for 3 percent - http://www.ninjatrader-support.com/H...TrailStop.html

      5. Unfortunately you can't use SetStopLoss and SetTrailStop for the same position, but we have a reference sample showing how to code such a behavior - http://www.ninjatrader-support2.com/...ead.php?t=3222

      Comment


        #4
        Truly unbelievable help. Thank you so very much. I will give all of it a try when I get home tonight.

        Thanks again.

        Comment


          #5
          You are welcome, thanks for the kind words!

          Comment


            #6
            Alright, I did a little more messing with the stops. Now I can actually get them to trigger, but I'm seeing a lot of candles like this:

            World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.


            As you can see, the entry is taken on the open of the candle. It goes up, and retraces a little, leaving a wick on the top. Using a 2.457% trail stop, the retracement from the high down to the close is no where near enough to trigger the stop, yet for some reason, it triggers anyway.

            Can anyone explain this?

            Comment


              #7
              The high of your bar was ~53.30. 2.457% brings that stop to ~51.99. Your price is 51.50 which is way lower than your stop. Therefore your stop gets filled.

              You cannot assume anything about what happens intrabar. You have no information on how the price action inside that bar occurred and as such NinjaTrader will take the most conservative approach possible. If the stop price is touched or surpassed at any possible point it will be filled in backtesting.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                Ahh thank you sir that makes sense. Again, I apologize to keep posting, but I honestly dont know how else I'm gonna learn how to do this.

                I am trying to set up a system that runs as following:

                Crossover triggers the initiation of a position.The exit strategy for the plan would be as follows:
                x% target price to dump half the position
                x% firm stop price to dump entire remaining position
                x% trail stop price to dump entire remaining position

                Here is what I have put in so far, mainly using the example scripts:

                World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.


                I dont know if this is correct, but it would seem that the easiest way to dump say half a position at a target price would be to open two positions in the first place, both with separate names, and close one when the target price is reached. Initially the trail and firm stop would apply to both, but after the target price is reached, they would only apply to the second. Is this accurate?

                Second, there are two error messages at the bottom that I cannot seem to get rid of. Everything looks fine to me, but they are still present.

                Also, does anyone have any particular online tutorial recommendations for this type of coding.

                Comment


                  #9
                  Hi Loren1711, you can click on the error messages at the bottom of the editor, it will then take you directly to the error that needs further debugging. This tip will also be helpful - http://www.ninjatrader-support2.com/...ead.php?t=4678

                  Unfortunantely you cannot use SetTrailStop and SetStopLoss concurrently - http://www.ninjatrader-support.com/H...tStopLoss.html

                  To learn how such a behavior can be coded, this will be a good sample - http://www.ninjatrader-support2.com/...ead.php?t=3222

                  You can also take a look at those scripts posted to our sharing dealing with this topic - http://www.ninjatrader-support2.com/...railing&desc=1

                  Comment

                  Latest Posts

                  Collapse

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