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

[amibroker] Jscript functions



PureBytes Links

Trading Reference Links

Tomasz - 

Ive found the reason for the logarithmic graphs being plotted from 
zero: the j-script function is returniung zero values.

So the problem isnt with the plotting, it seems that the new version 
doesnt like this j-script code and just returns zero for the whole 
array. I tested the same function on the previous version works fine.

Any ideas?

Andy

--- In amibroker@xxxxxxxxxxxxxxx, "andy_kovacs" <andy_kovacs@xxxx> 
wrote:
> Tomasz - 
> 
> Some time back someone posted an excelent piece of trailing stop 
> code "ATR BASED STOPS with JScript" which I have included in my 
> systems. In the tests I did, this code gave better results than 
the 
> in-built function, so I kept using it rather than re-coding using 
> the applystop function.
> 
> My default for graph display in preferences is Logarithmic, but I 
> dont actually draw the "price" indicator on the chart; I use plot
> (c,"Name of System: close=",colorblack,stylebar); This means I 
have 
> to tick the box "logarithmnic" in the gridlines part of the 
> indicator window to get a logarithmic display.
> 
> When the longstop and shortstop (the results of the java 
functions) 
> are plotted either side of the price, the graph is crammed right 
at 
> the top of the page and the scale starts from zero instead of some 
> value near the minimum of the price range. As the graphs before 
were 
> normal, I hadnt noticed, but Ive just tested a few codes and each 
> time I use the java trailing stop code the graph re-sets itself to 
> start from zero in both normal and logarithmic mode (as set in 
> indicator window, NOT preferences). 
> 
> When I edit out the plot(longstop,"etc........) and change the 
> indicator window back to normal (untick box) the graph is still 
> plotted from zero, but it looks fine. Just in log mode it squashes 
> up at the top of the page and becomes unusable. 
> 
> Is this normal? Am I doing something wrong somewhere or is it a 
> quirk of the program?
> 
> Heres the code for the stops, but I guess you already know it....
> 
> //********** ATR BASED STOPS with JScript *********//
> 
> EnableScript("jscript");
> 
> //first the raw stop functions are defined based on ATR-depending 
> distance to the close price
> 
> range = multiplier*ATR(Len);
> rawlongstop=C-range; //raw long stop
> rawshortstop=C+range; //raw short stop
> 
> //two JScript functions for the stops are defined
> <%
> //function for the longstop
> function f_longstop(rawstop,baseprice,Length){
> 
> //"importing" the AFL functions into JScript
> Len = AFL(Length);
> Ls=VBArray(AFL(rawstop)).toArray();
> bp = VBArray(AFL(baseprice)).toArray();
> 
> //the stop is calculated in the loop
> for(i=Len+1;i<Ls.length;i++){
> if(bp[i]>=Ls[i-1]){Ls[i]=Math.max(Ls[i],Ls[i-1]);}
> }
> 
> return Ls;
> }
> 
> //function for the shortstop
> function f_shortstop(rawstop,baseprice,Length){
> //"importing" the AFL functions into JScript
> Len = AFL(Length);
> Ss=VBArray(AFL(rawstop)).toArray();
> bp = VBArray(AFL(baseprice)).toArray();
> 
> //the stop is calculated in the loop
> for(i=Len+1;i<Ss.length;i++){
> if(bp[i]<=Ss[i-1]){Ss[i]=Math.min(Ss[i],Ss[i-1]);}
> }
> return Ss;
> }
> %>
> //*********** End of JScript *****************//
> 
> 
> Andy


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Make Money Online Auctions! Make $500.00 or We Will Give You Thirty Dollars for Trying!
http://us.click.yahoo.com/yMx78A/fNtFAA/i5gGAA/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/