The Indicator works in the Chart but not the Market Analyzer - am I missing something in my code specific for the market analyzer ?
#region Variables
// Wizard generated variables
private int overSoldLong = 25; // Default setting for OverSoldLong
private int overBoughtLong = 70; // Default setting for OverBoughtLong
private int sellShort = 75; // Default setting for SellShort
private int coverShort = 30; // Default setting for CoverShort
private int biasLong = 0;
// User defined variables (add any user defined variables below)
#endregion
protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "TPS"));
Overlay = false;
}
/// <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.
// Do not calculate if we don't have enough bars
if (CurrentBar < 200) return;
double value_SMA = SMA(Close, 200)[0];
double curr_value_RSI = RSI(Close, 2, 0)[0];
double prev_value_RSI = RSI(Close, 2, 0)[1];
if ((curr_value_RSI> overBoughtLong ) | (Close[0] < value_SMA) )
{
biasLong = 0;
}
if (biasLong>0 & Close[0] < Close[1] & Close[0] > value_SMA)
{
biasLong = biasLong + 1;
}
else if ((curr_value_RSI < overSoldLong) & (prev_value_RSI < overSoldLong) & (Close[0] > value_SMA) )
{
biasLong = 1;
DrawLine("tag1", false, 1, prev_value_RSI, 0, curr_value_RSI, Color.LimeGreen, DashStyle.Dot, 2);
}
;
TPS.Set(biasLong);
}
Comment