View Full Version : Price parameter in Moving Average
bmaltz
06-07-2007, 11:43 AM
Hi,
I would like to plot a displaced simple moving average of: (O + C)/2
How would I modify the Simple Moving Average ninjascript code to effect this change?
thanks,
Ben
NinjaTrader_Ray
06-07-2007, 12:29 PM
Hi,
You would have to create a new indicator and create a DataSeries, lets call it displacedData and set its values on each call to the OnBarUpdate() method.
Something like:
displacedData.Set((Open[0] + Close[0]) / 2);
Then you would do something like:
Plot0.Set(SMA(displacedData, 20)[0]);
bmaltz
06-07-2007, 09:16 PM
Could I take the existing Simple Moving Average file make a copy and rename it and add the (O+C)/2 code to it?
NinjaTrader_Josh
06-07-2007, 09:49 PM
Just open the original SMA file, right click, save as and name it whatever you want. Then just edit the new file and compile it. Make sure to change the indicator references at the top and then you should be good to go.
bmaltz
06-08-2007, 06:51 AM
Hi uacvax,
Thanks for the help. Can you be more specific about which references need to be changed?
Thanks,
Ben
NinjaTrader_Ray
06-08-2007, 06:55 AM
The class name and display name.
zkalian
06-08-2007, 12:50 PM
Can someone please help me, in strategy:
How I can write if I want a certain MA to cross at a Certain "ANGLE"
say 30 degrees, not less
Thanks
Zee
NinjaTrader_Ray
06-08-2007, 01:10 PM
Hi Zee,
I have started a new thread specific to your topic here.
http://www.ninjatrader-support.com/vb/showthread.php?p=11079#post11079
bmaltz
06-08-2007, 06:40 PM
Hi,
You would have to create a new indicator and create a DataSeries, lets call it displacedData and set its values on each call to the OnBarUpdate() method.
Something like:
displacedData.Set((Open[0] + Close[0]) / 2);
Then you would do something like:
Plot0.Set(SMA(displacedData, 20)[0]);
I'm not a C# programmer, can you possibly provide any more assistace in creating this indicator?
Thanks,
Ben
NinjaTrader_Ray
06-09-2007, 09:31 AM
Unfortunately are unable to provide assistance in programming implementation.
Take a look at some of our system indicators such as Stochastics to get an idea of how to use a DataSeries object.
NinjaTrader_Ray
06-09-2007, 12:16 PM
Alternatively,
You can contact one of our NinjaScript consultants to help as well.
http://www.ninjatrader.com/webnew/partners_onlinetrading_NinjaScript.htm