PDA

View Full Version : Simple Code


chrismayerinmarket
09-12-2011, 08:40 AM
Hello

I have a simple request if coders may. There is a plain ema color indicator in the following link http://www.ninjatrader.com/support/forum/showthread.php?t=43611 .

attached by the name ColoredEmaNT7.zip


Could someone graciously add a sound alert to the code so that it would get triggered when ema changes color.

I would really appreciate it.

Thank you

NinjaTrader_Matthew
09-12-2011, 08:46 AM
Hello,

You should be able to add this and customize it to your preferences very easily.

In the OnBarUpdate() section of the code, please try replacing the following:


if (Rising(ColorEMA))
{
PlotColors[0][0] = Color.Blue;
Alert("Rising", NinjaTrader.Cbi.Priority.High, "EMA Rising", "Alert1.wav", 10, Color.Black, Color.Yellow);
}
else if (Falling(ColorEMA))
{
PlotColors[0][0] = Color.Red;
Alert("Falling", NinjaTrader.Cbi.Priority.High, "EMA Faling", "Alert1.wav", 10, Color.Black, Color.Yellow);
}
More information on using the Alert() function can be found below:

http://www.ninjatrader.com/support/helpGuides/nt7/index.html?alert.htm

Please let me know if you have any questions and I'd be happy to help you get this working.

chrismayerinmarket
09-12-2011, 09:44 AM
thank you very much matthew..

However, I have absolute no experience with coding.. I opened the indicator in edit script and copied what you posted over what what written but bunch of errors came up "statement expected"...

Will the modification you posted fire an alert with each bar that closes or not.

I am hoping for something that would trigger when ema changes color but if the next bar has the same color of the ema it wont fire..

again thank you very much..

NinjaTrader_Matthew
09-12-2011, 09:56 AM
Hello,

This would take some extra steps, but definitely possible.

We do not normally do this, but we will have one of our NinjaScript trainees look into this as a practice exercise. You should be getting a response in this thread once it is completed or if more information is needed from you to finish.

If you have limited time or programming capabilities, you can discuss your requirements with any of our NinjaScript consultants.


Click here for a list of certified NinjaScript Consultants (http://www.ninjatrader.com/support/forum/../../partners#NinjaScript-Consultants)

chrismayerinmarket
09-12-2011, 10:00 AM
I can't thank you enough. I really appreciate this matthew.!

NinjaTrader_AdamP
09-12-2011, 10:46 AM
Chrismayerinmarket (http://www.ninjatrader.com/support/forum/member.php?u=30104),

Please find attached the requested indicator. I have tested it out on Gold and some Forex pairs and it appears like it is working great.

To see the Alerts, you will need to go to File > New > Alerts, though there should be a sound that plays when a new alert from this indicator is triggered.

In the Alerts window, when the EMA goes from Blue to Red, it will alert you in Red "EMA Falling", and when the EMA goes from Red to Blue, it will alert you in Blue "EMA Rising".

For future modifications, I would suggest visiting some of our NinjaScript certified consultants at the link below :

http://www.ninjatrader.com/partners#NinjaScript-Consultants

chrismayerinmarket
09-15-2011, 02:15 PM
Hello

Thank you very much for your help adam. I have just been able to test the indicator you have attached. I tried to compile it with the original ColoredEMA.cs present... it didn't allow me... So I compiled it alone and it compiled fine....

However I don't see any alerts.. I open a chart, load coloredemawalerts indicator..there is no option in the indicators window to view or select alerts...

I did as you suggested to open an alert window.. but there is no sign of the ema alerts there nor an option to load the indicator in the alert..

I really appreciate your help,,

NinjaTrader_AdamP
09-16-2011, 07:08 AM
Chris,

I am happy to help.

If you go to File > New > Alerts, an Alert window should pop-up. One thing to remember is that these alerts will only work in real-time and ignored on historical data. So basically, it may take awhile for the alert to trigger until the market changes trend locally.

Please let me know if I can assist further.