• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to get something to run on last bar on chart?

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

  • forrestang
    started a topic How to get something to run on last bar on chart?

    How to get something to run on last bar on chart?

    Howdy.

    I have some various stats I have a script I have run on the end of each day, last bar of that particular session template.

    I.e. for a RTH session template of NQ, it will run on that last bar that occurs at the end of the session. My problem is that it works for every day except the very last session. So if I run the report over 15 days of data, it will collect the first 14 days, but it won't execute on the very last day, until a new day begins.

    Is there a way to get around this? Or is there a way to tell it to run on the very latest bar on the chart?

    The piece of code I am using to run at the end of the day is:
    Code:
    			if(Bars.LastBarOfSession )
    			{	
                                     Do somethign
    			}
    Last edited by forrestang; 12-14-2011, 04:47 PM.

  • NinjaTrader_PatrickH
    replied
    Hello Tony,

    Thank you for your post.

    forrestang is correct here. Removing the CurrentBar from the tag string will mean there is only one tag listed so only one dot drawn. If you add a variable to the tag such as CurrentBar that updates every bar you will get a dot each time the condition to draw the dot occurs.

    Leave a comment:


  • AnkaS
    replied
    Hi,
    Try out
    if ( CurrentBar >= ( Count -2 ))
    DrawDot("LastBar", false, 0, Low[0] - 2 * TickSize, Color.Chartreuse);

    Regards

    Vivek

    Leave a comment:


  • tonynt
    replied
    Hello,

    thanks for your help. Seems to work.

    Best regards
    Tony


    Originally posted by forrestang View Post
    Try:
    Code:
    DrawDot("LastBar" , false, 0, Low[0] - 2 * TickSize, Color.Chartreuse);
    If you just want a dot below the last bar on the chart.

    Leave a comment:


  • forrestang
    replied
    Originally posted by tonynt View Post
    Hello,

    I tried to use marking the last bar with the information from NT-support and I do

    DrawDot("LastBar" + CurrentBar, false, 0, Low[0] - 2 * TickSize, Color.Chartreuse);

    But the dots remain below the bars, I just need a dot below the last bar.

    What do I have to change please?

    Thank you
    Tony
    Try:
    Code:
    DrawDot("LastBar" , false, 0, Low[0] - 2 * TickSize, Color.Chartreuse);
    If you just want a dot below the last bar on the chart.

    Leave a comment:


  • tonynt
    replied
    Hello,

    I tried to use marking the last bar with the information from NT-support and I do

    DrawDot("LastBar" + CurrentBar, false, 0, Low[0] - 2 * TickSize, Color.Chartreuse);

    But the dots remain below the bars, I just need a dot below the last bar.

    What do I have to change please?

    Thank you
    Tony

    Leave a comment:


  • NinjaTrader_PatrickH
    replied
    Hello Ankas,

    Thank you for your post.

    Count will work in multi-series indicators and strategies.

    Leave a comment:


  • AnkaS
    replied
    Hi,
    Will Count also work in case of MutiSymbol strategy?

    Regards

    Vivek

    Leave a comment:


  • forrestang
    replied
    Thank you, that seems to be what I needed to trigger that last session run.

    Leave a comment:


  • NinjaTrader_RyanM1
    replied
    Hi forrestang,

    You can work with CurrentBar in relation to Count to identify the last bar on the chart.

    When CalculateOnBarClose = true:
    if (Count - 2 == CurrentBar)

    When CalculateOnbarClose = false:
    if (Count - 1 == CurrentBar)

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by Jschmelz, Today, 04:45 PM
1 response
7 views
0 likes
Last Post NinjaTrader_Marco  
Started by sisenberg, Today, 08:06 PM
1 response
8 views
0 likes
Last Post sisenberg  
Started by priceisking, Today, 07:44 PM
0 responses
5 views
0 likes
Last Post priceisking  
Started by saltminer, Today, 06:06 PM
0 responses
5 views
0 likes
Last Post saltminer  
Started by KennyK, Today, 05:25 PM
0 responses
7 views
0 likes
Last Post KennyK
by KennyK
 
Working...
X