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

[amibroker] Translation code of H.E. Hurst Coefficient by Ehlers from TS to AM


  • Date: Tue, 16 Feb 2010 10:31:39 -0000
  • From: "cichy1235" <cichy1235@xxxxxxxx>
  • Subject: [amibroker] Translation code of H.E. Hurst Coefficient by Ehlers from TS to AM

PureBytes Links

Trading Reference Links

I need help with translation code of H.E. Hurst Coefficient by John Ehlers from Tradestation to Amibroker...

Original TS code is as follow:

Inputs:	
	Price((H+L)/2),
	Lookback(60);
			
Vars:
	I(0),
	N(0),
	count(0),
	N1(0),
	N2(0),
	N3(0),
	HH(0),
	LL(0),
	Dimen(0),
	Color1(0),
	Color2(0),
	Color3(0),
	PlotLen(0);

Arrays:
	H[190](0), H1[100](0), H2[100](0), H3[100](0), H4[100](0), HAvg[100](0);


For I = 1 to 50 Begin
	N = 2*I;
	N3 = (Highest(High, N) - Lowest(Low, N)) / N;
	HH = High;
	LL = Low;
	For count = 0 to N/2 - 1 begin
		If High[count] > HH then HH = High[count];
		If Low[count] < LL then LL = Low[count];
	End;
	N1 = (HH - LL)/(N / 2);
	HH = High[N/2];
	LL = Low[N/2];
	For count = N/2 to N - 1 begin
		If High[count] > HH then HH = High[count];
		If Low[count] < LL then LL = Low[count];
	End;
	N2 = (HH - LL)/(N / 2);

	If N1 > 0 and  N2 > 0 and N3 > 0 then Dimen = (Log(N1 + N2) - Log(N3)) / Log(2);
	H[N] = 2*(1 / Dimen - .5);
	H[N] = 1.25*(H[N] - .5) + .6;
	HAvg[N] = (H[N] + H1[N] + H2[N] + H3[N] + H4[N]) / 5;
	If HAvg[N] > 1 then HAvg[N] = 1;
	If HAvg[N] < 0 then HAvg[N] = 0;
	H4[N] = H3[N];
	H3[N] = H2[N];
	H2[N] = H1[N];
	H1[N] = H[N];
End;
For I = 2 to 50 Begin
	N = 2*I - 1;
	HAvg[N] = (HAvg[N - 1] + HAvg[N + 1]) / 2;
End;

//Plot the Rescale-range Statistic as a Heatmap
PlotLen = Lookback;
If Plotlen > 99 Then PlotLen = 99;		
For I = 8 to PlotLen Begin
	//Convert RS to RGB Color for Display
	If HAvg[I] >= .5 Then Begin
		Color1 = 255*(2 - 2*HAvg[I]);
		Color2 = 255*(2*HAvg[I] - 1);
		Color3 = 0;
	End
	Else If HAvg[I] < .5 Then Begin
		Color1 = 255*(2*HAvg[I]);
		Color2 = 0;
		Color3 = 255*(1 - 2*HAvg[I]);
	End;
	If I = 4 Then Plot4(4, "S4", RGB(Color1, Color2, Color3),0,4);
	If I = 5 Then Plot5(5, "S5", RGB(Color1, Color2, Color3),0,4);
	If I = 6 Then Plot6(6, "S6", RGB(Color1, Color2, Color3),0,4);
	If I = 7 Then Plot7(7, "S7", RGB(Color1, Color2, Color3),0,4);
	If I = 8 Then Plot8(8, "S8", RGB(Color1, Color2, Color3),0,4);
	If I = 9 Then Plot9(9, "S9", RGB(Color1, Color2, Color3),0,4);
	If I = 10 Then Plot10(10, "S10", RGB(Color1, Color2, Color3),0,4);
	If I = 11 Then Plot11(11, "S11", RGB(Color1, Color2, Color3),0,4);
	If I = 12 Then Plot12(12, "S12", RGB(Color1, Color2, Color3),0,4);
	If I = 13 Then Plot13(13, "S13", RGB(Color1, Color2, Color3),0,4);
	If I = 14 Then Plot14(14, "S14", RGB(Color1, Color2, Color3),0,4);
	If I = 15 Then Plot15(15, "S15", RGB(Color1, Color2, Color3),0,4);
	If I = 16 Then Plot16(16, "S16", RGB(Color1, Color2, Color3),0,4);
	If I = 17 Then Plot17(17, "S17", RGB(Color1, Color2, Color3),0,4);
	If I = 18 Then Plot18(18, "S18", RGB(Color1, Color2, Color3),0,4);
	If I = 19 Then Plot19(19, "S19", RGB(Color1, Color2, Color3),0,4);
	If I = 20 Then Plot20(20, "S20", RGB(Color1, Color2, Color3),0,4);
	If I = 21 Then Plot21(21, "S21", RGB(Color1, Color2, Color3),0,4);
	If I = 22 Then Plot22(22, "S22", RGB(Color1, Color2, Color3),0,4);
	If I = 23 Then Plot23(23, "S23", RGB(Color1, Color2, Color3),0,4);
	If I = 24 Then Plot24(24, "S24", RGB(Color1, Color2, Color3),0,4);
	If I = 25 Then Plot25(25, "S25", RGB(Color1, Color2, Color3),0,4);
	If I = 26 Then Plot26(26, "S26", RGB(Color1, Color2, Color3),0,4);
	If I = 27 Then Plot27(27, "S27", RGB(Color1, Color2, Color3),0,4);
	If I = 28 Then Plot28(28, "S28", RGB(Color1, Color2, Color3),0,4);
	If I = 29 Then Plot29(29, "S29", RGB(Color1, Color2, Color3),0,4);
	If I = 30 Then Plot30(30, "S30", RGB(Color1, Color2, Color3),0,4);
	If I = 31 Then Plot31(31, "S31", RGB(Color1, Color2, Color3),0,4);
	If I = 32 Then Plot32(32, "S32", RGB(Color1, Color2, Color3),0,4);
	If I = 33 Then Plot33(33, "S33", RGB(Color1, Color2, Color3),0,4);
	If I = 34 Then Plot34(34, "S34", RGB(Color1, Color2, Color3),0,4);
	If I = 35 Then Plot35(35, "S35", RGB(Color1, Color2, Color3),0,4);
	If I = 36 Then Plot36(36, "S36", RGB(Color1, Color2, Color3),0,4);
	If I = 37 Then Plot37(37, "S37", RGB(Color1, Color2, Color3),0,4);
	If I = 38 Then Plot38(38, "S38", RGB(Color1, Color2, Color3),0,4);
	If I = 39 Then Plot39(39, "S39", RGB(Color1, Color2, Color3),0,4);
	If I = 40 Then Plot40(40, "S40", RGB(Color1, Color2, Color3),0,4);
	If I = 41 Then Plot41(41, "S41", RGB(Color1, Color2, Color3),0,4);
	If I = 42 Then Plot42(42, "S42", RGB(Color1, Color2, Color3),0,4);
	If I = 43 Then Plot43(43, "S43", RGB(Color1, Color2, Color3),0,4);
	If I = 44 Then Plot44(44, "S44", RGB(Color1, Color2, Color3),0,4);
	If I = 45 Then Plot45(45, "S45", RGB(Color1, Color2, Color3),0,4);
	If I = 46 Then Plot46(46, "S46", RGB(Color1, Color2, Color3),0,4);
	If I = 47 Then Plot47(47, "S47", RGB(Color1, Color2, Color3),0,4);
	If I = 48 Then Plot48(48, "S48", RGB(Color1, Color2, Color3),0,4);
	If I = 49 Then Plot49(49, "S49", RGB(Color1, Color2, Color3),0,4);
	If I = 50 Then Plot50(50, "S50", RGB(Color1, Color2, Color3),0,4);
	If I = 51 Then Plot51(51, "S41", RGB(Color1, Color2, Color3),0,4);
	If I = 52 Then Plot52(52, "S42", RGB(Color1, Color2, Color3),0,4);
	If I = 53 Then Plot53(53, "S43", RGB(Color1, Color2, Color3),0,4);
	If I = 54 Then Plot54(54, "S44", RGB(Color1, Color2, Color3),0,4);
	If I = 55 Then Plot55(55, "S45", RGB(Color1, Color2, Color3),0,4);
	If I = 56 Then Plot56(56, "S46", RGB(Color1, Color2, Color3),0,4);
	If I = 57 Then Plot57(57, "S47", RGB(Color1, Color2, Color3),0,4);
	If I = 58 Then Plot58(58, "S48", RGB(Color1, Color2, Color3),0,4);
	If I = 59 Then Plot59(59, "S49", RGB(Color1, Color2, Color3),0,4);
	If I = 60 Then Plot60(60, "S50", RGB(Color1, Color2, Color3),0,4);
	If I = 61 Then Plot61(61, "S41", RGB(Color1, Color2, Color3),0,4);
	If I = 62 Then Plot62(62, "S42", RGB(Color1, Color2, Color3),0,4);
	If I = 63 Then Plot63(63, "S43", RGB(Color1, Color2, Color3),0,4);
	If I = 64 Then Plot64(64, "S44", RGB(Color1, Color2, Color3),0,4);
	If I = 65 Then Plot65(65, "S45", RGB(Color1, Color2, Color3),0,4);
	If I = 66 Then Plot66(66, "S46", RGB(Color1, Color2, Color3),0,4);
	If I = 67 Then Plot67(67, "S47", RGB(Color1, Color2, Color3),0,4);
	If I = 68 Then Plot68(68, "S48", RGB(Color1, Color2, Color3),0,4);
	If I = 69 Then Plot69(69, "S49", RGB(Color1, Color2, Color3),0,4);
	If I = 70 Then Plot70(70, "S50", RGB(Color1, Color2, Color3),0,4);
	If I = 71 Then Plot71(71, "S41", RGB(Color1, Color2, Color3),0,4);
	If I = 72 Then Plot72(72, "S42", RGB(Color1, Color2, Color3),0,4);
	If I = 73 Then Plot73(73, "S43", RGB(Color1, Color2, Color3),0,4);
	If I = 74 Then Plot74(74, "S44", RGB(Color1, Color2, Color3),0,4);
	If I = 75 Then Plot75(75, "S45", RGB(Color1, Color2, Color3),0,4);
	If I = 76 Then Plot76(76, "S46", RGB(Color1, Color2, Color3),0,4);
	If I = 77 Then Plot77(77, "S47", RGB(Color1, Color2, Color3),0,4);
	If I = 78 Then Plot78(78, "S48", RGB(Color1, Color2, Color3),0,4);
	If I = 79 Then Plot79(79, "S49", RGB(Color1, Color2, Color3),0,4);
	If I = 80 Then Plot80(80, "S50", RGB(Color1, Color2, Color3),0,4);
	If I = 81 Then Plot81(81, "S41", RGB(Color1, Color2, Color3),0,4);
	If I = 82 Then Plot82(82, "S42", RGB(Color1, Color2, Color3),0,4);
	If I = 83 Then Plot83(83, "S43", RGB(Color1, Color2, Color3),0,4);
	If I = 84 Then Plot84(84, "S44", RGB(Color1, Color2, Color3),0,4);
	If I = 85 Then Plot85(85, "S45", RGB(Color1, Color2, Color3),0,4);
	If I = 86 Then Plot86(86, "S46", RGB(Color1, Color2, Color3),0,4);
	If I = 87 Then Plot87(87, "S47", RGB(Color1, Color2, Color3),0,4);
	If I = 88 Then Plot88(88, "S48", RGB(Color1, Color2, Color3),0,4);
	If I = 89 Then Plot89(89, "S49", RGB(Color1, Color2, Color3),0,4);
	If I = 90 Then Plot90(90, "S50", RGB(Color1, Color2, Color3),0,4);
	If I = 91 Then Plot91(91, "S41", RGB(Color1, Color2, Color3),0,4);
	If I = 92 Then Plot92(92, "S42", RGB(Color1, Color2, Color3),0,4);
	If I = 93 Then Plot93(93, "S43", RGB(Color1, Color2, Color3),0,4);
	If I = 94 Then Plot94(94, "S44", RGB(Color1, Color2, Color3),0,4);
	If I = 95 Then Plot95(95, "S45", RGB(Color1, Color2, Color3),0,4);
	If I = 96 Then Plot96(96, "S46", RGB(Color1, Color2, Color3),0,4);
	If I = 97 Then Plot97(97, "S47", RGB(Color1, Color2, Color3),0,4);
	If I = 98 Then Plot98(98, "S48", RGB(Color1, Color2, Color3),0,4);
	If I = 99 Then Plot99(99, "S49", RGB(Color1, Color2, Color3),0,4);

End;




------------------------------------

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

<*> 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:
    amibroker-digest@xxxxxxxxxxxxxxx 
    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/