Вы находитесь на странице: 1из 5

CY1 = Param("Short Cycle Length?

" ,10, 1 ,1000 ,1 )/2;


CY2 = Param("Medium Cycle Length?" ,80, 1 ,1000 ,1 )/2;
M1 = Param("Short Cycle Multiplyer?" ,1, 0.01 ,10 ,1 );
M2 = Param("Medium Cycle Multiplyer?" ,3, 0.01 ,10 ,1 );
T1 = Ref(MA(Close ,CY1 ),CY1/2)+ M1*ATR(CY1 );
B1 = Ref(MA( Close ,CY1 ),CY1/2)- M1*ATR(CY1 );
T2 = Ref(MA(Close ,CY2 ),CY2/2)+ M2*ATR(CY2 );
B2 = Ref(MA( Close ,CY2 ),CY2/2)- M2*ATR(CY2 );
Plot(T1, "", colorLime);
Plot(B1, "", colorLime);
Plot(T2, "", colorRed);
Plot(B2, "", colorRed);
//Sell = (Cross(T2,T1) AND Close < Open AND Close < Ref(Close,-1)) OR H>=T2;
//Buy = (Cross(B2,B1) AND Close > Open AND Close > Ref(Close,-1)) OR L<=B2;
Buy=L<=B2;
Sell=H>=T2;
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell, Buy);
PlotShapes(shapeUpArrow*Buy,colorRed);
PlotShapes(shapeDownArrow*Sell,colorRed);
GraphXSpace = 5;
_SECTION_BEGIN( "Price" );
SetChartOptions( 0, chartShowDates | chartShowArrows | chartLogarithmic | chartW
rapTitle );
_N( Title = StrFormat( "{{NAME}} - " + SectorID( 1 ) + " - {{INTERVAL}} {{DATE}}
Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " + WriteVal( V, 1.0 ) + " {{VALUE
S}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ) );
Plot( C, "Close", colorBlack, styleCandle | styleNoTitle | ParamStyle( "Style" )
| GetPriceStyle() );
if ( ParamToggle( "Tooltip shows", "All Values|Only Prices" ) )
{
ToolTip = StrFormat( "Open: %g\nHigh: %g\nLow: %g\nClose: %g (%.1f%%)\nVolume: "
+ NumToStr( V, 1 ), O, H, L, C, SelectedValue( ROC( C, 1 ) ) );
}
_SECTION_END();
_SECTION_BEGIN("HH");
Q = Param( "% Change", 4, 0.1, 10,
Z = Zig( C , q ) ;
HH = ( ( Z < Ref( Z, -1 ) AND Ref(
> Peak( Z, q, 2 ) ) );
LH = ( ( Z < Ref( Z, -1 ) AND Ref(
< Peak( Z, q, 2 ) ) );
HL = ( ( Z > Ref( Z, -1 ) AND Ref(
) > Trough( Z, q, 2 ) ) );
LL = ( ( Z > Ref( Z, -1 ) AND Ref(
) < Trough( Z, q, 2 ) ) );
GraphXSpace = 5;
dist = 0.5 * ATR( 20 );

0.1 );
Z, -1 ) > Ref( Z, -2 ) ) AND (Peak( z, q, 1 )
Z, -1 ) > Ref( Z, -2 ) ) AND (Peak( Z, q, 1 )
Z, -1 ) < Ref( Z, -2 ) ) AND (Trough( Z, q, 1
Z, -1 ) < Ref( Z, -2 ) ) AND (Trough( Z, q, 1

for ( i = 0; i < BarCount; i++ )


{
if ( HH[i] )
PlotText( "HH", i, H[ i ] + dist[i], colorRed );
if ( LH[i] )
PlotText( "LH", i, H[ i ] + dist[i], colorRed );

if ( HL[i] )
PlotText( "HL", i, L[ i ] - dist[i], colorRed );
if ( LL[i] )
PlotText( "LL", i, L[ i ] - dist[i], colorRed );
}
Filter=HH OR HL OR LH OR LL;
AddColumn(RSI(2),"RSI",1.2);
AddColumn(Close,"PRICE",1.2);
AddColumn(HH,"SHORT");
AddColumn(LH,"LH");
AddColumn(HL,"HL");
AddColumn(LL,"COVER");
AddColumn(V,"volume",1.0);
_SECTION_END();

_SECTION_BEGIN("NR7");
/*********** NR7 System for Chart and Exploration ***********************/
R = H - L;
NR7 = False;
NR4 = False;
m7 = m4 = idm7 = idm4 = idm = 0;
for(i = 7; i < BarCount; i++)
{
if( R[i] < R[i - 1] AND R[i] < R[i -2] AND R[i] < R[i - 3] AND R[i] < R[i - 4] A
ND R[i] < R[i - 5] AND R[i] < R[i - 6])
{
NR7[i] = True;
m7[i] = 1;
}
}
for(i = 4; i < BarCount; i++)
{
if((R[i] < R[i - 1] AND R[i] < R[i -2] AND R[i] < R[i - 3] ) AND NOT NR7[i])
{
NR4[i] = True;
m4[i] = 1;
}
}
IDNR7 = Inside() * NR7;
IDNR4 = Inside() * NR4;
ID = Inside();
idm7 = IIf(IDNR7, 1, 0);
idm4 = IIf(IDNR4, 1, 0);
idm = IIf(id, 1, 0);
for(i = 1; i < BarCount;
{
if(IDNR7[i] == IDNR7[i if(IDNR4[i] == IDNR4[i if(NR7[i] == NR7[i - 1])

i++)
1]) idm7[i] = idm7[i] + idm7[i - 1];
1]) idm4[i] = idm4[i] + idm4[i - 1];
m7[i] = m7[i] + m7[i - 1];

if(NR4[i] == NR4[i - 1]) m4[i] = m4[i] + m4[i - 1];


if(ID[i] == ID[i - 1]) idm[i] = idm[i] + idm[i - 1];
}
MarkerIDNR7 = MarkerIDNR4 = shapeStar ;
Marker7 = shapeDigit7;
NR7Color = colorBrightGreen;
Marker4 = shapeDigit4;
NR4Color = colorLightOrange;
MarkerID = shapeCircle;
IDColor = colorRed;
IDNR7Color = colorBrightGreen;
IDNR4Color = colorLightOrange;
MarkerDist = L * 0.995;
IDNRDist = H * 1.03;
if(Status("action") == actionIndicator)
{
PlotOHLC(O, H, L, C, "Close", colorLightGrey, styleBar);
PlotShapes(IIf(IDNR7, MarkerIDNR7, shapeNone), IDNR7Color, 0, IDNRDist);
PlotShapes(IIf(IDNR4 AND NOT IDNR7, MarkerIDNR4, shapeNone), IDNR4Color, 0, IDNR
Dist);
PlotShapes(IIf(NR7 AND NOT ID, Marker7, shapeNone), NR7Color, 0, MarkerDist);
PlotShapes(IIf(NR4 AND NOT NR7 AND NOT ID, Marker4, shapeNone), NR4Color, 0, Mar
kerDist);
PlotShapes(IIf(ID AND NOT NR7 AND NOT NR4, MarkerID, shapeNone), IDColor, 0, IDN
RDist);
}
if(Status("action") == actionExplore)
{
Filter = (m7 > 0) OR (m4 > 0) OR (idm > 0);
SetOption("NoDefaultColumns", True);
AddColumn(DateTime(), "DATE", formatDateTime, colorDefault, colorDefault, 96);
AddTextColumn(Name(), "SYMBOL", 77, colorDefault, colorDefault, 120);
AddColumn(R, "Range", 6.2, colorDefault, colorDefault, 84);
AddColumn(IIf(idm, 48 + idm, 32), "INSIDE", formatChar, colorYellow, IIf(idm, co
lorLightBlue, colorDefault));
AddColumn(IIf(m4, 48 + m4, 32), "NR4", formatChar, colorYellow, IIf(m4, colorBlu
e, colorDefault));
AddColumn(IIf(m7, 48 + m7, 32), "NR7", formatChar, colorYellow, IIf(m7, colorGre
en, colorDefault));
}

///////////////////////////////////////////////////////////////////////////////
//
Gap Finder
//
AFL that plots that unfilled Gaps encountered within the last N bars.
// Author : Adheer Pai (adheer@gmail.com)
///////////////////////////////////////////////////////////////////////////////

// Input : The number of bars ago from where to start looking for gaps.
// Default is 250 : So, by default we search for Gaps found in last 250 trading
days ( 1 year )
period = Param("Lookback Period", 250, 15, 500);
// If we do not have enough bars, adjust the period accordingly.
if( BarCount - period - 1 < 0 ) period = BarCount - 2;
bIsGapUp = ( L > Ref(H, -1) );
bIsGapDn = ( H < Ref(L, -1) );

// Identify GapUp bars


// Identify GapDown bars

// We are not interested in Gap Ups and Gap Downs before the Period e.g. before
the last 250 bars.
// So we clear the values for bars before the ones we are interested in.
for( i = 0 ; i < (BarCount - 1 - period) ; i++ )
{
bIsGapUp[i] = False;
bIsGapDn[i] = False;
}
// Now plot GapUp bars with a Up-Triangle below its low.
PlotShapes(IIf(bIsGapUp, shapeSmallUpTriangle, shapeNone), colorBlue, 0, L, -12
);
// Now plot GapDown bars with a Down-Triangle below its high.
PlotShapes(IIf(bIsGapDn, shapeSmallDownTriangle, shapeNone), colorBlue, 0, H );
// Now walk from the first bar (e.g 250 bars ago, to the current bar)
for( i = (BarCount - period - 1) ; i <= (BarCount - 1) ; i++ )
{
dUpper = 0.0; dLower = 0.0; bFilled = True;
// Is the current bar a Gap-Up bar ?
if( bIsGapUp[i] == True )
{
// If yes, the store the Gap (Upper value) and Lower values.
dUpper = L[i]; dLower = H[i-1]; bFilled = False;
// Now walk till the current bar and see if the Gap values have
been filled from Above.
// I.e prices are falling and the gap is being falled.
for( j = i+1; j <= (BarCount - 1) ; j++ )
{
// Check whether the current low is lesser than the Gap
high. If yes, the Gap
// has been penetrated.
if( L[j] < dUpper )
{
dUpper = L[j];
// Determine whether the Gap has been fully pene
trated - if yes, then the
// Gap has been filled.
if( dUpper <= dLower ) bFilled = True;
}
if( bFilled == True ) break;
}
}
else if( bIsGapDn[i] == True )
{
// Same logic as GapUp - except we check whether the Gap has bee
n pierced from Below.
// i.e Prices are rising and the Gap has been filled.
dUpper = L[i-1]; dLower = H[i]; bFilled = False;
for( j = i+1; j <= (BarCount - 1) ; j++ )

{
if( H[j] > dLower )
{
dLower = H[j];
if( dLower >= dUpper ) bFilled = True;
}
if( bFilled == True ) break;
// Gap was fille
d, so move on to find the next gap.
}
}
if( bFilled == False )
// Gap Not filled - so plot hori
zontal line at the Gap Level.
{
pLine = LineArray(i-1, dLower, BarCount-1,dLower, 1);
//Plot(pLine, "", colorRed, styleDashed);
pLine = LineArray(i-1, dUpper, BarCount-1, dUpper, 1);
//Plot(pLine, "", colorBlue, styleDashed);
}
}

Вам также может понравиться