[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Holding the last bar's value.



PureBytes Links

Trading Reference Links

Keith,
Try first to avoid IIF [a simple multiplication is enough] and use 
Sig = 
(C > Ref(C,-1) AND V > Ref(V,-1))*1+
(C < Ref(C,-1) AND V < Ref(V,-1))*2;
Plot(ValueWhen(sig!=0,sig),"sig",1,8);
It will do what you want.

For comparison/verification paste in IB the 
Sig = 
(C > Ref(C,-1) AND V > Ref(V,-1))*1+
(C < Ref(C,-1) AND V < Ref(V,-1))*2;
Plot(ValueWhen(sig!=0,sig),"sig",colorBlack,8);
sig1=0;
Sig1 = 
IIf(C > Ref(C,-1) AND V > Ref(V,-1),1,
IIf(C < Ref(C,-1) AND V < Ref(V,-1),2,
Ref(Sig,-1)));Plot(sig1,"",colorRed,8);
I initialised your signal, called sig1 to be 0 when the conditions 
are not met [the red line].
The black line gives you what you ask.
Dimitris Tsokakis
--- In amibroker@xxxxxxxxxxxxxxx, "Keith Bennett" <kbennett@xxxx> 
wrote:
> 
> Could someone help with the following which I have been trying to 
> solve with AMA or HOLD without success.
> 
> Sig = 
> IIf(C > ref(C,-1) AND V > Ref(V,-1),1,
> IIF(C < Ref(C,-1) AND V < Ref(V,-1),2,
> Ref(Sig,-1)));
> 
> Of course the last line doesn't work due to the self reference :-(
> 
> If the first condition is met I want to return "1" , and if the 
> second condition is met I want to return "2". If neither condition 
is 
> met I want to retain the previuous value (daily bars).
> 
> Keith


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Free shipping on all inkjet cartridge & refill kit orders to US & Canada. Low prices up to 80% off. We have your brand: HP, Epson, Lexmark & more.
http://www.c1tracking.com/l.asp?cid=5510
http://us.click.yahoo.com/GHXcIA/n.WGAA/ySSFAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/