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 Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
579 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
334 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 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
554 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
551 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment