Stock Portfolio Organizer

The ultimate porfolio management solution.

Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
For Portfolio Manager Click Here

WiseTrader Toolbox

#1 Selling Amibroker Plugin featuring:

Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Find Out More Here

Point & Figure [315a] for Amibroker (AFL)

Copy & Paste Friendly
/* Point & Figure [315a].afl
Submitted by parfumeur, original credit Graham Kavanagh  17 Apr 2004
http://www.wisestocktrader.com/indicators/315-point-figure-chart-based-on-closing-price-v4-53
3/16/2017 10:01:01 PM

Point & Figure charting

Interpretation window data included. 1:1 Line drawn when column selected with 
slope = boxsize. Box size based on ATR of closing price

<Reverse> is now a reserved word. Changed to ,Reverse_>

*/

//Version(6.20.1);

SetBarsRequired(100000,100000);

range = Min(260,BarCount/2);
box = LastValue( round(ATR(range)*100)/100 );
Reverse_ = 3;									// reversal requirement

CX			= round(C/box);
CF			= ceil(Cx);
CR			= floor(Cx);

Bar			= BarIndex();
BarDate = DateNum();
BarTurn = 0;
BarEnd	= 0;


// initialize first element
j = 0;
PFC[j]	= CF[0];
PFO[j]	= CF[0]+1;

down		= 1;									// By default the first bar is a down bar.
up			= 0;

// perform the loop that produces PF Chart
for( i = 1; i < BarCount; i++ )
{
 if( CF[i] <= PFC[j]-1 && down)					//continue down
 {
  PFC[j] = CF[i];
  PFO[j] = CF[i]+1;
  BarEnd[j] = Bar[i];
 }
 else
 {
  if( CR[i] >= PFC[j] + Reverse_ && down)  //Change direction to up
  {
   j++;
   up			= 1;
   down		= 0;
   PFC[j]			= CR[i];
   PFO[j]			= CR[i] - 1;
   BarTurn[j]	= Bar[i];
   BarEnd[j]	= Bar[i];
  }
 }
 if( CR[i] >= PFC[j] + 1 && up)					//Continue up
 {
  PFC[j]		= CR[i];
  PFO[j]		= CR[i] - 1;
  BarEnd[j]	= Bar[i];
 }
 else
 {
  if( CF[i] <= PFC[j] - Reverse_ && up) //Change direction to down
  {
   j++;
   up = 0;
   down = 1;
   PFC[j] = CR[i];
   PFO[j] = CR[i]+1;
   BarTurn[j] = Bar[i];
   BarEnd[j] = Bar[i];
  }
 }
}

delta = BarCount-1 - j;

BarTurns	= Ref( BarTurn, -delta);
BarEnds		= Ref( BarEnd, -delta);

PFO = Ref( PFO, -delta );
PFC = Ref( PFC, -delta );
H = IIf( Ref(PFC,-1)>Ref(PFO,-1), Ref(HHV(PFC,1),-1)-1, Max(PFO,PFC) )*box + box/2;
L = IIf( Ref(PFC,-1)<Ref(PFO,-1), Ref(LLV(PFC,1),-1)+1, Min(PFO,PFC) )*box - box/2;
O = IIf( Ref(PFC,-1)>Ref(PFO,-1), Ref(HHV(PFC,1),-1)-1, IIf(
Ref(PFc,-1)<Ref(PFO,-1), Ref(LLV(PFC,1),-1)+1, PFO ) )*box;

// the difference between Open AND Close is set to box size the sign decides if 
// X or O are plotted

C = O + box * IIf( PFC > PFO, 1, -1 );

top = H - box/2;
bot = L + box/2;

GraphXSpace = 5;

//Title = Name() + " " + Now(1) + ": PF System, H: $" + Top + (for today's date)

_N( 
Title = Name() + " " + Date() + ": PF System, H: $" + Top + ", L: $" + Bot + ",
Box $" + Box + " Reversal " + Reverse_ + "\n" + "NewCol bar " + BarTurns + " date
" + WriteVal(
ValueWhen(BarIndex()==SelectedValue(BarTurns),DateTime()),formatDateTime)  + "
ColEnd bar " + BarEnds + " date " + WriteVal(
ValueWhen(BarIndex()==SelectedValue(BarEnds),DateTime()),formatDateTime) 
  );

Plot(C, "P&F Close", IIf( PFC > PFO, colorGreen, colorRed ), styleCandle +
stylePointAndFigure);		// Change the colors of the [X], green and [O], red here

LineUp = LineArray( SelectedValue(BarIndex()), SelectedValue(L),
SelectedValue(BarIndex())+1, SelectedValue(L)+box, 1, 0 );
Linedown = LineArray( SelectedValue(BarIndex()), SelectedValue(H),
SelectedValue(BarIndex())+1, SelectedValue(H)-box, 1, 0 );
Plot(IIf(SelectedValue(PFC<PFO),Lineup,Null), "Line", colorGreen, styleLine +
styleNoLabel + styleNoRescale);
Plot(IIf(SelectedValue(PFC>PFO),Linedown,Null), "Line", colorBrown, styleLine +
styleNoLabel + styleNoRescale);

//--Indicator-End-- 
Name() +", "+FullName();
"";
"Direction  = " + WriteIf(pfc>pfo,"Up","Down");
"Move Today = " + WriteIf(BarIndex()==SelectedValue(BarEnds),"Yes" +
WriteIf(BarIndex()==SelectedValue(BarTurns),", New Column", ",
Continuation"),"No");
"";
"Column Start \n   BarIndex() = " + BarTurns + "\n   Date() = " + WriteVal(
ValueWhen(BarIndex()==SelectedValue(BarTurns), DateTime()), formatDateTime);
"Column End \n   BarIndex() = " + BarEnds + "\n   Date() = " + WriteVal(
ValueWhen(BarIndex()==SelectedValue(BarEnds),DateTime()),formatDateTime);

// ==================== End of PnF Amibroker Formula ===========================
Back