Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

printing dot above candle

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

    printing dot above candle

    Hi, i would like to print dot above the candle of the chart using the buysellvolume indicator. it almost work but the dot disapear at the end of every bar. any idea how to fix this?
    Thanks


    Code:
    public class aaVolumetestChris : Indicator
    {
    
    private int activeBar = 0;
    
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = NinjaTrader.Custom.Resource.NinjaScriptIndicatorDe scriptionBuySellVolume;
    Name = "aaVolumetestChris";
    BarsRequiredToPlot = 1;
    Calculate = Calculate.OnEachTick;
    DrawOnPricePanel = true;
    IsOverlay = true;
    DisplayInDataBox = true;
    
    
    }
    else if (State == State.Historical)
    {
    if (Calculate != Calculate.OnEachTick)
    {
    Draw.TextFixed(this, "NinjaScriptInfo", string.Format(NinjaTrader.Custom.Resource.NinjaScr iptOnBarCloseError, Name), TextPosition.BottomRight);
    Log(string.Format(NinjaTrader.Custom.Resource.Ninj aScriptOnBarCloseError, Name), LogLevel.Error);
    }
    }
    }
    
    protected override void OnMarketData(MarketDataEventArgs e)
    {
    if(e.MarketDataType == MarketDataType.Last)
    {
    if(e.Price >= e.Ask)
    buys += (Instrument.MasterInstrument.InstrumentType == Cbi.InstrumentType.CryptoCurrency ? Core.Globals.ToCryptocurrencyVolume(e.Volume) : e.Volume);
    else if (e.Price <= e.Bid)
    sells += (Instrument.MasterInstrument.InstrumentType == Cbi.InstrumentType.CryptoCurrency ? Core.Globals.ToCryptocurrencyVolume(e.Volume) : e.Volume);
    }
    }
    
    protected override void OnBarUpdate()
    {
    if (CurrentBar < activeBar || CurrentBar <= BarsRequiredToPlot)
    return;
    
    if (CurrentBar != activeBar)
    {
    
    activeBar = CurrentBar;
    }
    if (buys > sells)
    {
    Draw.Dot(this, "buyers", true, 0, High[0] + TickSize, Brushes.Lime);
    RemoveDrawObject("sellers");
    //Buys[0] = buys; //+sells;
    
    }
    if (buys < sells)
    {
    Draw.Dot(this, "sellers", true, 0, Low[0] - TickSize, Brushes.Red);
    RemoveDrawObject("buyers");
    //Sells[0] = sells;
    
    }
    
    
    }​
    Last edited by cbadr; 09-26-2023, 10:45 AM.

    #2
    Hello cbadr,

    I don't see any kind of question attached to your post so I am unsure what you need help with here, please update your post with your question.

    Comment


      #3
      I updated my post above due to a bug. i think it's clear now

      Comment


        #4
        Hello cbadr,

        To make unique drawing objects you need to use unique tag names. You can add the CurrentBar to the tag like the following

        "buyers" + CurrentBar
        "sellers" + CurrentBar

        Comment


          #5
          Sorry i don't understand, can you please develop?

          Comment


            #6
            Hello cbadr,

            You would need to change the tags that you are using for the Draw.Dot syntax, you can edit the tag from being "buyers" to "buyers" + CurrentBar to make it unique for every bar.

            Comment


              #7
              got it thanks

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              576 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              334 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              101 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              553 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              551 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X