metastock-like functions: barssince(), vauewhen() New comment Forex Trader 2006.04.13 13:53 ValueWhen maestrade 29.05.05 00:54 Suppose an event like : RSI crossed over 70. You want to know what the High was at that time. In Metastock, you would just write : ValueWhen(1,Cross(RSI,70),High) where 1 is the first occurence in the past The graphic representation of this indicator is : looping from i=0 to i=Bars if Cross(RSI,70) True Then Buffer = High Else Buffer[i] = Buffer[i+1] very easy to do in Excel just hell in metaquotes it's too unfortunate. who has a clue about this indicator ValueWhen ? Thanks barssince(), vauewhen() -------------------------------------------------------------------------------- metastock-like functions: since it costed me quite some time to figure out a self-made metastock-like function, I think it might be valuble for some people to have the function code. Therefore I decide to post the code here. barssince() function: int barsSince() { bool cond; //by suffic369, pancwk int bars=Bars; datetime prevtime=0; if( prevtime == Time[0]) return(0); prevtime = Time[0]; for (int i=0;i<=bars;i++) { if ( cond ) { int barPos=i; break; } } if (barPos<bars) return(barPos); else return(-1); } valuewhen(): if you know the bar position,it is easy to know the value of whatever you want. Help with CopyHigh Coding valuewhen() too short for an article - lol Multicurrency advisor. Preferably the opinion of the developers. New comment
ValueWhen
maestrade 29.05.05 00:54
Suppose an event like : RSI crossed over 70.
You want to know what the High was at that time.
In Metastock, you would just write :
ValueWhen(1,Cross(RSI,70),High)
where 1 is the first occurence in the past
The graphic representation of this indicator is :
looping from i=0 to i=Bars
if Cross(RSI,70) True Then Buffer = High
Else Buffer[i] = Buffer[i+1]
very easy to do in Excel
just hell in metaquotes
it's too unfortunate. who has a clue about this indicator ValueWhen ?
Thanks
barssince(), vauewhen()
--------------------------------------------------------------------------------
metastock-like functions:
since it costed me quite some time to figure out a self-made metastock-like function, I think it might be valuble for some people to have the function code. Therefore I decide to post the code here.
barssince() function:
int barsSince() { bool cond;
//by suffic369, pancwk
int bars=Bars;
datetime prevtime=0;
if( prevtime == Time[0]) return(0);
prevtime = Time[0];
for (int i=0;i<=bars;i++) {
if ( cond ) {
int barPos=i;
break;
}
}
if (barPos<bars) return(barPos);
else return(-1);
}
valuewhen(): if you know the bar position,it is easy to know the value of whatever you want.