http://www.amibroker.com/bin/UsersGuide.pdf ----- Original Message ----- From: elmi...@gmail.com To: amibroker@yahoogroups.com Sent: April 25, 2010 9:45 PM Subject: Re: [amibroker] Re: How to backtest or plot a script, which usesSelectedValue or LastValue?
Dear Tomasz, how can I download the manual user of amibroker completly, because I plan to print it for myself.. So I can learn easily how to use amibroker software Rgds, Elmi Powered by Telkomsel BlackBerry® ------------------------------------------------------------------------------ From: Tomasz Janeczko <gro...@amibroker.com> Date: Mon, 26 Apr 2010 03:29:23 +0200 To: <amibroker@yahoogroups.com> Subject: Re: [amibroker] Re: How to backtest or plot a script, which uses SelectedValue or LastValue? Hello, Clearly you did not read the manual of Wealth-Lab carefully enough. check page 240 of their manual and you will read the following: "The Peak function never "looks ahead" in time, but always returns the Peak value as it would have been determined as of the specified bar. For this reason, the return value of the Peak function will lag, and report peaks a few bars later than they actually occurred in hindsight." What they are trying to say is that the peak function DOES look into the future but they internally DELAY the output of their Peak so the last leg of minimum percentage is formed. Such delay makes it unprofitable but well... that is not mentioned in their manual. AmiBroker does NOT delay the Peak output as the primary purpose of Peak/Trough and all Zig-zag family is PATTERN detection and not trading systems. It makes sense to have delay-free Peak because DELAYED Peak function can not be "undelayed" back. It is possible and quite easy in fact to create "WL-style" delayed peak by simply delaying AFL's Peak/Trough/Zig zag and it is presented in detail here: http://www.amibroker.com/members/traders/11-2003.html (for more details about that see ZigZag Trend Indicator in Nov 2003 issue of Stocks&Commodities) Best regards, Tomasz Janeczko amibroker.com On 2010-04-26 01:43, jhnlmn wrote: Thank you for your response. In essence, you are saying that I cannot use Tsokakis example (and many others from the Amibroker and Metastock libraries) without a significant rewriting. I am new to Amibroker. I was looking for a good trendline recognition script and stumbled on Amibroker. So, I downloaded a trial version to quickly test these scripts. So, I need to decide whether it is worse the effort to rewrite these scripts for Amibroker or go back to Wealth-Lab, which I was using before. I am surprised that PeakBars and TroughBars are looking into the future in Amibroker. It is not the case in WL. These are pretty simple functions - they just need to find min or max before a reversal. Why would Amibroker look into the future in this case? Now about replacing SelectedValue/LastValue. I tried to fix "Historical Trendlines and Breakouts" script by wrapping part of the script in for(i = 0; i < BarCount; i++) loop and then replacing: ... pS = TroughBars( s1, per, 1 ) == 0; endt=SelectedValue(ValueWhen( pS, x ,1)); startt=SelectedValue(ValueWhen( pS, x ,2)); dtS =endt-startt; endS = SelectedValue((ValueWhen( pS, s1,1) )); startS = SelectedValue(( ValueWhen( pS, s1 ,2))); aS = (endS-startS)/dtS;bS = endS; trendlineS = aS * ( x -endt ) + bS;//SUPPORT LINE ... Plot(IIf(x>=first -d AND x<=Last+d,trendlineS,- 1e10),"Support",colorBrightGreen,1); by pS = TroughBars( s1, per, 1 ) == 0; troughBarIdxLast = ValueWhen( pS, x ,1); troughBarIdxBeforeLast = ValueWhen( pS, x ,2); troughBarValueLast = ValueWhen( pS, s1, 1); troughBarValueBeforeLast = ValueWhen( pS, s1, 2); ... for(i = startBar; i < lastBar; i++) { endt= troughBarIdxLast[i]; startt = troughBarIdxBeforeLast[i]; if(prevEndTrendlineS != endt) { prevEndTrendlineS = endt; dtS = endt - startt; endS = troughBarValueLast[i]; startS = troughBarValueBeforeLast[i]; aS = (endS - startS) / dtS; bS = endS; trendlineS = aS * ( x - endt ) + bS;//SUPPORT LINE Plot(IIf(x >= startt - d AND x <= endt + d, trendlineS, -1e10), "Support", colorBrightGreen, 1); } ... } Is it the right approach to rewriting SelectedValue or LastValue scripts for a continuous drawing or backtesting? (Below is the entire rewritten script). Thank you John x = Cum(1); per = 3;// CALIBRATE THE ZIG() SENSITIVITY s1=L; s11=H; pS = TroughBars( s1, per, 1 ) == 0; troughBarIdxLast = ValueWhen( pS, x ,1); troughBarIdxBeforeLast = ValueWhen( pS, x ,2); troughBarValueLast = ValueWhen( pS, s1, 1); troughBarValueBeforeLast = ValueWhen( pS, s1, 2); pR = PeakBars( s11, per, 1 ) == 0; peakBarIdxLast = ValueWhen( pR, x, 1); peakBarIdxBeforeLast = ValueWhen( pR, x, 2); peakBarValueLast = ValueWhen( pR, s11, 1); peakBarValueBeforeLast = ValueWhen( pR, s11, 2); startBar = Status("FirstVisibleBar"); lastBar = Status("LastVisibleBar"); _TRACE("Startbar:"+startBar); _TRACE("Lastbar:"+lastBar); prevEndTrendlineS = -1; prevEndTrendlineR = -1; d=10;// INCREASE d TO EXTEND THE LINES Years=Year(); Months=Month(); Days=Day(); //color = for(i = startBar; i < lastBar; i++) { color[i] = colorBlack; } for(i = startBar; i < lastBar; i++) { endt= troughBarIdxLast[i]; startt = troughBarIdxBeforeLast[i]; if(prevEndTrendlineS != endt) { prevEndTrendlineS = endt; dtS = endt - startt; endS = troughBarValueLast[i]; startS = troughBarValueBeforeLast[i]; aS = (endS - startS) / dtS; bS = endS; trendlineS = aS * ( x - endt ) + bS;//SUPPORT LINE bearishbreakout = x > endt AND x < endt + d AND Cross(trendlineS, C); color = IIf (bearishbreakout,colorRed,color); Plot(IIf(x >= startt - d AND x <= endt + d, trendlineS, -1e10), "Support", colorBrightGreen, 1); } endt1 = peakBarIdxLast[i]; startt1 = peakBarIdxBeforeLast[i]; if(prevEndTrendlineR != endt1) { prevEndTrendlineR = endt1; dtR =endt1-startt1; endR = peakBarValueLast[i]; startR = peakBarValueBeforeLast[i]; aR = (endR-startR)/dtR; bR = endR; trendlineR = aR * ( x -endt1 ) + bR;//RESISTANCE LINE bullishbreakout = x > endt1 AND x < endt1 + d AND Cross(C,trendlineR); color = IIf (bullishbreakout,colorGreen,color); Plot(IIf(x >= startt1 - d AND x <= endt1 + d, trendlineR, -1e10), "Resistance", colorRed, 1); } }// for(i = startBar; i < lastBar; i++) Plot(C,"Close",color,64); ------------------------------------ **** IMPORTANT PLEASE READ **** This group is for the discussion between users only. This is *NOT* technical support channel. TO GET TECHNICAL SUPPORT send an e-mail directly to SUPPORT {at} amibroker.com TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at http://www.amibroker.com/feedback/ (submissions sent via other channels won't be considered) For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG: http://www.amibroker.com/devlog/ Yahoo! Groups Links