I just downloaded the 6.5 Beta. Is there a way to use either the "OnMarketData" or "OnPositionUpdate" to signal changes in highs/lows...I'd like to be able to reset/change a StopLoss based on new prices for these parameters, thus enabling a more "sensitive" dynamic instead of waiting for "bar closes". Thanks in advance.
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!
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
NinjaTrader
New high/low signals?
Collapse
X
-
New high/low signals?
Hi,
I just downloaded the 6.5 Beta. Is there a way to use either the "OnMarketData" or "OnPositionUpdate" to signal changes in highs/lows...I'd like to be able to reset/change a StopLoss based on new prices for these parameters, thus enabling a more "sensitive" dynamic instead of waiting for "bar closes". Thanks in advance.Tags: None
-
Hi again,
Would the following code logic be acceptable?:
protected override void OnMarketData(MarketDataEventArgs e)
{
if(e.MarketDataType == MarketDataType.Last)
{
if(MarketDataType.Last <= Low[0]){LOW_VAL = MarketDataType.Last;} //new low reached
if(MarketDataType.Last >= High[0]){HI_VAL = MarketDataType.Last;} //new high reached
}
}
Comment
-
No since you can not guarantee that the low/high of the current bar is seen before or after the OnMarketData throws the event. If you want to monitor new highs/lows in the strategy, set CalculateOnBarClose to false and then you get each and every tick and then monitor the close price to see if its the current bar high or low etc...RayNinjaTrader Customer Service
Comment
-
But I thought that "OnMarketData" does update on each tick...wouldn't it have to in order to catch each price change?
I was under the impression that the "OnMarketData" method was a way to get tick-by-tick data within a strategy using "calculate on bar close" within the "OnBarUpdate" method...Last edited by Burga1; 12-17-2007, 08:32 PM.
Comment
-
Yes to all of your questions however, what you want to do is best accomplished in the manner in which I stated. Don't make it more complex than it needs to be. If you intermix checking data between OnMarketData and OnBarUpdate you may run into race conditions since their is not guarantee in in which order the events are triggered although most of the time OnBarUpdate for last changed price will fire before OnMarketData.RayNinjaTrader Customer Service
Comment
-
I have a condition within the "OnBarUpdate" that is dependent on "calculate on bar close"...because of this I didn't want to have to disable the bar close requirement.
I can accomplish what I desire by using the "Close" instead of "high/low" however this is an incomplete solution that results in unacceptable strategy performance...
I would have thought it possible to use the "calculate on bar close" requirement while at the same time simply checking for high's and low's on a tick-by-tick basis...
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by SantoshXX, Today, 03:09 AM
|
0 responses
6 views
0 likes
|
Last Post
by SantoshXX
Today, 03:09 AM
|
||
Started by DanielTynera, Today, 01:14 AM
|
0 responses
2 views
0 likes
|
Last Post
by DanielTynera
Today, 01:14 AM
|
||
Started by yertle, 04-18-2024, 08:38 AM
|
9 responses
41 views
0 likes
|
Last Post
by yertle
Today, 01:00 AM
|
||
Started by techgetgame, Yesterday, 11:42 PM
|
0 responses
12 views
0 likes
|
Last Post
by techgetgame
Yesterday, 11:42 PM
|
||
Started by sephichapdson, Yesterday, 11:36 PM
|
0 responses
2 views
0 likes
|
Last Post Yesterday, 11:36 PM |
Comment