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

[amibroker] Re: using AMA



PureBytes Links

Trading Reference Links

Can someone tell me how to modify the formula below such that y 
equals the buy date

--- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <amibroker@xxx> 
wrote:
>
> Hello,
> 
> By the way here is entire formula
> 
> 
> 
> y= DateNum()==1021004;
> Fill=6.5;/* fillprice*/
> Mult=0.05;/*atr multiplier*/
> 
> Bars=Cum(y);
> Accel=Bars*Mult;
> Ratchet=LLV(Low,10)+(Accel*ATR(5));
> ATRSTOP=ValueWhen(Bars==1,LLV(C- (3*ATR(10)),10));
> Profit=Close>=Fill+ATR(5) OR Close>=Fill+(Fill*.05);
> 
> //ATRRATCHET=If(profit=1, If(Ratchet<PREV,PREV,Ratchet), If(Bars>1 
AND ATRSTOP<PREV,PREV,ATRSTOP));
> ATRRATCHET = Highest( ( Profit == 1 ) * Ratchet + ( Profit == 0 ) * 
ATRSTOP );
> 
> X=HighestSince(Bars==1,ATRRATCHET);
> Plot(x,"atr Rachet",colorRed,styleLine);
> Plot(C,"close",colorBlue,styleLine);
> 
> 
> Best regards,
> Tomasz Janeczko
> amibroker.com
> 
>   ----- Original Message ----- 
>   From: Tomasz Janeczko 
>   To: amibroker@xxxxxxxxxxxxxxx 
>   Sent: Wednesday, January 08, 2003 9:32 PM
>   Subject: Re: [amibroker] using AMA
> 
> 
>   Hello,
> 
> 
>   This code is an excellent sample of what I call "brute force 
programming".
> 
> 
>   ATRRATCHET:=If(profit=1,  If(Ratchet<PREV,PREV, Ratchet), { first 
part }
>                                              If(Bars>1 AND 
ATRSTOP<PREV,PREV,ATRSTOP) { second part } );
> 
>   We can of course translate it directly using VBScript/ JScript 
but... is it really needed ?
> 
> 
>   Instead of trying to translate such ugly PREV statement one 
should first thing what this statement
>   is trying to achieve.
> 
>   There are two parts of this statement:
>   one that is taken when profit equals 1 and and the "otherwise" 
case.
> 
>   The first part does simple thing: it calculates running Highest 
value of ratchet : simply:
>   Highest( Ratchet )
> 
>   the second part does basically the same but only when Bars 
variable is greater than one so:
> 
>   HighestSince( Bars <= 1, ATRStop )
> 
> 
>   Now entire formula gets the highest of one of the above depending 
on profit variable so we can write it so
> 
>   ATRRATCHET = IIf( profit == 1, Highest( Ratchet ), HighestSince( 
Bars <= 1, ATRSTOP ) );
> 
>   The problem is that it works almost correct however it does not 
match perfectly the formula using PREV.
> 
>   THe formula that matches looks even easier :-)
> 
>   ATRRATCHET = Highest( ( Profit == 1 ) * Ratchet + ( Profit == 0 ) 
* ATRSTOP );
> 
>   Only one function call to Highest ! 
> 
>   Best regards,
>   Tomasz Janeczko
>   amibroker.com
>     ----- Original Message ----- 
>     From: Jayson 
>     To: amibroker@xxxxxxxxxxxxxxx 
>     Sent: Wednesday, January 08, 2003 2:57 AM
>     Subject: RE: [amibroker] using AMA
> 
> 
>     Bob,
>     I just so happen to have some old MS code :))
> 
>     ATR Rachtet Ms
>     TYear:=Input("Enter Year",1990,2010,2002);
>     TMonth:=Input("Enter Month",1,12,1);
>     TDay:=Input("Enter day of month",1,31,1);
>     Fill:=Input("Enter Fill Price",0,100,1);
>     Mult:=Input("Daily ATR Multiplier",0,10,.05);
>     Bars:=Cum(Cum(Year()=tyear AND Month()=tmonth AND DayOfMonth()
=tday));
>     Accel:=Bars*Mult;
>     Ratchet:=LLV(LOW,10)+(Accel*ATR(5));
>     ATRSTOP:=ValueWhen(1,Bars=1,LLV(C- (3*ATR(10)),10));
>     Profit:=CLOSE>=Fill+ATR(5) OR CLOSE>=Fill+(Fill*.05);
> 
>     ATRRATCHET:=If(profit=1, If(Ratchet<PREV,PREV,
>     Ratchet), If(Bars>1 AND ATRSTOP<PREV,PREV,ATRSTOP));
> 
>     HighestSince(1,Bars=1,ATRRATCHET)
> 
>     I have no problem making the translation right up to the 
ATRRATchet variable. As I read it the 2nd IIF statement is 
referencing  ref(atrratchet,-1).......
> 
>     As fred mentioned it may be a case where vbscript is the quick 
solution but if truth be told I was am really more interested in 
learning a bit more about how ama works and an afl solution to PREV 
than in the indicator its self. 
> 
>     thanks for your input,
> 
>     Jayson 
>     -----Original Message---
>     From: Bob Jagow [mailto:bjagow@...]
>     Sent: Tuesday, January 07, 2003 7:07 PM
>     To: amibroker@xxxxxxxxxxxxxxx
>     Subject: RE: [amibroker] using AMA
> 
> 
>     "Ref of atrratchet" or ref of Ratchet and ref of ATRSTOP?
> 
>     I seem to recall that some old MS code wastefully used PREV in 
place of REF and thought that might be the case here.
> 
>     Bob
>       -----Original Message-----
>       From: Jayson [mailto:jcasavant@...]
>       Sent: Tuesday, January 07, 2003 3:33 PM
>       To: amibroker@xxxxxxxxxxxxxxx
>       Subject: RE: [amibroker] using AMA
> 
> 
>       NO bob that is the rub. The formula calls for the ref of 
atrratchet but since atrratchet is not yet defined the variable 
cannot look to its previous (prev) value. This is somewhat similar to 
what is done in an EMA which I recall Tomasz as saying could be 
reproduced in afl with AMA. I just need to go back through the 
archives to find his post. Thanks for offering your thought though :))
> 
>       Jayson 
>       -----Original Message-----
>       From: Bob Jagow [mailto:bjagow@...]
>       Sent: Tuesday, January 07, 2003 5:57 PM
>       To: amibroker@xxxxxxxxxxxxxxx
>       Subject: RE: [amibroker] using AMA
> 
> 
>       Jason,
>       would ref work? 
> 
>       If ATRRATCHET=Iif(profit==1, Iif(Ratchet<PREV,PREV,Ratchet), 
Iif(Bars>1 AND ATRSTOP<PREV,PREV,ATRSTOP));
>         Note                  ^
> 
>       Bob
>        
> 
>                            ^
> 
>         -----Original Message-----
>         From: Jayson [mailto:jcasavant@...]
>         Sent: Tuesday, January 07, 2003 9:59 AM
>         To: amibroker@xxxxxxxxxxxxxxx
>         Subject: RE: [amibroker] using AMA
> 
> 
>         Al,
>         thanks for sharing! My idea was a bit different and 
requires self referencing of a variable. I know this can be done with 
AMA/AMA2 but it is just not clicking with my brain. I will look at it 
this evening when I am not trying to follow my screens as well. I 
will keep you posted with my result. thanks again
> 
>         Jayson 
>         -----Original Message-----
>         From: Avcinci [mailto:avcinci@...]
>         Sent: Tuesday, January 07, 2003 12:41 PM
>         To: amibroker@xxxxxxxxxxxxxxx
>         Subject: Re: [amibroker] using AMA
> 
> 
>         Jayson, 
> 
>         About a year ago, Anthony and I were discussing how to code 
the Ratchet exit of Chuck LeBeau's. I haven't done much with it since 
then, but here is the formula we came up with then (it was mostly 
Anthony's coding; I just went along for the ride!!). I think it 
probably needs Stephane's RemBuy.dll since the buyprice does not 
remain fixed. But, it may give you some clues and pointers to try. 
Let me know how it works out. 
> 
>         Al Venosa
>           ----- Original Message ----- 
>           From: Jayson 
>           To: 1ami 
>           Sent: Tuesday, January 07, 2003 12:13 PM
>           Subject: [amibroker] using AMA
> 
> 
>           I know this has been discussed in regards to the EMA but 
I cannot seem to get my brain around the concept. I am trying to 
convert Chuck Lebeaus ATR Ratchet from another programming lang. I am 
stumped at this line ....
> 
>           ATRRATCHET=Iif(profit=1, Iif(Ratchet<PREV,PREV,Ratchet), 
Iif(Bars>1 AND ATRSTOP<PREV,PREV,ATRSTOP));
> 
>           I seem to recall that AMA/AMA2 can be used in place of 
prev but cannot seem to figure out how to do this. If any one can 
give me a nudge in the right direction I would appreciate it.
> 
>           regards,
> 
>           Jayson 
> 
> 
> 
>           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 the Yahoo! Terms 
of Service. 
> 
> 
> 
>         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 the Yahoo! Terms of 
Service. 
> 
> 
>         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 the Yahoo! Terms of 
Service. 
> 
> 
> 
>       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 the Yahoo! Terms of 
Service. 
> 
> 
>       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 the Yahoo! Terms of 
Service. 
> 
> 
> 
>     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 the Yahoo! Terms of 
Service. 
> 
> 
>     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 the Yahoo! Terms of 
Service. 
> 
> 
>         Yahoo! Groups Sponsor 
>               ADVERTISEMENT
>                 
>        
>        
> 
>   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 the Yahoo! Terms of 
Service.
>




Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

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