Крестики-нолики

Опубликовано в AmiBroker

Ну как не сохранить в коллекции такую прелесть?

 

Крестики-Нолики для Amibroker

//// P&F sample code
// Originally written by Mirat Dave
// Modified and adopted for AmiBroker 4.07 by Tomasz Janeczko
// Disclaimer:
// This code is not supposed to be fully working P&F chart
// and it may (and probably will) give inaccurate output.
// The ONLY purpose of this code is to show how to use new graph style 8128 (stylePointAndFigure)
// available in AmiBroker 4.07 that plots P&F-style O and X symbols.
// True P&F charting will be available in later versions of AmiBroker.

SetBarsRequired(100000,100000);
AvgTR = LastValue(ATR(50));
EnableScript("jscript");
<% High = VBArray( AFL( "High" )).toArray();
Low = VBArray( AFL( "Low" )).toArray();
ATR = AFL("AvgTR");


PFO = new Array();
PFC = new Array();

//Box = 0.7*ATR; // rma
Box = 1;

// initialize first element
j = 0;
PFO[j] = Box*Math.ceil(High[0]/Box);
PFC[j] = Box*Math.floor(Low[0]/Box);

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


// perform the loop that produces PF Chart
for( i = 1; i < High.length; i++ )
{
Reverse = Box * 3; // reversal requirement

if( Low[i] < PFC[j] - Box && down)
{
PFC[j] = Box*Math.floor(Low[i]/Box);
}
else
{
if( High[i] >= PFC[j] + Reverse && down)
{
j++;
swap = 1;
PFO[j] = Box*Math.floor(Low[i]/Box);
PFC[j] = Box*Math.ceil(High[i]/Box);
}
}

if( High[i] > PFC[j] + Box && up)
{
PFC[j] = Box*Math.ceil(High[i]/Box);
}
else
{
if( Low[i] <= PFC[j] - Reverse && up)
{
j++;
PFC[j] = Box*Math.floor(Low[i]/Box);
PFO[j] = Box*Math.ceil(High[i]/Box);
swap = 1;
}
}

if( swap )
{
swap = 0;
if( up )
{
up = 0;
down = 1;
}
else
{
up = 1;
down = 0;
}
}
}

delta = High.length - j;

AFL.Var("PFO") = PFO;
AFL.Var("PFC") = PFC;
AFL.Var("Box") = Box;
AFL.Var("delta") = delta;

%>

PFO = Ref( PFO, -delta );
PFC = Ref( PFC, -delta ) ;
/* High-Low range sets the height of the P&F bar */
H = Max(PFO,PFC);
L = Min(PFO,PFC);
O = PFO;
/* the difference between Open and Close should be set to box size */
/* the sign decides if X or O are plotted */
C = O + Box * IIf( PFC > PFO, 1, -1 );

Graph0Style = 64+8192; // new style is used here
Graph0BarColor = IIf( PFC > PFO, 5, 4 );
Graph0 = C;

Книга Томаса Дорси Метод графического анализа Крестики-Нолики

Недостаточно прав для комментирования