Rank: Member
Groups: Registered, Registered Users, Unverified Users Joined: 1/30/2012(UTC) Posts: 22 Location: Athens, Greece
|
First of all, I’ll try to describe the logic of my formula in a pseudo-code, as follows: IF Close crosses the Moving Avegare-26 Barssince ago THEN IF Barssince equals to zero THEN
do nothing
ELSE
Lookup for the FIRST time when the Close became greater than the Close Barssince ago IF the FIRST time occurs at the present bar THEN
Plot a signal ELSE
Do nothing because I already plotted the appropriate signal in a previous bar ENDIF ENDIF ENDIF The code I used till now is shown below :
Code:
bs26:=0;
Vclose26:=0;
bs26:=BarsSince(
(Cross(C,Mov(C,26,S))
AND
((C > Mov(C,50,S) AND C < Mov(C,200,S))
OR
(C < Mov(C,50,S) AND C > Mov(C,200,S))))
);
Vclose26:=ValueWhen(1,(Cross(C,Mov(C,26,S))
AND
((C > Mov(C,50,S) AND C < Mov(C,200,S))
OR
((C < Mov(C,50,S) AND C > Mov(C,200,S))))),C);
My real problem is that I did not find a appropriate function to detect the FIRST time the event occurred.
Also I have encountered two similar problems :
a. I can’t multiply a close by a decimal factor (e.g. close *1.05 produces an error
b. The SUM and the REF functions can’t accept a variable in the place of PERIOD parameter. Thanks a lot for your attention. [edited by wabbit : tags and readability, forum cutting off parts of the post [:(] )
|