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

[amibroker] Re: StDev, StdError and ATR



PureBytes Links

Trading Reference Links

Hi David,

I haven't had a chance to fun your code yet, but I did want to let 
you know that I wrote some code for identifying swing highs and lows 
and uploaded it to the AFL library. Part of the code was setting up 
arrays that held the barindex of the pivots as well as the prices, 
making it easy to determine the number of bars and pct. change 
between pivots. You'll find it under "Gordon Rose" since, when the 
dialog box for adding the code asked for a name, I dutifully entered 
mine instead of that of the function!

There is also a DLL that has a number of pivot-related routines in 
it. I believe that is in the files section of this bbs.

Good luck.

Gordon

--- In amibroker@xxxxxxxxxxxxxxx, "dsagerstrand" <dsagerstrand@xxxx> 
wrote:
> Hi,
> 
> I'm attempting to write some code to identify and chart swing highs 
> and swing lows.  Basically, I'm defining these highs and lows the 
> same way the ZigZag function defines Peaks and Troughs, but with 
the 
> following exceptions:
> 
> (a) I want to measure change in points rather than as a percentage, 
> and
> 
> (b) I want to be able to measure from Highs to Lows, rather than 
just 
> Highs to Highs, Lows to Lows, Closes to Closes, or Opens to Opens.
> 
> Before I make these modifications however, I've been trying to 
mimic 
> the existing Peak and Trough AFL functions.  I first wrote the 
> following code as a comparative study to identify Peaks and Troughs 
> as AFL defines them (marking Peaks green and Troughs red on a 
> candlestick chart).
> 
> Plot(C,"Close",IIf(PeakBars(C,5,1)==0,colorGreen,IIf(TroughBars
(C,5,1)
> ==0,colorRed,colorBlack)),styleCandle);
> 
> I then set about writing code to mimic this, but without using the 
> Zig, Peak, or Trough AFL functions.  Initially I thought about 
using 
> the BarsSince function to determine whether the price retraced the 
> specified percentage on either side of the potential Peak or Trough 
> before being taken out.  For example, a Peak formed by the Zig(C,5) 
> function would have to have a close on either side which was 5% 
below 
> the close of the Peak before price closed above the peak.  However, 
> the BarsSince function does not seem to accomodate this, as you 
can't 
> compare the closes of two different bars (unless you use the Ref 
> function in which case you would have to know the exact bars you 
were 
> comparing).
> 
> At any rate, I finally came up with the following code for 
> identifying peaks, but it is generating errors (presumably because 
it 
> is choking on the BarIndex() function calls in the for loops):
> 
> function pH( ARRAY, pctChange )
> {
>     threshold = ARRAY * (1-(pctChange/100)); // price that must be 
> retraced to confirm peak
>     bH = False; // flag = true when peak is confirmed
> 
>     // Check price to left of potential peak
>     for (i=BarIndex()-1; i>=0 AND bH==False AND ARRAY[i]<=ARRAY
> [BarIndex()]; i--)
>     {
>         if (ARRAY[i] <= threshold)
>         {
>             // Check price to right of potential peak
>             for (j=BarIndex()+1; j<=BarCount AND bH==False AND ARRAY
> [j]<=ARRAY[BarIndex()]; j++)
>             {
>                 if (ARRAY[j] <= threshold)
>                 {
>                     bH=True;
>                 }
>             }
>         }
>     }
>     return bH;
> }
> 
> Plot(C,"Close",IIf(pH(C,5),colorGreen,colorBlack),styleCandle);
> 
> Does anyone have any suggestions?  At this point I'm pretty much 
> stumped and would welcome any help.
> 
> Thanks,
> David



------------------------ 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/mOAaAA/3exGAA/qnsNAA/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 
Yahoo! Groups Links

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

<*> 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/