Timon,
The code is too long. What i can say is if i declare or initialize listm private it will return a different answer.
protected override void OnBarUpdate() and protected override void OnRender are classes coming from the software ninjatrader, charting software.
I want to use AddPlot method to create a line in the chart from the values in listm but AddPlot method will only work in OnBarUpdate().
According to the tech at NT :
A value would need to be assigned to the plot in OnBarUpdate(), then you would call base.OnRender() in OnRender() to ensure Plots are rendered along with custom render logic.
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"new version of SDBA";
Name = "NEWSDBA";
Calculate = Calculate.OnEachTick;
IsOverlay = true;
DisplayInDataBox = true;
DrawOnPricePanel = true;
DrawHorizontalGridLines = true;
DrawVerticalGridLines = true;
PaintPriceMarkers = true;
ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
//Disable this property if your indicator requires custom values that cumulate with each new market data event.
//See Help Guide for additional information.
IsSuspendedWhileInactive = true;
TBPrice = 0;
CheckV = true;
Volume = 0;
AddPlot(Brushes.Yellow, "NEWSDBA");
}
}
protected override void OnBarUpdate()
{
}
protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
{
//CMA minute
var lists = new List<double>();
var listv = new List<double>();
double avg = 0;
double closePrice = 0;
double volumes = 0;
double sum1 = 0;
double sum2 = 0;
double fibo2 = 0;
for (int barIndex = foundIndex; barIndex <= ChartBars.ToIndex; barIndex++)
{
closePrice = Bars.GetClose(barIndex);
volumes = Bars.GetVolume(barIndex);
if (CheckV)
{
avg = Volume;
}
else
{
avg = sum2 / RfoundI;
}
double clovol = closePrice * volumes;
sum1 += clovol;
sum2 += volumes;
cma = sum1 / sum2;
lists.Add(closePrice);
listv.Add(volumes);
}
var listm = new List<double>();
listm.Add(Close.GetValueAt(CurrentBar));
}
}
If you can make sense of this be my guess.
Thank you