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
OnMarketData question
Collapse
X
-
-
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:
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 ETFVoyageur, Today, 02:08 AM
|
0 responses
7 views
0 likes
|
Last Post
by ETFVoyageur
Today, 02:08 AM
|
||
Started by kujista, 04-22-2024, 07:46 AM
|
3 responses
12 views
0 likes
|
Last Post
by kujista
Today, 02:06 AM
|
||
Started by kujista, 04-23-2024, 06:23 AM
|
7 responses
57 views
0 likes
|
Last Post
by kujista
Today, 02:03 AM
|
||
Started by SentientDavid, Today, 01:34 AM
|
0 responses
8 views
0 likes
|
Last Post Today, 01:34 AM | ||
Started by MrForgetful, Today, 01:28 AM
|
0 responses
6 views
0 likes
|
Last Post
by MrForgetful
Today, 01:28 AM
|
Comment