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!
See more
See less

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.
    JesseNinjaTrader Customer Service

    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
        JesseNinjaTrader Customer Service

        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.
            JesseNinjaTrader Customer Service

            Comment


              #7
              got it thanks

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by lightsun47, Today, 03:51 PM
              0 responses
              2 views
              0 likes
              Last Post lightsun47  
              Started by 00nevest, Today, 02:27 PM
              1 response
              8 views
              0 likes
              Last Post 00nevest  
              Started by futtrader, 04-21-2024, 01:50 AM
              4 responses
              41 views
              0 likes
              Last Post futtrader  
              Started by Option Whisperer, Today, 09:55 AM
              1 response
              12 views
              0 likes
              Last Post bltdavid  
              Started by port119, Today, 02:43 PM
              0 responses
              8 views
              0 likes
              Last Post port119
              by port119
               
              Working...
              X