Hi all,
just my 2 cents worth on the build 600:
1) in Empty4 pre v600 you could do naughty things like this:
string S1;
S1 = "some text:";
S1 = S1 + " new text";
resulting in S1 acquiring the value "some text: new text";
Unfortunately - you can no longer do this, and if you have any code that relies on this, it will no longer work.
The solution to resolve the issue is simple (which is cleaner anyway):
string S1, tmp="";
S1 = "some text";
tmp = S1;
S1 = tmp + "new text";
2) I may be wrong in understanding but I have tested the following:
IndicatorCounted():
Returned value - The amount of bars not changed after the indicator had been launched last.
prev_calculated:
'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. This allows for economical algorithms for calculating the custom indicator in order to avoid repeated calculations for those bars that haven't changed since the previous run of this function.
For this, it is usually enough to return the value of the rates_total parameter, which contains the number of bars in the current function call. If since the last call of OnCalculate() price data has changed (a deeper history downloaded or history blanks filled), the value of the input parameter prev_calculated will be set to zero by the terminal.'
Both in strategy tester and on live data I see the following values produced by Empty4 v600:
on NewBar: Bars == rates_total, prev_calculated == rates_total-1, IndicatorCounted() == prev_calculated-1
during bar: Bars == rates_total, prev_calculated == rates_total, IndicatorCounted() == prev_calculated-1
and this is regardless of whether OnCalculate() has a return(x) with x=rates_total, x=prev_calculated, x=0, x=1, x=-1. Somehow it appears that the return value from OnCalculate is not used in any way....(but I may be dumb

)
You can use the following code in an indicator to test this behaviour.
Code: Select all
int bars=Bars(Symbol(),0);
int ic = IndicatorCounted();
int BminIC = bars - ic - 1;
int BminPC = rates_total - prev_calculated;
if (NewBar())
Print(" Bars = ",bars,
", rates_total = ",rates_total,
", prev_calculated = ",prev_calculated,
", IndiCounted() = ",ic,
", BminIC - BminPC =",BminIC-BminPC,
", newbar() = ",NewBar()
);
else
Print(" Bars = ",bars,
", rates_total = ",rates_total,
", prev_calculated = ",prev_calculated,
", IndiCounted() = ",ic,
", BminIC - BminPC =",BminIC-BminPC
);
if (BminIC-BminPC != 0) Print("*******************DIFFERENCE 1 ****************");
bool NewBar() {
static datetime lastbar;
datetime curbar = Time[0];
if(lastbar!=curbar) {
lastbar=curbar;
return (true);
}
else
return(false);
}
If your indicator uses a loop over bars that relies on either of the following:
loopcount = Bars-IndicatorCounted() [shorthand LC=B-IC] or
loopcount = rates_total-prev_calculated [shorthand LC=RT-PC]
you will notice that the behaviour is slightly different:
on Newbar: RT-PC = 1, and B-IC = 2
during bar: RT-PC = 0, and B-IC = 1.
Obviously, and dependent on your indicator code, when porting your code to the new v600 environment this difference in loopcount may have an impact on how and when your indicator gets updated!
Cheerio,
John