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 algospoke, Yesterday, 06:40 PM
|
2 responses
19 views
0 likes
|
Last Post
by algospoke
Today, 07:04 PM
|
||
Started by ghoul, Today, 06:02 PM
|
3 responses
14 views
0 likes
|
Last Post Today, 06:43 PM | ||
Started by jeronymite, 04-12-2024, 04:26 PM
|
3 responses
45 views
0 likes
|
Last Post
by jeronymite
Yesterday, 10:10 PM
|
||
Started by Barry Milan, Yesterday, 10:35 PM
|
7 responses
21 views
0 likes
|
Last Post Today, 06:16 PM | ||
Started by AttiM, 02-14-2024, 05:20 PM
|
10 responses
181 views
0 likes
|
Last Post
by jeronymite
Today, 06:11 PM
|
Comment