PureBytes Links
Trading Reference Links
|
Many of you are aware of the unreliability of TS point and figure especially
with regard to intraday systems. Here is my code (not taken from anyone else)
that I use. A function and simple breakout system is listed below. This must
be used with bar charts (i.e. 1 min, 5 min, daily).
I am a big fan of point and figure and would like to see other helpful ideas
posted.
Steve
******************************************************************************
*******
System
Input: pfBoxSiz(0.7),pfRevSiz(6),Length(3),Offset(0.1);
Buy pfFunction1(3,pfBoxSiz,pfRevSiz,Length,Offset) Stop;
Sell pfFunction1(4,pfBoxSiz,pfRevSiz,Length,Offset) Stop;
******************************************************************************
*******
Function
{
Function Name--- " pfFunction1"
Function = 0 then Return = Current Reversal Price;
Function = 1 then Return = Max Bar Price;
Function = 2 then Return = Bar Direction;
Function = 3 then Return = Buy Entry Stop Price;
Function = 4 then Return = Sell Entry Stop Price;
Function = other then Return = 0;
}
Inputs: Mode(NumericSimple),pfBoxSiz(NumericSimple),
pfRevSiz(NumericSimple),Length(NumericSimple),
Offset(NumericSimple);
Array: MaxBarPrice[30](0);
Vars: CurrentRevPrice(0),BarDirection(0),MaxBarCount(10),X(0),Return(0),
BuyStop(0), SellStop(0);
if CurrentBar <= 1 then begin
CurrentRevPrice = round(Close,0);
BarDirection = 0;
BuyStop = High + Offset;
SellStop = Low - Offset;
end
else begin
if BarDirection = 0 then begin
if High >= CurrentRevPrice + pfBoxSiz * pfRevSiz then begin
MaxBarPrice[0] = CurrentRevPrice + pfBoxSiz * pfRevSiz;
BarDirection = 1;
end
else if Low <= CurrentRevPrice - pfBoxSiz * pfRevSiz then begin
MaxBarPrice[0] = CurrentRevPrice - pfBoxSiz * pfRevSiz;
BarDirection = -1;
end;
end
else if BarDirection = 1 then begin
if High >= MaxBarPrice[0] + pfBoxSiz then begin
while High >= MaxBarPrice[0] + pfBoxSiz begin
MaxBarPrice[0] = MaxBarPrice[0] + pfBoxSiz;
CurrentRevPrice = MaxBarPrice[0] - pfBoxSiz * pfRevSiz;
end;
end
else if Low <= CurrentRevPrice then begin { we have a reversal }
for X = 0 to MaxBarCount-1 begin
MaxBarPrice[MaxBarCount - X] = MaxBarPrice[MaxBarCount - X-1];
end;
MaxBarPrice[0] = CurrentRevPrice;
BarDirection = -1;
CurrentRevPrice = MaxBarPrice[0] + pfBoxSiz * pfRevSiz;
while Low <= MaxBarPrice[0] - pfBoxSiz begin
MaxBarPrice[0] = MaxBarPrice[0] - pfBoxSiz;
CurrentRevPrice = MaxBarPrice[0] + pfBoxSiz * pfRevSiz;
end;
end;
end { BarDirection = 1}
else begin {BarDirection= -1}
if Low <= MaxBarPrice[0] - pfBoxSiz then begin
while Low <= MaxBarPrice[0] - pfBoxSiz begin
MaxBarPrice[0] = MaxBarPrice[0] - pfBoxSiz;
CurrentRevPrice = MaxBarPrice[0] + pfBoxSiz * pfRevSiz;
end;
end
else if High >= CurrentRevPrice then begin { we have a reversal }
for X = 0 to MaxBarCount-1 begin
MaxBarPrice[MaxBarCount - X] = MaxBarPrice[MaxBarCount - X-1];
end;
MaxBarPrice[0] = CurrentRevPrice;
BarDirection = 1;
CurrentRevPrice = MaxBarPrice[0] - pfBoxSiz * pfRevSiz;
while High >= MaxBarPrice[0] + pfBoxSiz begin
MaxBarPrice[0] = MaxBarPrice[0] + pfBoxSiz;
CurrentRevPrice = MaxBarPrice[0] - pfBoxSiz * pfRevSiz;
end;
end;
end; {BarDirection= -1}
{ Next section calculates the price of the current entry stop}
value1= 0;
value2= 100000;
for X = 1 to Length begin
if MaxBarPrice[X] > value1 then value1 = MaxBarPrice[X];
if MaxBarPrice[X] < value2 then value2 = MaxBarPrice[X];
end;
BuyStop = value1 + offset;
SellStop = value2 - offset;
if date=970811 and Mode = 3 then begin
print("pf0:",CurrentBar:5:0,":",Date:6:0,":",Time:5:0,":","MBP[0]=",MaxBarPric
e[0],
":","MBP[1]=",MaxBarPrice[1]);
print("pf1:",CurrentBar:5:0,":",Date:6:0,":",Time:5:0,":","MBP[2]=",MaxBarPric
e[2],
":","MBP[3]=",MaxBarPrice[3]);
end;
end; {CurrentBar<=1}
if Mode = 0 then begin
Return = CurrentRevPrice;
end
else if Mode = 1 then begin
if BarDirection = 0 then Return = Close
else if BarDirection = 1 then Return = MaxBarPrice[0]
else Return = MaxBarPrice[0];
end
else if Mode = 2 then begin
Return = BarDirection;
end
else if Mode = 3 then begin
Return = BuyStop;
end
else if Mode = 4 then begin
Return = SellStop;
end
else begin
Return = 0;
end;
pfFunction1 = Return;
|