MA Histogramm only show for a limited range
MA Histogramm only show for a limited range
30 Aug 2018, 15:42
is it possible to display (as example) a Moving average only for the last 10 candles?
but not impacting the formular how its calculated ..
something like put NaN in the values?
is there some example out there on how to do this?
Replies
swingfish
06 Sep 2018, 16:13
thank you very much, this did help a lot .. but for some strange reason the indicator does not delete the rest of the day after the reset.
my special version does "reset" to 0 at the Tokyo opening.. and for some reason the previous 15 dots are note being deleted after
i can't figure out where the bug is. as you see the code is really simple
the part
if (i < index - 15)
{
VWAP[i] = double.NaN;
}
does remove the dots perfectly from the current day, but leaves the last 15 points of the previos day staying ..
is there a way to get rid of them ?
here is a screenshoot https://prnt.sc/krb16s
i'm clueless on what i do wrong
private int start_bar = o; if (ShowVwap) { int end_bar = index; int CurrentDay = MarketSeries.OpenTime[end_bar].DayOfYear; double highest = 0; double lowest = 999999; double close = MarketSeries.Close[index]; if (CurrentDay == oldCurrentDay) { double sum = 0.0; for (int i = start_bar; i <= end_bar; i++) { sum += MarketSeries.Close[i]; VWAP[i] = TotalPV / TotalVolume; for (int k = start_bar; k <= i; k++) { double HLC = (MarketSeries.High[k] + MarketSeries.Low[k] + MarketSeries.Close[k]) / 3; double OHLC = (MarketSeries.High[k] + MarketSeries.Low[k] + MarketSeries.Open[k] + MarketSeries.Close[k]) / 4; double avg = HLC; double diff = avg - VWAP[i]; } // cut vwap short if (!ShowHistoricalvWap) { if (i < index - 15) { VWAP[i] = double.NaN; } // this does not work (supposed to delete the old days data /* if (i > MarketSeries.OpenTime[end_bar].DayOfYear) { VWAP[i] = double.NaN; } */ } } } else { oldCurrentDay = MarketSeries.OpenTime[end_bar].DayOfYear; start_bar = end_bar - TimeOffset; } }
@swingfish
PanagiotisCharalampous
06 Sep 2018, 16:16
Hi swingfish,
It seems that you are running that part only for the last day because of the following statement
if (CurrentDay == oldCurrentDay) {
Best Regards,
Panagiotis
@PanagiotisCharalampous
swingfish
06 Sep 2018, 16:28
oh yes, that's right ... so I have to make another loop to do the cleanup I guess
how do I loop through all the history without blowing the memory? to clean it up ?
@swingfish
swingfish
06 Sep 2018, 16:55
thanks again for pointing that out
i just added a "manual removal" in the else of if (CurrentDay == oldCurrentDay)
if (!ShowHistoricalvWap) { for (int i = index - 16; i <= index; i++) { VWAP[i] = double.NaN; }
not really a "clean" way of doing it but that saves me the loop through all the history .. right?
@swingfish
PanagiotisCharalampous
06 Sep 2018, 17:02
Hi swingfish,
You dont need to make a loop. just keep the code outside the if-else statement at the botton of the calculate funtion. See below
if (CurrentDay == oldCurrentDay) { double sum = 0.0; for (int i = start_bar; i <= end_bar; i++) { sum += MarketSeries.Close[i]; VWAP[i] = TotalPV / TotalVolume; for (int k = start_bar; k <= i; k++) { double HLC = (MarketSeries.High[k] + MarketSeries.Low[k] + MarketSeries.Close[k]) / 3; double OHLC = (MarketSeries.High[k] + MarketSeries.Low[k] + MarketSeries.Open[k] + MarketSeries.Close[k]) / 4; double avg = HLC; double diff = avg - VWAP[i]; } // cut vwap short } } else { oldCurrentDay = MarketSeries.OpenTime[end_bar].DayOfYear; start_bar = end_bar - TimeOffset; } if (!ShowHistoricalvWap) { if (i < index - 15) { VWAP[i] = double.NaN; } // this does not work (supposed to delete the old days data }
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
30 Aug 2018, 15:52
Hi swingfish,
Here it is
Best Regards,
Panagiotis
@PanagiotisCharalampous