Trabajo finalizado
Tarea técnica
I have gotten an indicator called RVOL, which measures the relative volume of a symbol against the past days of trading.
This is currently an indicator format.
What I need is this converted into a bool / double that reflects the same value shown in the indicator.
To understand further.
1) Watch the video provided (zip file)
2) Have a look at the code
3) Have a read of the rest of the description.
Note: I need developers who are able to deliver on time so please only apply if you can complete this task
This the main indicator section of code:
void CalculateRelVolume(const int startBar, const int rates_total, const long& volume[]) { vol[startBar] = (double)volume[startBar]; int i = startBar; if (i >= rates_total) i = rates_total - 1; for (; i > 0 && !IsStopped(); i--) { double curr_volume = (double)volume[i]; double mean_volume = 0.0; for(int j = 1; j <= AveragingDays; j++) mean_volume += (double)volume[i + (j * BarsIn24Hours)]; mean_volume /= (double)AveragingDays; //N.B. Value of 1.0 represents current vol is equal to average volume, 0.0-1.0 is below average, >1.0 is above average if(mean_volume>0) vol[i] = curr_volume / mean_volume; if(vol[i] > indicator_level1) volHigh[i] = vol[i]; //If current vol higher than average else if (vol[i] > indicator_level2) volMedium[i] = vol[i]; //If current vol lower than average else volLow[i] = vol[i]; } }
Note there are more parts to this indicator. But simple answer is vol[i] is the value that needs to be fetched.
This is my first attempt: (Note I do not want to have to fetch iCustom)
bool RVOL1(string symb1) { double RVOL = iCustom(symb1, PERIOD_M1,"RVOL", 5, 3, 1); double RVOL_MAX = 1.0; if(RVOL < RVOL_MAX) return true; else { return false; } return false; }
This is my second attempt at it:
bool isVolumeBelowAverage(string symb) { bool state = false; int averagingDays = 5; int rates_total = Bars(symb, PERIOD_M1); int barsIn24Hours = 0; datetime prevDateTime = iTime(symb, PERIOD_M1, 0) - (86400 * 7); int numBarsIn7Days = iBarShift(symb, PERIOD_M1, prevDateTime, false); barsIn24Hours = numBarsIn7Days / 5; if (barsIn24Hours == 0) return false; double curr_volume = iVolume(symb, PERIOD_M1, 0); double mean_volume = 0.0; for (int j = 1; j <= averagingDays; j++) { mean_volume += iVolume(symb, PERIOD_M1, 0 + (j * barsIn24Hours)); } mean_volume /= (double)averagingDays; double relVolume = 0.0; if (mean_volume > 0) { relVolume = curr_volume / mean_volume; } if(relVolume < 0.8) { state = true; } return(state) ; }