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

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.
      Chris L.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by andrewtrades, Today, 04:57 PM
      1 response
      10 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by chbruno, Today, 04:10 PM
      0 responses
      6 views
      0 likes
      Last Post chbruno
      by chbruno
       
      Started by josh18955, 03-25-2023, 11:16 AM
      6 responses
      436 views
      0 likes
      Last Post Delerium  
      Started by FAQtrader, Today, 03:35 PM
      0 responses
      9 views
      0 likes
      Last Post FAQtrader  
      Started by rocketman7, Today, 09:41 AM
      5 responses
      20 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X