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
Adding and Alert to the CCI Indicator
Collapse
X
-
Hello danp502,
You can modify the CCI indicator by making a copy of it with a different name and then add alerts.
Please use the steps I have provided below to create a copy of an indicator:- In the Control Center select Tools > Edit NinjaScript > Indicator...
- Select the indicator to copy > Click Ok
- Right-click within the code window > select Save As
- Give the indicator a unique name > Click OK
Below is a link to Alert() in the Help Guide.
http://www.ninjatrader.com/support/h.../nt7/alert.htm
Also, because this was a simple change, I have modified the indicator for you so that you have a working example and you can use this to modify other scripts or create your own.Attached FilesChelsea B.NinjaTrader Customer Service
-
Hi,
Can someone add an alert option to this indicator for me, Please.
As Chelsea said, I guess a parameter is the answer, as I guess that means it shows up when the indicator is added to a chart, and one can change the sound alert?
Thank you,
JoeAttached Files
Comment
-
Hi westcoastjoe,
Using the example in post #4 you should be able to add a string input parameter that allows you to type a filename and use this as the sound file located in C:\Program Files (x86)\NinjaTrader 7\sounds\.
In this example we create a string to store the filename with a default value:
private string soundFile = "Alert1.wav";
Create a public input the user can type into:
[Description("Name of file for alert sound located in C:\\Program Files (x86)\\NinjaTrader 7\\sounds\\")]
[GridCategory("Parameters")]
public string SoundFile
{
get { return soundFile; }
set { soundFile = value; }
}
And use this string for the soundLocation override in the Alert call:
Alert("CCIcross", NinjaTrader.Cbi.Priority.Low, "CCI Crossed above 100", soundFile, 1, Color.White, Color.Black);
Alert(string id, Priority priority, string message, string soundLocation, int rearmSeconds, Color backColor, Color foreColor)
If you want to add an option to turn the alerts on or off, you can use a bool for this. Bool is short for boolean which holds a true or false value.
For example:
Create the bool:
private bool useAlerts = true;
Create a public input:
[Description("Use Alerts")]
[GridCategory("Parameters")]
public bool UseAlerts
{
get { return useAlerts; }
set { useAlerts = value; }
}
In your logic where you want to add the alert use:
if (/* logic to trigger alert && */ useAlerts == true)
{
Alert("myAlert", NinjaTrader.Cbi.Priority.Low, "This is my custom alert", soundFile, 1, Color.White, Color.Black);
}
Below is a link to the help guide on Alert().
http://www.ninjatrader.com/support/h.../nt7/alert.htmChelsea B.NinjaTrader Customer Service
Comment
-
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by junkone, Today, 11:37 AM
|
2 responses
12 views
0 likes
|
Last Post
by junkone
Today, 12:09 PM
|
||
Started by frankthearm, Yesterday, 09:08 AM
|
12 responses
43 views
0 likes
|
Last Post Today, 12:05 PM | ||
Started by quantismo, 04-17-2024, 05:13 PM
|
5 responses
35 views
0 likes
|
Last Post Today, 11:32 AM | ||
Started by proptrade13, Today, 11:06 AM
|
1 response
7 views
0 likes
|
Last Post Today, 11:27 AM | ||
Started by love2code2trade, 04-17-2024, 01:45 PM
|
4 responses
35 views
0 likes
|
Last Post Yesterday, 10:31 PM |
Comment