Interesting Formula!
Well done at attempting to convert it.
I see a couple of issues with what you've posted:
[color=darkblue:74f51a2c41][size=18:74f51a2c41]1. There are too many variables declared.[/size:74f51a2c41][/color]
E.G. "NBLH:=BLH-BBH;"
Unfortunately, Metastock currently only supports 20 variables per formula (or more precisely, per indicator). That means you should only see ":=" 20 times or less. One important thing to be aware of is if you have called (referenced) a variable within the definition of another variable, the variable being called (or 'looked up') must appear above the one that is calling it.
E.G.
This is wrong:
MyMA:=Mov(C,per,E);
per:=Input("Periods",1,300,13);
MyMA;
This is right:
per:=Input("Periods",1,300,13);
MyMA:=Mov(C,per,E);
MyMA;
WHY? Because Metastock evaluates formulae from top down, just as you read it.
In the first example, 'MyMA' is looking for the value of 'per', but Metastock does not know it yet because it is further down the list of things to calculate.
Whereas in the second example, 'per' has already been calculated and stored, so when Metastock tries to evaluate 'MyMA', it already has all the input values necessary to calculate the result.
[color=darkblue:74f51a2c41][size=18:74f51a2c41]2. A few plots (individual formulae) look syntactically incorrect.[/size:74f51a2c41][/color]
E.G.
i=barssince(BLH);
j=barssince(BBC);
Unlike Excel, Metastock cannot take letters as input for formulae UNLESS you are doing it in an external DLL or an ODBC linked spreadsheet.
I can see that 'i' and 'j' are declared further down, which relates to issue 1 above. But regarding the following piece:
countback2=j-i
DRPV:= sum(
if(Ref(C,i*-1) <Ref(i+1)*-1),
Ref(V,i*-1) * ( Ref(C,(i+1)*-1) - Ref(C,(i*-1)) ),
DRPV) , countback);
you should know that Metastock removes all line breaks when calculating a formula. What this means is this:
countback2=j-i {line break}
DRPV:= sum( {line break}
if(Ref(C,i*-1) <Ref(i+1)*-1), {line break}
Ref(V,i*-1) * ( Ref(C,(i+1)*-1) - Ref(C,(i*-1)) ), {line break}
DRPV) , countback);
- BECOMES -
"countback2=j-i DRPV:= sum( if(Ref(C,i*...etc...;" - i.e. Metastock sees it as all on one line, and you can clearly see that 'countback2=j-i DRPV:=' is incorrect in Metastock's view.
One more example:
"URPV=DRPV=0;"
I am not sure exactly how Metastock would evaluate this one, but my guess is that if it did not return a syntax error of some sort, it would evaluate it like this:
" If URPV equals DRPV and DRPV equals 0 {meaning both variables equal zero at the current bar}, then return TRUE, else return FALSE" - i.e. return the value '1' if true or 0 if false.
When Metastock is faced with a logical or 'Boolean' formula that evaluates to a TRUE or FALSE condition, it returns '1' for TRUE and '0' for FALSE as stated above.
But I would expect this one to fail due to incorrect syntax.
I hope this helps you. When you have a successfully working Cup and Handle formula, please let me know!
Kind Regards,
Steve/skeetabomb.