Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Vertical Line

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

    Vertical Line

    OK, this one seems like it should be pretty easy/obvious, but it's not.

    Created a basic strategy in Strategy Builder to draw a vertical line on a 5-minute chart wherever the close was higher than the open. (This was just for testing, because I haven't been able to get the vertical line to work on anything and figured I'd start out with the most basic conditions)

    It draws one vertical line, on the most recent bar that meets the criteria, and that's it. Every single other drawing object will draw on every bar that meets the criteria as far back as the bars go.

    What's wrong here? This is Strategy Builder syntax, unmodified:

    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0)
    return;

    if (CurrentBars[0] < 0)
    return;

    // Set 1
    if (Close[0] > Open[0])
    {
    Draw.VerticalLine(this, @"VerticalLine Vertical line_1", 0, Brushes.Lime, DashStyleHelper.Solid, 2);
    }​

    Click image for larger version

Name:	image.png
Views:	413
Size:	608.5 KB
ID:	1253035

    #2
    Hello LunaKai,

    That is because of the tag you used. You need to click in the tag field and click Set to bring up the string builder window. In that window you can type in the string you have, in the following field click Set and then choose Misc -> CurrentBar. That will make unique tags so you aren't updating 1 object each time the condition is true.

    Comment


      #3
      That did it. I'd been using ArrowDown and so forth from other Strategy examples and they were working just fine...now I know that's because they modified each bar's tag.

      Thanks much!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      79 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      40 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      63 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      63 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      54 views
      0 likes
      Last Post CarlTrading  
      Working...
      X