indicator Camarilla_Points voor WHS
_________________________________________________________________________________
indicator Camarilla_Points;
input
StartHour = 2; /* hour of start of day*/
draw H5("H5"), H4("H4"), H3("H3"), PP("PP"),
L3("L3"), L4("L4"), L5("L5");
vars i(number), /* index */
lst(number), fst(number), /* index of first and last items in the data set*/
Whigh(number), Wlow(number), /* Working H&L */
Lhigh(number), Llow(number), Lclose(number), /* Last HLC used for calc PP */
i1ststart(number), /*index of start of first whole day*/
i2ndstart(number), /*index of start of second whole day*/
daycount(number), /* used to find first 2 days */
L_PP(number), L_H5(number), L_H4(number), L_H3(number), L_L5(number), L_L4(number), L_L3(number),
D1 (number), D2 (number), D3 (number), D4 (number);
begin
/* init Variables*/
D1:=0.091667;
D2:=0.183333;
D3:=0.2750;
D4:=0.55;
lst := back(close);
fst := front(close);
daycount := 0;
if lst < fst then
return; /* exit on erroneous data */
/* Scan array, find 1st and 2nd days. Ignore first partial day*/
for i:= fst to lst do begin
if (hour(timestamp[i]) = starthour) and (minute(timestamp[i]) = 0) then begin /* look for start of day based on input starting hour */
daycount := daycount + 1; /* start counting at begin of first day */
if daycount = 1 then begin /* do only at begin of first day after we have skipped partial day's data */
i1ststart := i; /*found index of first day */
Whigh := high[i]; /*Change working HL to current HL at start of first day */
Wlow := low[i];
end;
if daycount = 2 then i2ndstart := i; /*found index of start of second day */
end;
if daycount = 1 then begin /* find HL of first whole day */
if high[i] > Whigh then Whigh := high[i];
if low[i] < Wlow then Wlow := low[i];
end;
end;
if daycount < 2 then return; /* if not at least 2 days of data started then exit */
/*Main routine*/
for i := i1ststart to lst do begin /*starts plotting only at start of second whole day */
if hour(timestamp[i]) = starthour and minute(timestamp[i]) = 0 then begin
Lhigh := Whigh; /* if we are at the begin of a new day then change HLC and recalculate Pivots */
Llow := Wlow;
Lclose := close[i-1];
Whigh := high[i]; /*Change working HL to current HL at start of day */
Wlow := low[i];
L_PP := (Lhigh + Llow + Lclose) / 3; /* Calculate PP based on yesterday's HLC*/
L_H5 := ((Lhigh / Llow) * Lclose);
L_H4 := ((Lhigh – Llow) * D4) + lclose;
L_H3 := ((Lhigh – Llow) * D3) + lclose;
L_L5 := Lclose – (L_H5 – Lclose);
L_L4 := Lclose – ((Lhigh – Llow) * D4);
L_L3 := Lclose – ((Lhigh – Llow) * D3);
end;
PP[i] := L_PP;
H5[i] := L_H5;
H4[i] := L_H4;
H3[i] := L_H3;
L5[i] := L_L5;
L4[i] := L_L4;
L3[i] := L_L3;
if high[i] > Whigh then Whigh := high[i]; /* check for HL on current day, used for tomorrow's Pivot calculations */
if low[i] < Wlow then Wlow := low[i];
end;
end.