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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      156 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      90 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      140 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      130 views
      1 like
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      107 views
      0 likes
      Last Post CarlTrading  
      Working...
      X