This cannot be the code that you are showing the results from. You have placed your print and return in the parameters for the OnCalculate function. There is no way that this will work.
int OnCalculate (const int rates_total, // size of input time series const int prev_calculated, // bars handled in previous call const datetime& time[], // Time const double& open[], // Open const double& high[], // High const double& low[], // Low const double& close[], // Close const long& tick_volume[], // Tick Volume const long& volume[], // Real Volume const int& spread[] // Spread Print ("Volume: ", Volume[0], " , prev_calculated: ", prev_calculated, " ,rates_total: " ,rates_total, " , IndicatorCounted: " , IndicatorCounted(), " , Bars:", Bars); return(rand()); );
GumRai:
This cannot be the code that you are showing the results from. You have placed your print and return in the parameters for the OnCalculate function. There is no way that this will work.
Thank you, I added the missing line. Any other comment?
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
First, I will reprint a paragraph of the English help file:
We should noted the connection between the return value of OnCalculate() and the second input parameter prev_calculated. During the function call, the prev_calculated parameter contains a value returned by OnCalculate() during previous call.
As I do not believe anything in the new betatrader 600+, I started a test, and I placed only a Print statement to see how the values change.
In addition I placed a random number for the return value, to confirm if it appears back in the prev_calculated variable.
int OnCalculate (const int rates_total, // size of input time series const int prev_calculated, // bars handled in previous call const datetime& time[], // Time const double& open[], // Open const double& high[], // High const double& low[], // Low const double& close[], // Close const long& tick_volume[], // Tick Volume const long& volume[], // Real Volume const int& spread[] // Spread ) { Print ("Volume: ", Volume[0], " , prev_calculated: ", prev_calculated, " ,rates_total: " ,rates_total, " , IndicatorCounted: " , IndicatorCounted(), " , Bars:", Bars); return(rand()); );
The output was like that:
From this listing, I haven't found the previous return value in the function parameter. The prev_calculated equals the previous rates_total instead (= IndicatorCounted() + 1).
So, I wonder what will change in the future - implementation or the help file? What shall I keep an eye on?