# P_F Algorithm INPUTS Accept box_size_ reversal_boxes inputs

Document Sample

```					P&F Algorithm

INPUTS

1. Accept box_size, reversal_boxes inputs
2. Accept Date range in date_array and prices in H_array, L_array.

INITIAL CALCULATIONS

3. Calculate max and min of H_array and L_array to calculate number of Y-axis intervals
a. max_range = round(Max(H_array) * 1.1)
b. min_range = round(Min(L_array) * 0.9)
c. Yaxis_array_size = (max_range – min_range) / box_size
4. Caclulate Yaxis_array
Yaxis_array(1) = round(min_range)
For n = 2 to Yaxis_array_size
Yaxis_array(n) = Yaxis_array(n-1)+box_size
Next n

PLOT P&F

5. Plot initial value:
for n=1 to Yaxis_array_size
If (H_array(1) > Yaxis_array(n) AND H_array(1) < Yaxis_array(n-1) THEN PF_array(1,n) = 1
Else n = n+1

6. Construct PF_array with entire P&F plot

For iDay = 2 to no_days

current_column = 1
Reversal_Date(current_column) = iDay

If mod(current_column,2) = 1
If H_array(iDay) > n + box_size
Do
n=n+1
PF_array(current_column, n) = 1
Loop Until (H_array(iDay) < n + box_size
iDay = iDay + 1
Else If L_array(iDay) < n – reversal_boxes * box_size
ReDim PF array to add new column (Preserve previous data)
Reversal_Date(current_column) = iDay
current_column = current_column+1
Do
n=n–1
PF_array(current_column, n) = 0
Loop Until (L_array(iDay) > n – box_size
iDay = iDay + 1
Else
iDay = iDay + 1
End If
Else
If L_array(iDay) < n - box_size
Do
n=n-1
PF_array(current_column, n) = 0
Loop Until (L_array(iDay) > n - box_size
iDay = iDay + 1
Else If H_array(iDay) > n + reversal_boxes * box_size
ReDim PF array to add new column (Preserve previous data)
Reversal_Date(current_column) = iDay
current_column = current_column+1
Do
n=n+1
PF_array(current_column, n) = 1
Loop Until (H_array(iDay) < n + box_size
iDay = iDay + 1
Else
iDay = iDay + 1
End If
End If

End For

7. Plot PF_array on chart
8. Plot the dates on which the first new column entry was made below that column

```
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
 views: 11 posted: 2/27/2012 language: pages: 2