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.
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 ETFVoyageur, 05-07-2024, 07:05 PM
|
17 responses
133 views
0 likes
|
Last Post
by ETFVoyageur
Yesterday, 11:27 PM
|
||
Started by ETFVoyageur, Yesterday, 10:13 PM
|
1 response
7 views
0 likes
|
Last Post
by ETFVoyageur
Yesterday, 10:45 PM
|
||
Started by somethingcomplex, Yesterday, 10:36 PM
|
0 responses
7 views
0 likes
|
Last Post Yesterday, 10:36 PM | ||
Started by sofortune, 05-10-2024, 10:28 AM
|
5 responses
22 views
0 likes
|
Last Post
by sofortune
Yesterday, 10:26 PM
|
||
Started by guyonabuffalo, Yesterday, 10:01 PM
|
0 responses
4 views
0 likes
|
Last Post Yesterday, 10:01 PM |
Comment