Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Need help with wizard on gap strategy

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

    Need help with wizard on gap strategy

    Pls take a look at my strategy, I haven't figured out the use of variables. I assign 4:31pm (local time of US market open) to variable 0, 1 bar before (which is previous sessiuon close 11:00pm) to variable1 and then if variable0>variable1 I short and the opposite. In other words to fade the gap.
    Then when variable0=variable1 (which means gap closed) I exit long and short.
    The results on the graph don't match. It doesn't fade the gap, and exits either on stop loss or end of session. doesnt take into account the price of session open = close previous session (which is 1 bar prior to open which is time stamped). I tried to follow the online seminar stayed awake until 12:30 am and as soon as ity started it failed.....on your side.
    Then in the forum I can't attach my strategy for someone to have a look. Pls just take a look and tell me what is wrong.
    Perhaps variable0=1 and variable1=1 doesnt mean something?

    Is there a way I can assign a 50% (or user defined percentage) of route from open position to filling the gap (say half fill), and a stop of 30% the ATR(5days)?
    Attached Files

    #2
    alexnj,

    I responded to your other post with the same post. Please see my response there. We can handle the case here though since it was off topic in the other thread. Thank you.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      used prior/current session OHLC

      I tried something more simple and straight forward. yet the close doesn't taek place at gap fill. Open is fine now
      used priorsession close and current session open from indicators group.
      Am I getting closer??



      Originally posted by NinjaTrader_Josh View Post
      alexnj,

      I responded to your other post with the same post. Please see my response there. We can handle the case here though since it was off topic in the other thread. Thank you.
      Attached Files

      Comment


        #4
        Your code is just saying when the prior close is > current open, enter long. This condition is true for every single bar in the current session so you would be submitting EnterLong() over and over.

        Your exit says if the current bar's close price is equal to the day's open price and you are in a long position, exit long. This could happen, but will also be a more rare condition for the close price to be exactly the day's open price.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          You are right added timeseries=4:31 for 1 min chart (4:30 us open)
          have 2 vesrions, one with equal and the other cross above below for exits yet exits don't occur where I want them to! What is missing? Also entries are always in second bar of session. Need instantly when market opens at current 1 min bar.



          Originally posted by NinjaTrader_Josh View Post
          Your code is just saying when the prior close is > current open, enter long. This condition is true for every single bar in the current session so you would be submitting EnterLong() over and over.

          Your exit says if the current bar's close price is equal to the day's open price and you are in a long position, exit long. This could happen, but will also be a more rare condition for the close price to be exactly the day's open price.
          Attached Files

          Comment


            #6
            alexnj, this is expected with CalculateOnBarClose = true the bar will have to be closed and then you place the order for the next bar.

            For the exit, keep in mind for your condition the High or Low have to be exactly equal to the prior Close value, better would be to work with <= or >= to make sure you also exit when price pushes through.

            Comment


              #7
              Thanx Bertrand, now it works. Although it may go close to gap fill and then not match and stop comes in or exit on close. Is there a way to assign % of reaching entry (or last days close), meaning a percentage of the gap fill. Also I unchecked calculate on bar close but still entries are on second candle. Something else to change?


              Originally posted by NinjaTrader_Bertrand View Post
              alexnj, this is expected with CalculateOnBarClose = true the bar will have to be closed and then you place the order for the next bar.

              For the exit, keep in mind for your condition the High or Low have to be exactly equal to the prior Close value, better would be to work with <= or >= to make sure you also exit when price pushes through.
              Attached Files

              Comment


                #8
                Changing CalculateOnBarClose would only have an effect in realtime - http://www.ninjatrader-support.com/H...BarClose1.html

                To create a percentage based gapfill you would need to do basic calculations which unfortunately are not possible in the wizard.

                Comment


                  #9
                  with offsets it might work? Now exits to soon

                  How about offset? I think it works only it exits to soon now. I used defined input and set the offset to 0,2 (maybe 20% offset) but I am not sure if offset works on the side I want or goes the other way. Could you enlighten me on this approach using offset? Otherwise you suggest I play with profits and stops to optimize? (forgeting about a rule to exit % of the way..). Then again maybe I should assign points for offset? But would restrict to particular contract (TF has greater value than ES or a cuurency)



                  Originally posted by NinjaTrader_Bertrand View Post
                  Changing CalculateOnBarClose would only have an effect in realtime - http://www.ninjatrader-support.com/H...BarClose1.html

                  To create a percentage based gapfill you would need to do basic calculations which unfortunately are not possible in the wizard.
                  Attached Files

                  Comment


                    #10
                    alexnj,

                    Your current use of offsets may or may not be what you want. This is what your code is currently saying

                    High[0] >= PriorDayOHLC().PriorLow[0] + OFL * TickSize

                    For instance let us say prior low is 100 and high is 150.

                    150 >= 100 + OFL * TickSize.

                    For the ES, TickSize is 0.25 and your OFL is 0.2

                    150 >= 100 + 0.2 * 0.25
                    or 150 >= 100.05

                    Not sure if that is what you want.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      doent reach target, even with 0 offset

                      I put ticks and value of 10 (for TF), I even tried with no offset and yet for example 5/12/09 short@505,8 covers 503,5 and previous high at 501,6 and previous close 500,7 for somereason I cant get it to exit right or passed the previous high or close (or low when long). Something is not correct




                      Originally posted by NinjaTrader_Josh View Post
                      alexnj,

                      Your current use of offsets may or may not be what you want. This is what your code is currently saying

                      High[0] >= PriorDayOHLC().PriorLow[0] + OFL * TickSize

                      For instance let us say prior low is 100 and high is 150.

                      150 >= 100 + OFL * TickSize.

                      For the ES, TickSize is 0.25 and your OFL is 0.2

                      150 >= 100 + 0.2 * 0.25
                      or 150 >= 100.05

                      Not sure if that is what you want.
                      Attached Files

                      Comment


                        #12
                        Not sure I follow your example. Your code says you will exit long when the current high price crosses above the prior session's low. This would rarely occur if your current session already started > prior close. If you are > prior close already there is no way you can have high cross above prior low unless you dropped below it at some point in time.
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          close enough, members can further develop

                          I think I managed to get somewhere. Perhaps another person would like to play around with it (and we all benefit - I mean newbies). I managed to get profits in TF April1,09 - May15,09 450$, 41,38% profit ratio, at some point had greater win ratio but loss. Instead of cross above/below I used >= and <= and took away extra info that didn't affect strategy (current position long, then exit long etc.). I am optimizing on the TF but will take over 7 hours. Pls have a look for major mistakes. I hope members benefit from a strategy with gap (in wizard I couldn't find another one). I will try and work on the if gap>2% follow and if <2% fade, if I get get % change in price to fit somewhere (any hints where I can find in wizard?)

                          Thanx again!!!

                          P.S. If anyone improves it just notify me......


                          Originally posted by NinjaTrader_Josh View Post
                          Not sure I follow your example. Your code says you will exit long when the current high price crosses above the prior session's low. This would rarely occur if your current session already started > prior close. If you are > prior close already there is no way you can have high cross above prior low unless you dropped below it at some point in time.
                          Attached Files

                          Comment


                            #14
                            Looks alright. Good luck.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              Need Reverse position, if doesn't fill has energy the other way

                              I made one for DAX which does quite well. Then tried to add a feature when it exits on stop loss to reverse position, but for some reason the results are very bad with too many trades. How can I reverse position properly? The general idea being if it doesnt try to fill the gap and goes the other way cut losses fast (I put a tight stop of 0,3%) but it has momentum to go the other way (since it didn't want to fill the gap). So I need to add extra condition reverse for X bars or close0<close3 etc.

                              Thanx. Hope this helps more people.


                              Originally posted by NinjaTrader_Josh View Post
                              Looks alright. Good luck.
                              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