Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

High/Low between times

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

    High/Low between times

    How do I find the high and low between two times? Example: High between 7:00 am and 10:00 am and low between that same period. Thanks!

    GT

    #2
    Hi GreenTrade,

    Please check out this reference sample: http://www.ninjatrader-support2.com/...ead.php?t=8600
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Perfect! Thanks for the quick response!

      GT

      Comment


        #4
        How about plotting a line at the high or low from the start time to the end time? Also, how would I plot fibonacci lines only if I were in a position? Thanks!

        GT

        Comment


          #5
          You cannot plot from a strategy. You will need to create an indicator for plotting. Please see the tutorial on custom indicator creation in the Help Guide for making plots.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            Sorry, I guess I meant to say draw a line or objects. I have already drawn some objects but do not know how to "start them then turn them off" at certain times.

            Comment


              #7
              You use a DrawLine() or whichever method you want to get the line at the specific time you want. Then you can remove the object with RemoveDrawObject(). Please see the Help Guide for more information on the methods.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                Using your sample I have gotten the high and low for the timeframe desired. How would I do this for at different times in the same day? Say I want to get the high and low for 9:30am -10:30am and then the high and low from 11:30am - 12:30pm. I am working on it right now but when I print the second highestHigh it still returns the first highestHigh's value. I have tried renaming some of the variables, i.e. highestHigh2 . . . without anything working. Thanks again for your help!

                GT

                Comment


                  #9
                  Just create two complete sets independent of each other. Completely new set of variables and then proceed in the exact same fashion as before.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    A little off of the subject but I am trying to use the lowest low in the given period as the initial stoploss. Looking at the log it shows that it is executing correctly in the onExecution portion of the code and then when then next bar closes the onBarUpdate portion of code changes the stop to where the prior trades stop was placed. I have looked in the forums at information on resetting the stop have tried to do so by using the code:

                    if (Position.MarketPosition == MarketPosition.Flat)
                    LongStopLevel = LowestLow;

                    and then calling this variable in the onBarUpdate stopOrder = ExitLongStop code

                    Any other thoughts/ideas on how to fix this? Thanks!

                    GT
                    Last edited by GreenTrade; 12-28-2008, 07:36 PM.

                    Comment


                      #11
                      Hi GreenTrade, please post some code from the section where you modify the stop price level so we can take a look - thanks!

                      Comment


                        #12
                        This is written in the onBarUpdate section of code. Again this morning the onExecution stop worked correctly but the code below changed the stopOrder price to the last price the stop was the prior trading day. I am using this code to move the stop price to .0020 below the highest low since entry after a certain profit has been reached (.0050 in the code).

                        Code:
                        [COLOR=blue][FONT=&quot]if[/FONT][/COLOR][COLOR=black][FONT=&quot](Position.MarketPosition==MarketPosition.Long)[/FONT][/COLOR]
                          [COLOR=black][FONT=&quot]{[/FONT][/COLOR]
                          [COLOR=blue][FONT=&quot]if[/FONT][/COLOR][COLOR=black][FONT=&quot](((HighestHigh - LowestLow)>=[/FONT][/COLOR][COLOR=purple][FONT=&quot].0050[/FONT][/COLOR][COLOR=black][FONT=&quot]) && (MAX(High,(Math.Max([/FONT][/COLOR][COLOR=purple][FONT=&quot]0[/FONT][/COLOR][COLOR=black][FONT=&quot],BarsSinceEntry([/FONT][/COLOR][COLOR=maroon][FONT=&quot]"LongEntry"[/FONT][/COLOR][COLOR=black][FONT=&quot]))))[[/FONT][/COLOR][COLOR=purple][FONT=&quot]0[/FONT][/COLOR][COLOR=black][FONT=&quot]]) >= (Position.AvgPrice + .0050)[/FONT][/COLOR]
                          [COLOR=black][FONT=&quot]      stopOrder = ExitLongStop([/FONT][/COLOR][COLOR=purple][FONT=&quot]1[/FONT][/COLOR][COLOR=black][FONT=&quot], (MAX(Low,BarsSinceEntry([/FONT][/COLOR][COLOR=maroon][FONT=&quot]"LongEntry"[/FONT][/COLOR][COLOR=black][FONT=&quot]))[[/FONT][/COLOR][COLOR=purple][FONT=&quot]0[/FONT][/COLOR][COLOR=black][FONT=&quot]]) - .0020, [/FONT][/COLOR][COLOR=maroon][FONT=&quot]"LongTrail"[/FONT][/COLOR][COLOR=black][FONT=&quot], [/FONT][/COLOR][COLOR=maroon][FONT=&quot]"LongEntry"[/FONT][/COLOR][COLOR=black][FONT=&quot]);[/FONT][/COLOR]
                          [COLOR=blue][FONT=&quot]else[/FONT][/COLOR]
                          [COLOR=black][FONT=&quot]      stopOrder = ExitLongStop([/FONT][/COLOR][COLOR=purple][FONT=&quot]1[/FONT][/COLOR][COLOR=black][FONT=&quot], LongTrail, [/FONT][/COLOR][COLOR=maroon][FONT=&quot]"LongTrail"[/FONT][/COLOR][COLOR=black][FONT=&quot], [/FONT][/COLOR][COLOR=maroon][FONT=&quot]"LongEntry"[/FONT][/COLOR][COLOR=black][FONT=&quot]);[/FONT][/COLOR]
                          [COLOR=black][FONT=&quot]}           [/FONT][/COLOR]
                        Also, I have used just the portion below and it work fine so there must be an error in the first section.
                        Code:
                        [COLOR=blue][FONT=&quot]if[/FONT][/COLOR][COLOR=black][FONT=&quot](Position.MarketPosition==MarketPosition.Long)
                        [/FONT][/COLOR][COLOR=black][FONT=&quot]   stopOrder = ExitLongStop([/FONT][/COLOR][COLOR=purple][FONT=&quot]1[/FONT][/COLOR][COLOR=black][FONT=&quot], LongTrail, [/FONT][/COLOR][COLOR=maroon][FONT=&quot]"LongTrail"[/FONT][/COLOR][COLOR=black][FONT=&quot], [/FONT][/COLOR][COLOR=maroon][FONT=&quot]"LongEntry"[/FONT][/COLOR][COLOR=black][FONT=&quot]);[/FONT][/COLOR]
                        Thanks again for the help!

                        GT

                        Comment


                          #13
                          Thanks GreenTrade, likely your order is expiring at the end of the bar, so I would suggest setting liveUntilCancelled to true -> http://www.ninjatrader-support.com/H...tLongStop.html

                          Please also review this link - http://www.ninjatrader-support.com/H...verview36.html

                          Comment


                            #14
                            So basically in setting liveuntilcancel I want the order to remain live unless a new order is place (when the market moves and there is a higher low) or when the position is closed by the current order. In keeping the order liveuntilcancel do I have to cancel the order in these two situations or will that be done automatically b/c of a new order and b/c the order in filled?

                            Comment


                              #15
                              Also, it may not be an expiration issue b/c this happens at the first time the onBarUpdate is called after entering a position. It looks like something in my code is reverting back to the last "LongTrail" price from the previous long position.

                              Comment

                              Latest Posts

                              Collapse

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