[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

--- In amibroker@xxxxxxxxxxxxxxx, "Keith Bennett" <kbennett@xxxx> 
wrote:
> 
> Problem solved (I think) using FLIP.
> 
> FLIP(Sig==1,Sig==2);
> 
> Is this the best/only way to handle this type of problem?
> 
> Keith
> 
> 
> --- 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

Keith:
here is someting that Dimitris Tsokakis posted:

There are 3 different things here [with the respective AFL solutions]:
When a COND is true for many concecutive bars, we may ask 
a. To remember the value of an array from the last bar the COND was 
true, solved through Valuewhen(COND,array) or the equivalent 
AMA(array,COND)
b. To remember the value of an array from the first bar the COND was 
true, solved through Valuewhen(COND AND Ref(COND,-1)==0,array) or the 
equivalent AMA(array, COND AND Ref(COND,-1)==0)
c. To remember the value of an array exclusively from the [confirmed] 
last bar the COND was true, solved through 
Valuewhen(COND==0 AND Ref(COND,-1),Ref(array,-1)) or the equivalent 
AMA(Ref(array,-1), COND==0 AND Ref(COND,-1))


          Walt


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for Your HP, Epson, Canon or Lexmark
Printer at Myinks.com. Free s/h on orders $50 or more to the US & Canada. http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/sO0ANB/LIdGAA/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/