Thanks.
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
OnBarUpdate & OnMarketDepth
Collapse
X
-
Originally posted by dsraider View PostMy code has OnBarUpdate followed by OnMarketDepth. I print from OnBarUpdate. Is there a way to grab a parameter from OnMarketDepth, like e.Price, and print from OnBarUpdate?
Thanks.
You can Print from OnMarketDepth.
RJay
-
rt6176,
Thanks but my If ---> Print statement is in OnBarUpdate. I have no problem moving Print down to Depth but I'm not sure if that's possible, as I don't know how to make one communicate with the other. Maybe a bool in OnBar following by an If (bool = true) Print in Depth?
Comment
-
Originally posted by dsraider View Postrt6176,
Thanks but my If ---> Print statement is in OnBarUpdate. I have no problem moving Print down to Depth but I'm not sure if that's possible, as I don't know how to make one communicate with the other. Maybe a bool in OnBar following by an If (bool = true) Print in Depth?
If you define the variable you want to print in the Initialize area, you can call it from any method.
You can assign a value to the variable in OnMarketDepth and you can print it from OnBarUpdate.
RJay
Comment
-
Hey RJay,
That sounds perfect but I can't seem to compile:
PHP Code:protected override void Initialize()
{
double lastPrice = 0;
}
protected override void OnBarUpdate()
{
Print(lastPrice);
}
protected override void OnMarketDepth(MarketDepthEventArgs e)
{
double lastPrice = e.Price;
}
Comment
-
Originally posted by dsraider View PostHey RJay,
That sounds perfect but I can't seem to compile:
PHP Code:protected override void Initialize()
{
double lastPrice = 0;
}
protected override void OnBarUpdate()
{
Print(lastPrice);
}
protected override void OnMarketDepth(MarketDepthEventArgs e)
{
double lastPrice = e.Price;
}
Instead define the lastPrice in the "Variables" section, so that it is a class variable. Then access the variable from any event, by direct query.
Comment
-
Hey koganam,
I hear you loud and clear and that is what I normally do. The problem here, though, is that I'm trying to print OnMarketDepth data from OnBarUpdate because I need the OnBarUpdate logic to decide whether or not to print.
Defining lastPrice in Variables and then printing in OnBarUpdate just throws me a "0."
Maybe there's another way to print MarketDepth data from OnBar?
Comment
-
Originally posted by dsraider View PostHey koganam,
I hear you loud and clear and that is what I normally do. The problem here, though, is that I'm trying to print OnMarketDepth data from OnBarUpdate because I need the OnBarUpdate logic to decide whether or not to print.
Defining lastPrice in Variables and then printing in OnBarUpdate just throws me a "0."
Maybe there's another way to print MarketDepth data from OnBar?- You declare/define lastPrice as a class variable.
- You assign lastPrice in OnMarketDepth().
- You print/output lastPrice in OnBarUpdate().
You must assign a variable a value before you can see what value you assigned it.
Comment
-
I believe I understand you correctly but I'm still getting 0s with this:
PHP Code:#region Variables
double lastPrice = 0;
#endregion
protected override void OnBarUpdate()
{
Print(lastPrice);
}
protected override void OnMarketData(MarketDepthEventArgs e)
{
double lastPrice = e.Price;
}
Comment
-
Originally posted by dsraider View PostI believe I understand you correctly but I'm still getting 0s with this:
PHP Code:#region Variables
double lastPrice = 0;
#endregion
protected override void OnBarUpdate()
{
Print(lastPrice);
}
protected override void OnMarketData(MarketDepthEventArgs e)
{
double lastPrice = e.Price;
}
You need live market data or replay data running for this to work.Last edited by RJay; 01-29-2012, 03:38 PM.
Comment
-
Originally posted by dsraider View PostI believe I understand you correctly but I'm still getting 0s with this:
PHP Code:#region Variables
double lastPrice = 0;
#endregion
protected override void OnBarUpdate()
{
Print(lastPrice);
}
protected override void OnMarketData(MarketDepthEventArgs e)
{
double lastPrice = e.Price;
}
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by strategist007, Today, 07:51 PM
|
0 responses
2 views
0 likes
|
Last Post Today, 07:51 PM | ||
Started by StockTrader88, 03-06-2021, 08:58 AM
|
44 responses
3,967 views
3 likes
|
Last Post
by jhudas88
Today, 06:59 PM
|
||
Started by rbeckmann05, Today, 06:48 PM
|
0 responses
4 views
0 likes
|
Last Post
by rbeckmann05
Today, 06:48 PM
|
||
Started by rhyminkevin, Today, 04:58 PM
|
4 responses
58 views
0 likes
|
Last Post
by dp8282
Today, 06:13 PM
|
||
Started by iceman2018, Today, 05:07 PM
|
0 responses
6 views
0 likes
|
Last Post
by iceman2018
Today, 05:07 PM
|
Comment