protected override void OnBarUpdate() { if (!FancyLicensingBool) { Draw.TextFixed(this, "license-errors", "Not Licensed", TextPosition.Center, Brushes.Black,new SimpleFont("Arial", 16), Brushes.Black, Brushes.White, 100); return; } }
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
How can I exit an Indicator
Collapse
X
-
How can I exit an Indicator
Is there anyway to exit the processing of an indicator altogether in order to draw text on the pane? For example, if I make a license call to my server and the user is not licensed, I am trying something like this:
Code:Tags: None
-
There is option to use {SetState(State.Finalized);} instead of return;
There is also State.Terminated but I've found this does not exit indicator, it just starts it again in the same way using "return;" does. I don't think State.Finalzed is supported by NT support so I guess you use it at your own risk. Hopefully someone from NT will be able to explain there usage better.
-
Hello swooke,
Thanks for your post.
If you want to have the indicator draw on the chart, I would suggest setting a bool and then drawing on the chart like you have done. Aborting the indicator will cause the drawing objects to disappear.
This would not be a supported approach so your mileage may vary, but you could try removing your indicator from the ChartControl.Indicators collection. I would not recommend trying this with indicators that use IsOverlay = false since removing from the Indicators collection will not remove the added panel.
ChartControl.Indicators.Remove(this);
You could combine this with throwing an exception so an error is noted in the Log tab of the Control Center.
throw new Exception("Script terminated.");
I'll leave the thread open for other community members that may have input using unsupported code.
JimNinjaTrader Customer Service
Comment
-
Yeah, whatever happened to the NT7 method of using "Enabled = false;"? (for ex, see NT7's @Pivots.cs indicator)
I mean, it would seem that the NT8 equivalent of "Enabled = false;" is what the OP is looking for.
I also note that NT7 Strategy supported a Disable() method (which I assumed was a wrapper for that 'Enable' variable),
does NT8 have an equivalent for that?
I mean, one would think there should be a common universal "Disable()" like method in NT8 that would work
similarly across all plugin types -- aka, Indicators, Strategies, and Addons ... does that exist? If not, why not?
What is the correct/documented/supported way to disable your NT8 NinjaScript object?
Comment
-
Hello bltdavid,
The Enabled property is not documented for NinjaTrader 7 and we have moved away from doing this in NinjaTrader 8. NinjaTrader 8 Pivots will draw text on the chart and log an error so the user is informed of what happened with the script.
Disable() in NinjaTrader 7 is for strategies only and is replaced with CloseStrategy() in NinjaTrader 8.
CloseStrategy() - https://ninjatrader.com/support/help...sestrategy.htm
SetState(State.Terminated) would be our suggested way to terminate a script. Similar to what we see when setting Enabled to false in NinjaTrader 7, this will not remove the indicator from the chart.
SetState - https://ninjatrader.com/support/help.../?setstate.htm
We look forward to assisting.JimNinjaTrader Customer Service
- Likes 1
Comment
-
Originally posted by NinjaTrader_Jim View PostHello bltdavid,
The Enabled property is not documented for NinjaTrader 7 and we have moved away from doing this in NinjaTrader 8. NinjaTrader 8 Pivots will draw text on the chart and log an error so the user is informed of what happened with the script.
Disable() in NinjaTrader 7 is for strategies only and is replaced with CloseStrategy() in NinjaTrader 8.
CloseStrategy() - https://ninjatrader.com/support/help...sestrategy.htm
SetState(State.Terminated) would be our suggested way to terminate a script. Similar to what we see when setting Enabled to false in NinjaTrader 7, this will not remove the indicator from the chart.
SetState - https://ninjatrader.com/support/help.../?setstate.htm
We look forward to assisting.
When I use state terminated in an indicator script, the script will terminate once, then restart on the next bar so I cannot get it to actually terminate the script, it only terminates then start again. Am I missing something in how to use state terminated to ensure that it ends the script and it doesn;t start again or is this normal behaviour and only finalize actually stops the script from restarting?
Comment
-
Hello b16_aln,
When you test with SetState(State.Terminated); are you calling this during historical processing or when the script is processing realtime data? When I test when State.Realtime is reached, the script no longer processes OnBarUpdate.
Historical data is processed in a thread pool, so the same approach would not work here to set the state to State.Terminated when the script processes historical data. I would recommend using a return statement instead.
If you have additional questions here, could you modify the test script I attached so we can look at a similar example?
I look forward to assisting.Attached FilesJimNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Dr Kerry, Today, 02:03 AM
|
0 responses
2 views
0 likes
|
Last Post
by Dr Kerry
Today, 02:03 AM
|
||
Started by AndriXF7, 12-06-2023, 10:09 AM
|
5 responses
161 views
1 like
|
Last Post
by Lunorri
Today, 01:56 AM
|
||
Started by rosa2013, Today, 01:47 AM
|
0 responses
1 view
0 likes
|
Last Post
by rosa2013
Today, 01:47 AM
|
||
Started by owenany, Today, 01:25 AM
|
0 responses
1 view
0 likes
|
Last Post
by owenany
Today, 01:25 AM
|
||
Started by BigRay, 04-07-2023, 05:41 PM
|
2 responses
659 views
1 like
|
Last Post
by 2inthebush
Today, 01:10 AM
|
Comment