Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
ed wrote:Indicator Code:
Pds := 14;
Offset := 1.7; {percent displacement}
HiBand := ExtFml( "ASI.BBandTop", C, Pds, offset);
LoBand := ExtFml( "ASI.BBandBot", C, Pds, offset);
MidBand:= Mov(C, Pds, E ) ;
HH5:= If(Cross(midband, Ref(L, -1)), 1,0 );
{Plot}
HH5;
ed
The code is correct, as far as I can see. What you have coded is for the variable to have a value of 1 when the midband (which is the Pds EMA) crosses up through the previous bar's low. In the green circle, this appears to be the case. On the 18th, the midband blue line is higher than the low of the blackbar on the 17th.
BTW..
I assume you intend doing more with this code, hence the existence of the Hiband and Loband variables, so I won't comment more on them, but the HH5 variable is more simply written, without changing the values as:
HH5:= Cross(midband, Ref(L, -1));
MS will return a Boolean TRUE (1) or FALSE (0) based on the algorithm, so it has the same value.
--
As an alternative to Cross, particularly for more complicated scenarios you might like to use a code more like:
x:= midband>Ref(L, -1);
x AND Alert(x=0,2);
which is a lot more flexible and extensible.
Hope this helps.
If you have any problems, just shout!
wabbit :
|