(login for full post details)
#1 (permalink )
South Jordan UT
Experience: Intermediate
Platform: Ninjatrader
Trading: Forex
Posts: 15 since Jan 2013
Thanks: 6 given,
1
received
Hello all,
I got PMA indicator from public domain and I like to try using this for strategy. I am trying to modify PMA indicator into a strategy. But it doesn't work for me. I know I have a lot to learn. It is a simple program and I am not familiar with the differences between indicator and strategy plottings.
Would it be possible if you could just modify those lines below? I hope it is not too big of a task and is really simple. Is it doable?
Let me know.
Many thanks,
-traderjh
Code
#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Gui.Chart;
#endregion
// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
/// <summary>
/// Predictive Moving Average (ehlers)
/// </summary>
[Description("Predictive Moving Average (ehlers)")]
public class PMA : Indicator
{
#region Variables
// declare the variables here
double WMA2;
double Trigger;
// create the dataseries here
private DataSeries WMA1;
private DataSeries Predict;
#endregion
/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
// add the plots here
Add(new Plot(new Pen(Color.Blue, 3), PlotStyle.Line, "Predict_Plot"));
Add(new Plot(new Pen(Color.Red, 3), PlotStyle.Line, "Trigger_Plot"));
CalculateOnBarClose = true;
Overlay = false;
PriceTypeSupported = true;
// initialize dataseries here
WMA1 = new DataSeries(this);
Predict = new DataSeries(this);
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// if there isn't enough data just set the variables to 0
if (CurrentBar < 7)
{
WMA1.Set(0);
WMA2 = 0;
Predict.Set(0);
Trigger = 0;
}
// else set the variables to the real values
else
{
WMA1.Set((7*Median[0] + 6*Median[1] + 5*Median[2] + 4*Median[3] + 3*Median[4] + 2*Median[5] + Median[6])/28);
WMA2 = (7*WMA1[0] + 6*WMA1[1] + 5*WMA1[2] + 4*WMA1[3] + 3*WMA1[4] + 2*WMA1[5] + WMA1[6])/28;
Predict.Set(2*WMA1[0] - WMA2);
Trigger = (4*Predict[0] + 3*Predict[1] + 2*Predict[2] + Predict[3])/10;
}
// set the plots
Predict_Plot.Set(Predict[0]);
Trigger_Plot.Set(Trigger);
}
#region Properties;
// create the dataseries for the plots
[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public DataSeries Predict_Plot
{
get { return Values[0]; }
}
[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public DataSeries Trigger_Plot
{
get { return Values[1]; }
}
#endregion
}
}