I have written this code to plot the well known ichimoku indicator as practice, but seem to be missing something.
It compiles fine and can be applied to the chart, but there is no output on the chart..
Could someone please point me in the right direction, I dont see what im missing, everything appears perfect in my code.
public class Ichimoku : Indicator
{
#region Variables
// Wizard generated variables
private int tSperiod = 9; // Default setting for TSperiod
private int kSperiod = 26; // Default setting for KSperiod
// User defined variables (add any user defined variables below)
#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(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "TS"));
Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "KS"));
Add(new Plot(Color.FromKnownColor(KnownColor.DarkViolet), PlotStyle.Line, "SpanA"));
Displacement = kSperiod;
Add(new Plot(Color.FromKnownColor(KnownColor.Firebrick), PlotStyle.Line, "SpanB"));
Displacement = kSperiod;
Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "CS"));
Displacement = (kSperiod * (-1));
CalculateOnBarClose = true;
Overlay = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
double ts1, ks1, spa1, spb1, cs1;
ts1 = (High[tSperiod] + Low[tSperiod]) / 2;
ks1 = (High[kSperiod] + Low[kSperiod]) / 2;
spa1 = (ts1 + ks1) / 2;
spb1 = (High[(kSperiod * 2)] + Low[(kSperiod * 2)]) / 2;
cs1 = Close[0];
TS.Set(ts1);
KS.Set(ks1);
SpanA.Set(spa1);
SpanB.Set(spb1);
CS.Set(cs1);
}
}
Comment