![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| Indicator Development Support for the development of custom indicators using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Mar 2009
Posts: 56
Thanks: 0
Thanked 0 times in 0 posts
|
Hi,
Who can help me? I would like an indicator with three exponential moving averages. What is wrong in your code? (I see only one!) This is the code: [Description()] publicclass EMAs3 : Indicator { #region Variables privateint fast = 7; // Default setting for Fast privateint average = 14; // Default setting for Average privateint slow = 21; // Default setting for Slow #endregion protectedoverridevoid Initialize() { Add(new Plot(Color.Red, "EMA Fast")); Add(new Plot(Color.DarkViolet, "EMA Average")); Add(new Plot(Color.Blue, "EMA Slow")); Overlay = true; PriceTypeSupported = true; } protectedoverridevoid OnBarUpdate() { Value.Set(CurrentBar == 0 ? Input[0] : Input[0] * (2.0 / (1 + Fast)) + (1 - (2.0 / (1 + Fast))) * Value[1]); Value.Set(CurrentBar == 0 ? Input[0] : Input[0] * (2.0 / (1 + Average)) + (1 - (2.0 / (1 + Average))) * Value[1]); Value.Set(CurrentBar == 0 ? Input[0] : Input[0] * (2.0 / (1 + Slow)) + (1 - (2.0 / (1 + Slow))) * Value[1]); } Thank you for your help germano |
|
|
|
|
|
#2 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
germano,
You cannot do Value.Set for all of them. Value.Set is only used when the indicator has one plot. If your indicator has multiple plots you need to call the appropriate plot names. Please see the MACD indicator for an example. Please note how the plots are named in the Properties region of the code.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: Mar 2009
Posts: 56
Thanks: 0
Thanked 0 times in 0 posts
|
Thanks Josh for suggestion; I am going to study the code of the MACD indicator.
Hello |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Displaced moving averages | ggloor | Charting | 6 | 10-11-2009 02:11 AM |
| Price Data and Moving Averages | mainstream | Strategy Development | 3 | 02-02-2009 07:27 AM |
| Displaced moving averages | T2020 | Charting | 2 | 01-20-2009 09:13 AM |
| how to chart envelopes on moving averages | saltcafe | Charting | 1 | 09-01-2008 12:10 PM |
| Nested moving averages? | Burga1 | Indicator Development | 2 | 11-16-2007 08:51 AM |