Just wondering if anyone can cast their eye over my attempt at adding this Better Volume indicator into an EA for testing?
I'm trying to look back the past twenty bars to see if there is any climax high / low volume and then save it to a GlobalVariable. From what I can see the indicator buffer is 7, but for some reason when I run the for-loop it will only see the bar 0 and 1 and doesn't scan through the last 20 bars (TrendVolumeLookBackCandles) as needed!.
Apologies
Indicator attached...
Thanks, JP
Code: Select all
if (UseTrendVolume)
{
static datetime oldTrendVolumeBarTime = 0;
if (oldTrendVolumeBarTime != iTime(Symbol(), VolumeIndicatorTimeFrame, 0))
{
oldTrendVolumeBarTime = iTime(Symbol(), VolumeIndicatorTimeFrame, 0);
TrendVolumeStatus = volumenosignal;
for (int vv = 0; vv <= TrendVolumeLookBackCandles; vv++)
{
trendvolumevalue = iCustom(Symbol(), TrendVolumeTradingTimeFrame, "BetterVolume",7,vv);
if(!CloseEnough(trendvolumevalue,EMPTY_VALUE))
{
if(trendvolumevalue == 1) TrendVolumeStatus = volumeclimaxhigh;
if(trendvolumevalue == 2) TrendVolumeStatus = volumeneutral;
if(trendvolumevalue == 3) TrendVolumeStatus = volumelow;
if(trendvolumevalue == 4) TrendVolumeStatus = volumehighchurn;
if(trendvolumevalue == 5) TrendVolumeStatus = volumeclimaxlow;
if(trendvolumevalue == 6) TrendVolumeStatus = volumeclimaxchurn;
if (TrendVolumeStatus == volumeclimaxhigh)
{
TrendVolumeTradeTrigger = volumetradesell;
GlobalVariableSet(TrendVolumeTradeTriggerGvName,1);
break;
}
if (TrendVolumeStatus == volumeclimaxlow)
{
TrendVolumeTradeTrigger = volumetradebuy;
GlobalVariableSet(TrendVolumeTradeTriggerGvName,2);
break;
}
}
}
}
}