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

ORB strategy

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

    ORB strategy

    How would I go about making an orb strategy?
    I assume I would assign a custom double series
    I would set my custom series to only be the first 15 minutes
    I would set it to enter long if price goes above the high of the custom series and
    go short when it breaks below the low of the custom series?
    Does it look like my screenshots will work? thanks

    Click image for larger version

Name:	asadsssssssssssssssssssssssssssssssss.png
Views:	1041
Size:	49.6 KB
ID:	1220936

    Click image for larger version

Name:	asadsssssssssssssssssssssssssssssssss.png
Views:	970
Size:	50.4 KB
ID:	1220937


    #2
    Hello ezrollin,

    Thank you for your post.

    What I see from your screenshots is that you are setting OpenRangeBars[0] to the value of the CurrentBar index number:



    I also see that you have a condition that checks if the current Close price crosses below the current OpenRangeBars value.

    I suspect that this is not how you would like your strategy to behave. Please clarify the following:
    • "I would set my custom series to only be the first 15 minutes"
      • Are you referring to setting the series to the Close price for the first 15 minutes?
    • "I would set it to enter long if price goes above the high of the custom series and
      go short when it breaks below the low of the custom series?"
      • Is the strategy only supposed to go long or short in the first 15 minutes as well? Or do you mean that after recording the price values from the first 15 minutes, if the price goes over the high or below the low from those 15 minutes it should go long or short?
    Once I have a better understanding of what you are looking for, I would be glad to offer suggestions and examples of what you are describing.

    I look forward to your reply.​
    Emily C.NinjaTrader Customer Service

    Comment


      #3
      I'm trying to take only the first 15 minutes of prices into account. Then compare them for the rest of the day.
      Only the first 15 minutes of data matter because that is the opening range.
      I'm trying to store the first 15minutes of prices into my custom series and then check to see if there is a break above or below it

      Comment


        #4
        Hello ezrollin,

        Thank you for clarifying.

        I have created the following video explaining how this could be set up with two doubles (RangeHigh and RangeLow) rather than using a custom series:


        Here is the strategy created in the video in case you would like to import it and take a look at it inside of the Strategy Builder:
        HighLowCrossTest_NT8.zip

        The example uses the following ideas to set up the conditions:
        Time filter - https://ninjatrader.com/support/help...ateTimeFilters
        Time comparison - https://ninjatrader.com/support/help...imeComparisons
        Cross above/Cross below - https://ninjatrader.com/support/help...sOverCondition
        Price data comparison (to check if the price is above RangeHigh or below RangeLow) - https://ninjatrader.com/support/help...ataComparisons

        Please let me know if I may be of further assistance.
        Emily C.NinjaTrader Customer Service

        Comment


          #5
          I tried to send you a PM to tell you thanks for going out of your way to help me understand by making a video.
          It seemed pretty easy to do.

          However I can tell I'm not getting the correct RangeHigh and RangeLow based on the first 15 minutes because I added code into the builder
          to plot the High and Low of the first 15 and you can see its not correct.
          I dont know why its not right.
          Click image for larger version  Name:	dsfadfadsfdasfadsfdsafadsfdsafdasfas.png Views:	0 Size:	189.5 KB ID:	1223267
          ​The opacity blue is the 15minute rectangle plotted of RangeHigh and RangeLow and my red lines are the correct high and low.


          Also: not sure why it wont let me plot 2 Horizontal lines, so I had to do the rectangle
          I can send you my code if you want?
          thanks

          Comment


            #6
            Hello ezrollin,

            Thank you for your reply.

            While we do not provide hands-on debugging services, I would be glad to assist with providing resources and examples or helping to understand any error messages that come up. I recommend adding Print statements to the Strategy Builder that will print the value of RangeHigh and RangeLow so you may understand better what values are being used and they make modifications so that the proper values are saved.

            More information about using your prints to debug a script may be found here, including a video showing how to add prints to the Strategy Buidler:
            Additionally, you mentioned you were not able to plot horizontal lines - did you receive an error message when attempting to do so? If so, what does the error state? What did the set of conditions and actions to plot the horizontal lines look like?

            Thank you for your patience. I look forward to your reply.
            Emily C.NinjaTrader Customer Service

            Comment


              #7
              Hello Emily and Ezrollin. I'm hoping you guys can help me. I am new to strategy builder so I am still learning the ropes. I am looking to create a ORB strategy and thought I'd start here. I will share my screen shots of what I have. Unfortunately I am not able to get the strategy to initiate any trades at all. I watched your video and followed it, then used my own inputs and stops and targets. (Step 1 and Step 2 are the same as in your video therefore I did not include screen shots of them). I'm not sure if I will use a 15 min ORB strategy (instead a 1/2/5 min), however, I am trying to gain an understanding of simply using the strategy builder and creating an ORB strategy, and figured creating a working 15 min ORB strategy would be a good place to start.

              Thanks!!

              Edit to add: I do turn on the "UseLong" and "UseShort" bools when I add the strategy to the chart. I also make sure to "enable" the strategy in the same menu.
              Attached Files
              Last edited by jfarman; 01-05-2023, 11:42 AM.

              Comment


                #8
                Hello jfarman,

                Thank you for your note.

                Whenever a strategy is not behaving as expected, such as not taking any trades when you are expecting it to, I recommend adding prints to understand the values being used in your conditions to submit trades. For example, you have CrossAbove and CrossBelow conditions comparing the Close with RangeHigh and RangeLow. Based on your inputs and variables screenshot, RangeHigh and RangeLow both start at a default value of 0. If the value is not being properly changed, then it won't be expected that the price can cross above/below 0. Whenever you are updating the values for RangeHigh and RangeLow, you should print them to make sure they are saved as expected. You could also add a new Set of conditions/actions and just set the action to print RangeHigh and RangeLow. For more information about using prints to debug a script:

                Video about adding prints via Strategy Builder - https://drive.google.com/file/d/1CCl...gEIwJKv6L/view

                Otherwise, please ensure that your strategy is enabled and the name is in Green on the Strategies tab of the Control Center when you are expecting it to be active and taking trades. If the strategy position is somehow out of sync with the account position, this could also result in the strategy not actively placing trades. For more information:



                Please let us know if we may be of further assistance.
                Emily C.NinjaTrader Customer Service

                Comment


                  #9
                  Hi jfarman,

                  I would suggest you to avoid using the CrossAbove / CrossBelow checks.
                  Use instead:
                  close()>RangeHigh to enter Long
                  close()<RangeLow to enter Short
                  I suppose you have the Sets 1 and 2 correcty set in your Strategy.
                  (you should show Set 1 & Set 2 also, just to be sure that your variables take the right values).

                  Comment


                    #10
                    Hi Emily,

                    Thanks for trying to help. Unfortunately the output is only giving me one number and then 0, and it is not even close to where it should be. The time stamps for the number do not match up to the chart. I followed your video and it does not seem to be working. Is there something I am missing? I tried it with the 15 minute range in your example, as well as the 1 minute strategy I'm trying to create.

                    Hi KonstantinosNT,

                    I'm using cross above/cross below because I want the trade to initiate as soon as the last price exceeds the high or low of the defined range.


                    Maybe if I explain the strategy entirely, that might help to understand what I am trying to achieve: The strategy is for ES futures.

                    The basis of the strategy is to observe the opening (first) 1 minute bar, and then create a range of that bars high and low. If the next (2nd) one minute bar price goes above or below that previous (first) bars high or low, I want to initiate a trade in the respective direction. I want the trade to initiate immediately upon the 2nd bar exceeding that range. I do not want to wait for the 2nd bar to close.

                    Once a trade has been initiated, regardless of direction, I do not want anymore trades taken at all. Even if a target or stop loss has been reached and another trade would otherwise have triggered again. I also do not want any trades taken after the 2nd one minute bar has closed. So only one trade, and the trade must initiate during the 2nd bar only. (The trade, if still open, could continue beyond the 2nd bar)

                    For targets and stops I would like it to take 2 contracts. For explanation purposes, lets assume we are going long in a trade.
                    - Contract 1 would have an 8 tick target from entry and 8 tick stop loss from entry. If price reaches/touches 4 ticks above/profit from entry, then stop loss would move to 1 tick above entry. Then profit would be taken at the 8 tick target mark.
                    - Contract 2 would have only an 8 tick stop loss from entry. If price reaches/touches 4 ticks above/profit from entry, then stop loss would move to 1 tick above entry. If price reaches/touches 8 ticks above entry, then a trailing stop would initiate with a 6 tick trailing stop. Then the trade would close whenever the trailing stop was triggered or closed manually.


                    I would like to be able to replicate this strategy on the 1, 2, 5, and 15 minute timeframes. Which is why I was trying to build out the 15 minute chart range from the earlier posts. The number of contracts, as well as targets and stops could be adjusted based on personal risk profile. I would also like to test this strategy with using hard targets only vs 1 hard target and 1 trailing stop (contract 1 only vs contract 1&2 combined). I hope this helps to understand my goals. I hope you guys are able to help me. Thanks again for all your suggestions. I look forward to your direction.

                    Comment


                      #11
                      Hello jfarman,

                      Thank you for the description.

                      What are the prints that you added to the strategy and what was the output? If possible, please provide a screenshot and/or right-click the NinjaScript Output window then select Save As to save the output into a file that you can attach to your response. You mentioned the output is giving you one number and then 0; what value were you expecting for the prints?

                      I look forward to your reply.
                      Emily C.NinjaTrader Customer Service

                      Comment


                        #12
                        Hi jfarman,

                        If you have the calculate mode set to "on each tick" then the close() is always the current price, which is what you want.
                        I mean, it doesn't wait for the 2nd bar to complete to compute it, it's always the real time current price.
                        Thus the checks : close()>RangeHigh / close()<RangeLow , are valid and executed on every tick, in real time.

                        Your strategy plan is understandable and very simple to build and set it to work. (I am not sure it's profitable, though !)
                        I repeat, it's better to also share the screenshots of the Set 1 and Set 2 of your strategy.
                        Last edited by KonstantinosNT; 01-10-2023, 02:23 AM.

                        Comment


                          #13
                          Originally posted by ezrollin View Post
                          However, I can tell I'm not getting the correct ... 15 minutes because I added code into the builder.. the first 15 and you can see its not correct.
                          I don't know why it's not right.

                          The opacity blue is the 15-minute rectangle...
                          my guess: you added the strategy to the 5-minute char, but your strategy is for the 15-minute time frame.
                          if you want to view a 5-minute chart instead of a 15-minute one,
                          as a trick you can create a window with two charts of 15 and 5 minutes.
                          in which the bars of the 15-minute chart will be transparent (invisible).
                          when you are in the strategy selection (adding) window, then select the 15-minute timeframe.
                          Click image for larger version  Name:	5min.png Views:	0 Size:	47.4 KB ID:	1230570

                          Comment


                            #14
                            Emily,

                            For the prints, I added time series, range high, and range low. I attached the screenshot of the output window where I am getting 3988 for range high and 0 for range low. I should be getting 4141 and 4135. (This is for 12/13/2022) I did start scrolling backwards to see where the 3988 might land on the chart and it is on the previous day 0930 am chart. Its not the correct value for that time but it is very close. Why would it be doing that? And I also cannot figure out why the Range low value is 0.


                            Hi KonstantinosNT,

                            I just changed to on each tick and close()>RangeHigh / close()<RangeLow​ to see if that helps. It seems the actual range being generated is the issue at the moment. I included set 1 and set 2 of the strategy builder for you to look at. I opened up the groups to see as well. The time range I used for the "opening range time" are >=9:30am and <=9:31am. I am glad I was able to convey my thoughts for the strategy, but I wish I could say it was easy to build and set to work because I am on the struggle bus over here lol I don't have any programming background and I've always used TOS for trading so I'm not even fluent on Ninjatrader quite yet. I have done this strategy manually for quite some time and have found it to work well but you have to be quick on the trigger with entries and then placing stop loss and target in the DOM. This lack of precision has led to slippage on all sides and ultimately..losing money. On look backs, if I was accurate on these variables it would be more profitable than not...which is why I'm looking to an algorithm. I don't typically incorporate a trailing stop when I do this manually, but sometimes I see the trade go and go and wish I had a trailing stop. I look at this trade kind of like a gap 'n go...once it breaks that high or low it typically jumps several points, especially on the 1 and 2 minute time frames. I think this is due to the algos trading, settling positions, etc at the open. One of the keys however is moving the stop loss up to break even plus commissions (usually 1 tick) as quickly as possible without being too close and accidentally stopping yourself out. The 5 minute and 15 minute are more directional and could be viewed as part of a larger trade, but do sometimes give a quick scalp type trade.


                            I uploaded all the windows of my strategy builder with this 1 minute strategy. The only thing I changed after taking the screen shots was changing condition set 3 & 4 to a time value >=9:32am. I found that the chart is labeling the 09:32am bar when the actual time is 9:31am - 9:32am (bar open to bar close). I have also yet to add a condition to stop it from taking more than one trade and stop after that 9:32am bar. Hope all this helps! Thanks again guys!​
                            Attached Files
                            Last edited by jfarman; 01-10-2023, 10:22 AM.

                            Comment


                              #15
                              I could only upload 5 images at a time so here are the rest.
                              Attached Files

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by DJ888, Today, 10:57 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by MacDad, 02-25-2024, 11:48 PM
                              7 responses
                              158 views
                              0 likes
                              Last Post loganjarosz123  
                              Started by Belfortbucks, Today, 09:29 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post Belfortbucks  
                              Started by zstheorist, Today, 07:52 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post zstheorist  
                              Started by pmachiraju, 11-01-2023, 04:46 AM
                              8 responses
                              151 views
                              0 likes
                              Last Post rehmans
                              by rehmans
                               
                              Working...
                              X