GT
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
High/Low between times
Collapse
X
-
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!
GTTags: None
-
Hi GreenTrade,
Please check out this reference sample: http://www.ninjatrader-support2.com/...ead.php?t=8600Josh P.NinjaTrader Customer Service
-
-
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
-
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
-
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
-
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!
GTLast edited by GreenTrade; 12-28-2008, 07:36 PM.
Comment
-
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).
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="]if[/FONT][/COLOR][COLOR=black][FONT="](Position.MarketPosition==MarketPosition.Long)[/FONT][/COLOR] [COLOR=black][FONT="]{[/FONT][/COLOR] [COLOR=blue][FONT="]if[/FONT][/COLOR][COLOR=black][FONT="](((HighestHigh - LowestLow)>=[/FONT][/COLOR][COLOR=purple][FONT="].0050[/FONT][/COLOR][COLOR=black][FONT="]) && (MAX(High,(Math.Max([/FONT][/COLOR][COLOR=purple][FONT="]0[/FONT][/COLOR][COLOR=black][FONT="],BarsSinceEntry([/FONT][/COLOR][COLOR=maroon][FONT="]"LongEntry"[/FONT][/COLOR][COLOR=black][FONT="]))))[[/FONT][/COLOR][COLOR=purple][FONT="]0[/FONT][/COLOR][COLOR=black][FONT="]]) >= (Position.AvgPrice + .0050)[/FONT][/COLOR] [COLOR=black][FONT="] stopOrder = ExitLongStop([/FONT][/COLOR][COLOR=purple][FONT="]1[/FONT][/COLOR][COLOR=black][FONT="], (MAX(Low,BarsSinceEntry([/FONT][/COLOR][COLOR=maroon][FONT="]"LongEntry"[/FONT][/COLOR][COLOR=black][FONT="]))[[/FONT][/COLOR][COLOR=purple][FONT="]0[/FONT][/COLOR][COLOR=black][FONT="]]) - .0020, [/FONT][/COLOR][COLOR=maroon][FONT="]"LongTrail"[/FONT][/COLOR][COLOR=black][FONT="], [/FONT][/COLOR][COLOR=maroon][FONT="]"LongEntry"[/FONT][/COLOR][COLOR=black][FONT="]);[/FONT][/COLOR] [COLOR=blue][FONT="]else[/FONT][/COLOR] [COLOR=black][FONT="] stopOrder = ExitLongStop([/FONT][/COLOR][COLOR=purple][FONT="]1[/FONT][/COLOR][COLOR=black][FONT="], LongTrail, [/FONT][/COLOR][COLOR=maroon][FONT="]"LongTrail"[/FONT][/COLOR][COLOR=black][FONT="], [/FONT][/COLOR][COLOR=maroon][FONT="]"LongEntry"[/FONT][/COLOR][COLOR=black][FONT="]);[/FONT][/COLOR] [COLOR=black][FONT="]} [/FONT][/COLOR]
Thanks again for the help!Code:[COLOR=blue][FONT="]if[/FONT][/COLOR][COLOR=black][FONT="](Position.MarketPosition==MarketPosition.Long) [/FONT][/COLOR][COLOR=black][FONT="] stopOrder = ExitLongStop([/FONT][/COLOR][COLOR=purple][FONT="]1[/FONT][/COLOR][COLOR=black][FONT="], LongTrail, [/FONT][/COLOR][COLOR=maroon][FONT="]"LongTrail"[/FONT][/COLOR][COLOR=black][FONT="], [/FONT][/COLOR][COLOR=maroon][FONT="]"LongEntry"[/FONT][/COLOR][COLOR=black][FONT="]);[/FONT][/COLOR]
GT
Comment
-
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
-
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
-
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
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
369 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
108 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
572 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
573 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment