Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Drawing objects inside Indicator

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

    Drawing objects inside Indicator

    Hi. I'm developing and indicator, to give me signals of entry into the market. The problem that i have is taht the objects are drawing every tick. So some times the draw a lot of objects insede the bar.

    The code is:

    protected override void OnBarUpdate() // executed every tick...It's necessary that condition everytick....If the condition it's true I would like to draw just one time... //
    {



    if (condition))
    {

    contador++;
    //Print("WA"+Time[0].ToShortTimeString());
    Draw.ArrowUp(this, contador.ToString(), false, 0, Low[0]-2,Brushes.GreenYellow);
    contador++;
    Draw.Text(this, contador.ToString(), "WA", 0, Low[0]-10, Brushes.GreenYellow);
    }

    //
    else if (condition)
    {
    contador++;
    //Print("WB"+ Time[0].ToShortTimeString());
    Draw.ArrowUp(this, contador.ToString(), false, 0, Low[0]+2, Brushes.Red);
    contador++;
    Draw.Text(this, contador.ToString(), "WA", 0, Low[0]+10, Brushes.Red);
    }


    else if(condition))
    {
    contador++;
    //Print("SA"+ Time[0].ToShortTimeString());
    Draw.Text(this, contador.ToString(), "SA", 0, Low[0]-2,Brushes.YellowGreen);
    }


    else if(condition))
    {
    contador++;
    //Print("SB"+ Time[0].ToShortTimeString());
    Draw.Text(this, contador.ToString(), "SB", 0, Low[0]+2, Brushes.Red);
    }


    else if(condition))
    {
    contador++;
    //Print("OK_Under"+ Time[0].ToShortTimeString());
    Draw.Text(this, (contador).ToString(), "OK", 0, Low[0]+6);
    }


    else if(condition))
    {
    contador++;
    //Print("OK_over"+ Time[0].ToShortTimeString());
    Draw.Text(this, (contador).ToString(), "OK", 0, Low[0]-6);
    }

    }

    #2
    I have fixed the problem.. Just adding this lien of code:

    if(condition && currentBar!=CurrentBar)
    {
    currentBar = CurrentBar; // so if the same bar, doesn't draw the object again...

    }


    Thanks..


    Comment


      #3
      Hello brokerbombero,

      Thanks for the post.

      I'm glad you were able to find the issue here.

      Please let me know if there is anything I can assist with.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CaptainJack, 05-29-2026, 05:09 AM
      0 responses
      227 views
      0 likes
      Last Post CaptainJack  
      Started by CaptainJack, 05-29-2026, 12:02 AM
      0 responses
      146 views
      0 likes
      Last Post CaptainJack  
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      160 views
      1 like
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      237 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      197 views
      0 likes
      Last Post CarlTrading  
      Working...
      X