Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DrawDot on current bar

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    DrawDot on current bar

    DrawDot("tag"+CurrentBar,true,Time[0],TheBid,Color.Cyan);

    Draws a dot on bar [1]?

    #2
    Mindset,

    What is your CalculateOnBarClose setting?
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Calculate on bar close

      Set to False.
      Y co ord is correct but X seems to be 1 bar off.

      Comment


        #4
        Seems to work fine here when I set it to the high of each bar.
        Attached Files
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Update

          ok I was using OnMarketData. If I set the condition and use {} it plots Bar[1] if I don't use {} it plots CurrentBar ie as expected.

          Comment


            #6
            Unfortunately I am not sure I follow you. It would probably be best if you could just post a sample as I have done. Thank you.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              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


                #8
                Drawdot

                No, today it works fine inside the curly braces under onmarketdata
                I mean it definitely was plotting bar[1] and not bar[0] even after I restarted NT7B9.

                Comment


                  #9
                  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


                    #10
                    seems it is off by one bar. the currentbar is having an index of -1.

                    Comment


                      #11
                      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


                        #12
                        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


                          #13
                          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


                            #14
                            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);
                            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.

                            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 ETFVoyageur  
                            Started by ETFVoyageur, Yesterday, 10:13 PM
                            1 response
                            7 views
                            0 likes
                            Last Post ETFVoyageur  
                            Started by somethingcomplex, Yesterday, 10:36 PM
                            0 responses
                            7 views
                            0 likes
                            Last Post somethingcomplex  
                            Started by sofortune, 05-10-2024, 10:28 AM
                            5 responses
                            22 views
                            0 likes
                            Last Post sofortune  
                            Started by guyonabuffalo, Yesterday, 10:01 PM
                            0 responses
                            4 views
                            0 likes
                            Last Post guyonabuffalo  
                            Working...
                            X