Draws a dot on bar [1]?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
DrawDot on current bar
Collapse
X
-
Josh,
your code is in OnBarUpdate. Place the code in OnMarketData. the dot will draw on CurrnetBar - 1 and not on the currentbar.
Code:protected override void [B]OnMarketData[/B](MarketDataEventArgs e) { if (e.MarketDataType == MarketDataType.Last && e.Volume >=10) { DrawDot("dot" + dotcount,false,0,e.Price,Color.YellowGreen); dotcount +=1; } }
Comment
-
Code segment
Code:protected override void OnMarketData(MarketDataEventArgs e) { if (e.MarketData.Ask != null) { TheAsk = e.MarketData.Ask.Price; } if (e.MarketData.Bid != null) { TheBid = e.MarketData.Bid.Price; } if(TheBid == double.MinValue || TheAsk == double.MinValue) return; if (e.MarketDataType != MarketDataType.Last) return; if (e.Volume >= Vol_Lim) { mystr = e.Time.ToString("t") + " " + String.Format(" [{0}] ",e.Volume.ToString("N0") ) + String.Format("@ {0} ", e.Price.ToString()); Print(Environment.NewLine); Print( e.Time.ToString("T") + " " + String.Format(" @ {0} ", e.Price.ToString()) + String.Format(" for {0} Lots ,e.Volume.ToString("N0"))); if(e.Volume > Vol_Lim * 3) { if(e.Price <=TheBid) DrawDot("tag"+CurrentBar,true,Time[0],TheBid,Color.Cyan); else DrawDot("tag"+CurrentBar,true,Time[0],TheAsk,Color.Cyan); } }
Comment
-
Guys,
OnMarketData() and OnMarketDepth() are not tied to any bars series. This means their events are not linked to [] indexes. Further meaning, that going [0] may very well be the previous bar as no OnBarUpdate() was triggered for the newly building bar yet while you are receiving OnMarketData/Depth() updates.Josh P.NinjaTrader Customer Service
Comment
-
onmarket data
Josh
I get that - but I don't seem to have the issue anymore - my indicator has worked fine real time all day.
An onmarketdata event doesn't assume an on bar update but in reality I don't find it an issue.
Must have just been an odd install or something.
Comment
-
Thanks Josh for the clarification.
if i do this:
DrawDot("dot" + dotcount,false,0,High[0],Color.YellowGreen);
the dot is drawn on Bar[0]
but if i do this:
DrawDot("dot" + dotcount,false,0,e.Price,Color.YellowGreen);
then the dot is drawn on Bar[1]. now this can be done in OnMakretData etc as Josh rightly clarified as the price is not linked to []
thanks again Josh.
Comment
-
EDIT: FIXED IT by using barsAgo (0) instead of Time[0].
I'm observing this too and i'm not using onMarketData.
Sometimes it's drawing on the current bar and sometimes 1 bar ago. I have been trying to figure it out for a while now when I got the idea to search this thread.Code:y = Low[0] - 3*TickSize; DrawDot("Dot"+CurrentBar, true, Time[0], y, color);
I don't know what the time parameter is for (it wasn't there in 6.5) and I don't know what to put.
This is the same code that never had this problem with 6.5.Last edited by cunparis; 07-30-2010, 03:43 PM.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
608 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
355 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
105 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
560 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
561 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|


Comment