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!
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
NinjaTrader
Print only after last Daily bar
Collapse
X
-
Print only after last Daily bar
I have a Print line that does running totals (+=) in OnBarUpdate, so i only want it to Print once. What's the most succinct way to make that happen on Daily bars?Tags: None
-
Hi Bruce,
Thanks for that. I'm cycling through a trade colleciton, and I want to print that line only after the last trade. I'm porting a script from a friend who works in tradestation, and he has something called "LastBarOnChart" that does the trick for him, but I haven't found anything for NT like that.
David
Comment
-
Hi, If your script is running Calculate.OnBarClose, the last historical bar would be:
if ( CurrentBar == ( BarsArray[0].Count-2))
{
Draw.Dot(this, "LASTBAR", false, 0, High[0], Brushes.Red);
}
If the script is running OnEachTick, it can be written as:
if ( CurrentBar == ( BarsArray[0].Count-1) && IsFirstTickOfBar)
{
Draw.Dot(this, "LASTBAR", false, 0, High[0], Brushes.Red);
}Chris L.NinjaTrader Customer Service
Comment
-
-
Hi Chris,
Is there a way to do this when I'm using State == State.Terminated inside of OnStateChange()? for instance:
else if (State == State.Terminated)
{
if (SystemPerformance.AllTrades.Count > 0)
{
foreach (Trade lastTrade in SystemPerformance.AllTrades)
{
lastMfe = lastTrade.MfeCurrency
//adjustMfe += lastMfe / (ATR(14)[0] * Bars.Instrument.MasterInstrument.PointValue); // how do I print this cumulative value only once at the end of the collection?
}}}Last edited by trader3000a; 05-23-2023, 05:10 AM.
Comment
-
I would be reluctant personally to do this... do we know that during State.Terminated the SystemPerformance information has not already been broken down? The naming of the state "Terminated" (rather than "PreTerminate" or something like that suggests that the destruction is already underway. Still, maybe it will work if coincidentally that part is disposed later than this part? Have you tried?
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Net Change
by Segwin
Started by Segwin, 05-07-2018, 02:15 PM
|
14 responses
1,788 views
0 likes
|
Last Post
by aligator
Today, 11:47 AM
|
||
Started by Jimmyk, 01-26-2018, 05:19 AM
|
6 responses
837 views
0 likes
|
Last Post
by emuns
Today, 11:27 AM
|
||
Started by jxs_xrj, 01-12-2020, 09:49 AM
|
6 responses
3,293 views
1 like
|
Last Post
by jgualdronc
Today, 10:56 AM
|
||
Started by Touch-Ups, Today, 10:36 AM
|
0 responses
13 views
0 likes
|
Last Post
by Touch-Ups
Today, 10:36 AM
|
||
Started by geddyisodin, 04-25-2024, 05:20 AM
|
11 responses
63 views
0 likes
|
Last Post Today, 10:08 AM |
Comment