Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
OnMarketData question
Collapse
X
-
-
Hi agafon2,Originally posted by agafon2 View PostHello
This is an indicator, which in real time separate volume on every Last tick to bulls or bears (if last price = bid - volume is bearish; if last price = ask - volume is bullish)
Here is a code:
Result:Code:int Previous_time; double Previous_Ask, Previous_Bid; double Bulls_Volume, Bears_Volume; /// <summary> /// This method is used to configure the indicator and is called once before any bar data is loaded. /// </summary> protected override void Initialize() { Overlay = true; CalculateOnBarClose = false; } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnMarketData(MarketDataEventArgs e) { if (e.MarketDataType == MarketDataType.Ask) { Previous_Ask = e.Price; Print("Ask = " + e.Price + " " + e.Time); } if (e.MarketDataType == MarketDataType.Bid) { Previous_Bid = e.Price; Print("Bid = " + e.Price + " " + e.Time); } if (e.MarketDataType == MarketDataType.Last) { if(e.Price == Previous_Ask) { Bulls_Volume += e.Volume; } else { Bears_Volume += e.Volume; } /* if(e.Price == Previous_Bid) { Bears_Volume += e.Volume; }*/ //Print("Last = " + e.Price + " " + e.Time + " Volume: " +e.Volume); } } }
Look at this picture:
SaveImg позволит вам загрузить фото или картинку бесплатно и без регистрации
On some bars a sum of bearish (red color) and bullish (green color) is equals total volume on bar (black color) - and it's exactly correct, but on some bars this sum of bearish and bullish volumes doesn't equal total volume on bar - why it's so?
did you resolve the issue in the meantime? I want to do the same thing, so I am wondering how you accomplished to split the volume correctly.
Cheers,
NutFlush
P.S. If you haven't resolved it, I might have an idea where the problem is...
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by CarlTrading, 03-31-2026, 09:41 PM
|
1 response
157 views
1 like
|
Last Post
|
||
|
Started by CarlTrading, 04-01-2026, 02:41 AM
|
0 responses
90 views
1 like
|
Last Post
by CarlTrading
04-01-2026, 02:41 AM
|
||
|
Started by CaptainJack, 03-31-2026, 11:44 PM
|
0 responses
143 views
2 likes
|
Last Post
by CaptainJack
03-31-2026, 11:44 PM
|
||
|
Started by CarlTrading, 03-30-2026, 11:51 AM
|
0 responses
130 views
1 like
|
Last Post
by CarlTrading
03-30-2026, 11:51 AM
|
||
|
Started by CarlTrading, 03-30-2026, 11:48 AM
|
0 responses
107 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:48 AM
|

Comment