0% found this document useful (0 votes)
135 views29 pages

Study Amibroker

The document describes various technical analysis indicators and trading strategies including RSI, EMA, VWMA, Bollinger Bands, Heiken Ashi candles, and pivot point analysis. Multiple parameters can be configured and various signals, indicators and strategies are plotted on the chart.

Uploaded by

hanah05hd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
135 views29 pages

Study Amibroker

The document describes various technical analysis indicators and trading strategies including RSI, EMA, VWMA, Bollinger Bands, Heiken Ashi candles, and pivot point analysis. Multiple parameters can be configured and various signals, indicators and strategies are plotted on the chart.

Uploaded by

hanah05hd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 29

study("RSI with EMA & VWMA [AN]")

rsi_period = input(defval=9, title="RSI Period", type=input.integer)


vwma_f_p = input(defval=21, title="RSI VWMA Period", type=input.integer)
ema_s_p = input(defval=3, title="RSI EMA Period", type=input.integer)
bull_sup = input(defval=50, title="RSI Bull Trend Support", type=input.integer)
bear_res = input(defval=50, title="RSI Bear Trend Resistance", type=input.integer)

rsi = rsi(close, rsi_period)


vwma_rsi = vwma(rsi, vwma_f_p)
ema_rsi = ema(rsi, ema_s_p)

prsi = plot(rsi, title='RSI', color=color.new(#ffeb3b, 0), style=plot.style_line,


linewidth=2)
overbought = hline(50, title="Overbought", color=color.new(color.purple, 50),
linestyle=hline.style_dashed, linewidth=1)
oversold = hline(50, title="Oversold", color=color.new(color.purple, 50),
linestyle=hline.style_dashed, linewidth=1)
fill(overbought, oversold, color.new(color.purple, 90), title="RSI Fill")

pvwma = plot(vwma_rsi, title='VWMA', color=color.new(#66bb6a, 30),


style=plot.style_line, linewidth=1)
pema = plot(ema_rsi, title="EMA", color=color.new(#d32f2f, 30), style=plot.style_line,
linewidth=1)

fillColor = ema_rsi < vwma_rsi ? color.green : color.red


fill(pvwma, pema, color=fillColor, transp=60)
fill(pema, prsi, color=color.gray, transp=90)
hline(bull_sup, title="Bull Market RSI Support", color=color.new(color.green, 50),
linestyle=plot.style_line, linewidth=3)
hline(bear_res, title="Bear Market RSI Resistance", color=color.new(color.red, 60),
linestyle=plot.style_line, linewidth=3)

_SECTION_BEGIN("5 EMA High-Low");


SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g,
Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( Close, "Close", ParamColor("Color", colorBlack ), styleNoTitle |
ParamStyle("Style") | GetPriceStyle() );
Buy = Cross(Close,EMA( High , 5 ));
Sell = Cross(EMA( Low , 5 ),Close);
PlotShapes(IIf(Sell==1, shapeDownArrow, shapeNone), colorRed, 0,High, Offset=-
20);
PlotShapes(IIf(Buy==1, shapeUpArrow , shapeNone), colorGreen, 0,Low, Offset=-
20);
Plot( EMA( Low,5), "5 EMA LOW",ParamColor("Color", colorBlue
),styleNoRescale);
Plot( EMA( High,5), "5 EMA High",ParamColor("Color", colorBlue
),styleNoRescale);
_SECTION_END();

_SECTION_BEGIN("Display the Title");


Title = "5 EMA High-Low ( MKT CALLS) " + " - " + Name() + " - " +
EncodeColor(colorRed)+ Interval(2) + EncodeColor() +

" - " + Date() +" - " +EncodeColor(colorLime)+


_SECTION_END();

//www.aflcode.com
Range1=Optimize("range1",5,1,20,1);
Range2=Optimize("range2",5,1,125,1);

Buy = Cross((MA(Close,range1)),(MA(Open,range2)));
Sell = Cross(MA(Open,range2),(MA(Close,range1)));
Short = Sell;
Cover = Buy;
// plot expanded average

Plot(MA( Close,range1), "5Min-c", colorRed );


Plot(MA( Open,range2), "5Min-o", colorGreen );

// plot arrows
shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorGreen, colorRed ), 0, IIf( Buy, Low, High )
);

//www.aflcode.com
//================================================== ======================
// HBA Trading system (Heiken Ashi, Bolinger Bands, ADX)

//==================================================
==================================
SetChartOptions(0,chartShowArrows | chartShowDates);

// 1. Heiken Ashi
HaClose = (O + H + L + C)/4;
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
xDiff = (HaHigh - Halow);
barcolor = IIf(HaClose >= HaOpen,colorBrightGreen,colorRed);
PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "", barcolor, styleCandle );

// 2. Bolinger Bands
BBTop=BBandTop(H,10,2);
BBBot=BBandBot(L,10,2);
BBMid=(BBTop+BBBot)/2;

Plot(BBTop,"",12,1);
Plot(BBMid,"",12,1);
Plot(BBBot,"",12,1);

// Buy, sell
EntryLong = Cross(C,BBMid) AND HaClose>HaOpen AND xDiff>1 AND ADX(14)<40;
ExitLong = Cross(BBMid,C) AND HaClose<HaOpen AND xDiff>1;
PlotShapes(IIf(EntryLong , shapeSmallUpTriangle, shapeNone) ,colorBrightGreen,
0,L,-30);
PlotShapes(IIf( ExitLong , shapeSmallDownTriangle, shapeNone) ,colorOrange,
0,H,-25);

//www.aflcode.com
_SECTION_BEGIN("candlestick");
Plot (EMA(C,13),"",IIf(EMA(C,13) > Ref(EMA(C,13),-
1),colorAqua,colorBrown),styleThick);
Plot (MA(C,5),"",IIf(MA(C,5) > Ref(MA(C,5),-
1),colorAqua,colorBrown),styleThick+styleDashed);
Buy_ema = EMA(C,5) > EMA(C,34) AND EMA(C,5) > EMA(C,13);
Sell_ema = EMA(C,5) < EMA(C,34) AND EMA(C,5) < EMA(C,13);
Plot(EMA(C,34),"",IIf(Buy_ema,colorAqua,IIf(sell_ema,colorBrown,colorYellow)),
styleDots);
Plot(EMA(C,34)+0.1,"",IIf(Buy_ema,colorAqua,IIf(sell_ema,colorBrown,colorYello
w)),styleDots+styleNoLabel);
Plot(EMA(C,34)-
0.1,"",IIf(Buy_ema,colorAqua,IIf(sell_ema,colorBrown,colorYellow)),styleDots+s
tyleNoLabel);
Plot(EMA(C,34)+0.2,"",IIf(Buy_ema,colorAqua,IIf(sell_ema,colorBrown,colorYello
w)),styleDots+styleNoLabel);
Plot(EMA(C,34)-
0.2,"",IIf(Buy_ema,colorAqua,IIf(sell_ema,colorBrown,colorYellow)),styleDots+s
tyleNoLabel);

//Plot (C, "", IIf(PDI() > MDI(),colorGreen,colorRed),styleCandle);

A1=EMA(C,13)-EMA(C,34);
A2=MA(C,5)-EMA(C,34);
A3=MA(C,5)-EMA(C,13);
Buy = Buy_ema AND a2 > Ref(a2, -1)AND a3 > Ref(a3,-1) ;
Sell = Sell_ema AND a2 < Ref(a2, -1)AND a3 < Ref(a3,-1) ;
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
PlotShapes(Buy*shapeUpArrow,colorGreen);
PlotShapes(Sell*shapeDownArrow,colorRed);

_SECTION_BEGIN("ABKPPivotAndPops");
SetBarsRequired(350, -0);

//user parameters
parmPlotScoreCard = 1;
parmPlotA900AutoStop = 0;
parmA900Color = colorBlack;
parmA900Style = styleNoLabel;
parmAutoStopColor = colorCustom12; //ParamColor("AutoStop Color",
colorCustom12);
parmAutoStopStyle = styleLine;//ParamStyle("AutoStop Style", styleLine,
maskAll);
parmPPTextColor = colorBlack;//ParamColor("PP Text color", colorBlack);
parmPPTrndColorUp = colorGreen;//ParamColor("PP Trend Up color", colorGreen );
parmPPTrndColorDn = colorRed;//ParamColor("PP Trend Dwn color", colorRed );
parmPPTextOffSet = 0.9;//Param("PP OffSet", 0.90, 0.40, 1.5, 0.1);
parmTickMultipler = 0;//Param("M/W tick allowance", 0, 0, 10, 1);
parmA900AutoStopX = ParamToggle("Plot A900/AutoStop Cross", "No|Yes");
parmA900AutoStopColorX = colorBlack;//ParamColor("A900/AutoStop Cross Color",
colorBlack);
ParmSCThreshold = 5;//Param("ScoreCard Threshold", 5, 1, 9, 1);
parmVoice = 0;//ParamToggle("Pivot Voice", "No|Yes", 0);
parmPivotPop = 1;//ParamToggle("PivotPop", "No|Yes", 1);
parmBarCancel = 4;//Param("Bar Cancel", 4, 1, 20, 1);
parmFilter = ParamList("Filter", "None|KPMSL|KPWaterLevel|KPMedium", 0);
parmPlotFilter = 0;//ParamToggle("Plot Filter", "No|Yes", 0);
parmFilterColor = colorBlack;//ParamColor("Filter Color",
ColorRGB(127,255,212));
parmFilterStyle = styleLine;//ParamStyle("Filter Style", styleLine, maskAll);
parmBBPeriod = 20;//Param("Bollinger Band Period", 20, 2, 30, 1);
parmBBSD = 1;//Param("Bollinger Band width", 1.0, 0.5, 3.0, 0.5);
ParmPlotPPIndicators = 0;//ParamToggle("Plot Pivot Pop indicators", "No|Yes",
0);
parmBBColor = colorBlack;//ParamColor("BBands Color", colorBlack);
parmBBStyle = styleLine;//ParamStyle("BBands Style", styleLine, maskAll);

ParmDebug = 0;//ParamToggle("Debug", "No|Yes", 0);

// constants
_N(PaneName = Name() + Interval(2)+ _SECTION_NAME());
_N(NewBarName = "NewBar" + PaneName);

//functions
function NewBarP()
{
PrevDT = StaticVarGet( NewBarName);
DT = LastValue(DateTime());
StaticVarSet( NewBarName,DT);
return DT != PrevDT;
}
function MRoundP(Number, Multiple )
{
if(Multiple == 0 )
{

xMultiple = 0.01; }
else
{
xMultiple = Multiple;
}
Divided = Number / xMultiple;
intDivided = int(Divided);
intDivided = intDivided + round(Divided - intDivided);
return intDivided * xMultiple;
}

//miscellaneous setups
ObjAB = CreateObject("Broker.Application");
ticker = objAB.Stocks(Name() );
if(ticker.TickSize == 0)
{
TickValue = 0.01; //set TickValue to a penney
}
else
{
TickValue = ticker.TickSize; // use Tick Size for this symbol
}
NewBarSignal = NewBarP();
// KP Indicators
KPA900 = E_TSKPA900(Close);
KPAutoStop = E_TSKPAUTOSTOP(High,Low,Close);
Ctmpl = E_TSKPCOLORTMPL(Open,High,Low,Close,Volume); //ScoreCard
KPScoreCard = 0;
KPScoreCard = KPScoreCard + IIf(tskp_colortmplcnd0 > 0, 1, -1);
KPScoreCard = KPScoreCard + IIf(tskp_colortmplcnd1 > 0, 1, -1);
KPScoreCard = KPScoreCard + IIf(tskp_colortmplcnd2 > 0, 1, -1);
KPScoreCard = KPScoreCard + IIf(tskp_colortmplcnd3 > 0, 1, -1);
KPScoreCard = KPScoreCard + IIf(tskp_colortmplcnd4 > 0, 1, -1);
KPScoreCard = KPScoreCard + IIf(tskp_colortmplcnd5 > 0, 1, -1);
KPScoreCard = KPScoreCard + IIf(tskp_colortmplcnd6 > 0, 1, -1);
KPScoreCard = KPScoreCard + IIf(tskp_colortmplcnd7 > 0, 1, -1);
KPScoreCard = KPScoreCard + IIf(tskp_colortmplcnd8 > 0, 1, -1);

if(parmDebug == 1)
{
printf("a900: %0.6f% \nAutoStop: %0.6f%\nScoreCard: %0.0f%\n", KPA900,
KPAutoStop, KPScoreCard);
}
if(parmPlotScoreCard == 1)
{
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo
%g, Close %g% (%0.4f%) {{VALUES}}", O, H, L, C, SelectedValue( C - Ref(C, -1))
));
if( ParamToggle("Tooltip shows", "All Values|Only Prices" ) )
{
ToolTip=StrFormat("Open: %g\nHigh: %g\nLow: %g\nClose: %g (%.2f%%)\
nVolume: "+NumToStr( V, 1 ), O, H, L, C, SelectedValue( ROC( C, 1 )));
}
Color = IIf(KPScoreCard >= parmSCThreshold, colorBlue, IIf(KPScoreCard <= -
parmSCThreshold, colorRed, colorYellow) );
Plot( C, "Close", Color , styleNoTitle | styleBar+styleThick );
}
//user want A900/AutoStop plotted
if(parmPlotA900AutoStop == 1)
{
Plot(KPA900, "A900", parmA900Color, parmA900Style);
Plot(KPAutoStop, "AutoStop", parmAutoStopColor, parmAutoStopStyle);
}
// find A900/AutoStop cross over/under with ScoreCard confirmation.
XOUp = (KPA900 > KPAutoStop) AND (KPScoreCard >= parmSCThreshold); // New
Pivot Low
XODn = (KPA900 < KPAutoStop) AND (KPScoreCard <= -parmSCThreshold); // New
Pivot High
if(parmDebug == 1)
{
printf(WriteIf(XOUp, "before= XOUp: True", "before= XOUp: False") +
WriteIf(XODn, " XODn: True\n", " XODn: False\n") );
}
//remove duplicate signals
XOUp = ExRem(XOUp, XODn);
XODn = ExRem(XODn, XOUp);

if(parmDebug == 1)
{
printf(WriteIf(XOUp, "after= XOUp: True", "after= XOUp: False") +
WriteIf(XODn, " XODn: True\n", " XODn: False\n") );
}
//find the current Pivot Points - PL and PH
//remember XOUp = 1 means a PL and XODn =1 means a PH
PLBars = IIf(XOUp, LowestSinceBars(XODn, L ,1), 0); //find the bar that
produced the Lowest Low
PHBars = IIf(XODn, HighestSinceBars(XOUp, H, 1),0); //find the bar that
produced the Highest High
//PLPrice = IIf(XOUp, Ref(L, -PLBars), 0);
//PHPrice = IIf(XODn, Ref(H, -PHBars),0);
PLPrice = Ref(L, -PLBars);
PHPrice = Ref(H, -PHBars);

//keep track of the previous Pivot Points


PrevPLBars = Ref(BarsSince(XOUp), -1) +1;
PrevPHBars = Ref(BarsSince(XODn), -1) +1;
PrevPLPrice = Ref(PLPrice, -prevPLBars);
PrevPHPrice = Ref(PHPrice, -PrevPHBars );
PivotsCloseEnough = TickValue * parmTickMultipler;
PLDifference = MroundP(PLPrice - PRevPLPrice, ticker.TickSize);
PHDifference = MroundP(PHPrice - PrevPHPrice, ticker.TickSize);
PPTrend = IIf(XOUp AND (PLDifference > PivotsCloseEnough) AND PrevPHPrice >
PrevPLPrice AND PRevPHPrice > PLPrice, 1,
IIf(XOUp AND (PLDifference < - PivotsCloseEnough) AND PRevPHPrice >
PrevPLPrice AND PrevPHPrice > PLPrice, -1,
IIf(XODn AND (PHDifference > PivotsCloseEnough) AND PrevPLPrice <
PrevPHprice AND PrevPLPrice < PHPrice, 1,
IIf(XODn AND (PHDifference < -PivotsCloseEnough) AND PrevPLPrice <
PrevPHPrice AND PrevPLPrice < PHPrice, -1, 0)) ));
/*
PPTrend = IIf(XOUp AND PLPrice > PRevPLPrice AND PrevPHPrice > PrevPLPrice AND
PRevPHPrice > PLPrice, 1,
IIf(XOUp AND PLPrice < PRevPLPrice AND PRevPHPrice > PrevPLPrice AND
PrevPHPrice > PLPrice, -1,
IIf(XODn AND PHPrice > PrevPHPrice AND PrevPLPrice < PrevPHprice AND
PrevPLPrice < PHPrice, 1,
IIf(XODn AND PHPrice < PrevPHPrice AND PrevPLPrice < PrevPHPrice AND
PrevPLPrice < PHPrice, -1, 0)) ));
*/
if(ParmDebug)
{
printf("Current PH Bar: %g% /Price: %g%\n", PHBars, PHPrice);
printf("Current PL Bar: %g% /Price: %g%\n", PLBars, PLPrice);
printf("Previous PH Bar: %g% /Price: %g%\n", PrevPHBars, PrevPHPrice);
printf("Previous PL Bar: %g% /Price: %g%\n", PrevPLBars, PrevPLPrice) ;
printf("PP Trend: %g%\n", PPTrend);
printf("PHPrice - PrevPHPrice: %g%\nPLPrice - PrevPLPrice: %g%\
nPivotsCloseEnough: %g%\n", PHDifference, PLDifference, PivotsCloseEnough);
}
//PLot pivots as text
dist = parmPPTextOffSet * ATR(10);
//for( i = 0; i < BarCount -1; i++)
for( i = 0; i < BarCount ; i++)
{
if(XOUp[i ] == 1 ) //cross up -plot the Pivot Low
{
PlotText("PL \n"+PLPrice[i], i - PLBars[i], PLPrice[i] - dist[i] ,
parmPPTextColor, IIf(PPTrend[i] == 1, parmPPTrndColorUp, IIf(PPTrend[i] == -1,
parmPPTrndColorDn, colorYellow) ));
}
if(XODn[i ] == 1 ) //cross down - plot the pivot high
{
PlotText("PH \n"+PHPrice[i], i - PHBars[i], PHPrice[i] + dist[i],
parmPPTextColor, IIf(PPTrend[i] == 1, parmPPTrndColorUp, IIf(PPTrend[i] == -1,
parmPPTrndColorDn, colorYellow) ));
}
} //end For
// Plot A900/AutoStop cross over/under
if(parmA900AutoStopX == 1)
{
PlotShapes(IIf(Cross(KPA900, KPAutoStop), shapeUpTriangle, shapeNone),
parmA900AutoStopColorX, 0, L, -20);
PlotShapes(IIf(Cross(KPAutoStop, KPA900), shapeDownTriangle, shapeNone),
parmA900AutoStopColorX, 0, H , -20);
}
//PHLine = LineArray(BarCount - LastValue(PHBars) -3, LastValue(PHPrice),
BarCount - LastValue(PHBars) +2, LastValue(PHPrice), 0);
//Plot(PHLine, "PH", colorBlack, styleLine);
//PLLine = LineArray(BarCount - LastValue(PLBars) -3, LastValue(PLPrice),
BarCount - LastValue(PLBars) +2, LastValue(PLPrice), 0);
//Plot(PLLine, "PL", colorBlack, styleLine);
// identify M, lazy M, W and Lazy W formations
//voice
if(parmVoice ==1)
{
if(NewBarSignal)
{
if( LastValue(Ref(XODn, -1)) == 1 AND LastValue(Ref(PPTrend, -1)) == 1)
Say(Interval(2) + " New pivot. Higher high.");
if( LastValue(Ref(XODn, -1)) == 1 AND LastValue(Ref(PPTrend, -1)) == -1)
Say(Interval(2) + " New pivot. Lower high.");
if( LastValue(Ref(XODn, -1)) == 1 AND LastValue(Ref(PPTrend, -1)) == 0)
Say(Interval(2) + " New pivot. M Top.");
if( LastValue(Ref(XOUp,-1)) ==1 AND LastValue(Ref(PPTrend, -1)) == 1)
Say(Interval(2) + " New pivot. Higher low.");
if( LastValue(Ref(XOUp,-1)) ==1 AND LastValue(Ref(PPTrend, -1)) == -1)
Say(Interval(2) + " New pivot. Lower low.");
if( LastValue(Ref(XOUp,-1)) ==1 AND LastValue(Ref(PPTrend, -1)) == 0)
Say(Interval(2) + " New pivot. W bottom.");
}
}
//Pivot Pop code
if(parmPivotPop == 1)
{
//Kp indicators for Pivot Pop
dummy = E_TSKPFAST2(Open, High, Low, Close, Volume);
KPFast2 = IIf(tskp_fast2val1 > 0, 1, -1);
BarsSinceXOUp =BarsSince(XOUp);
BarsSinceXODn = BarsSince(XODn);
switch(parmFilter)
{
case "None":
PopFilter = True;
break;
case "KPMSL":
swVal = E_TSKPSWINGLINE(High, Low, Close);
KPMSL = tskp_swmean;
PopFilter = IIf(BarsSinceXOUp < BarsSinceXODn AND (C > KPMSL), True,
IIf(BarsSinceXODn < BarsSinceXOUp AND (C < KPMSL), True, False));
break;
case "KPWaterLevel":
KPWaterlevel = E_TSKPWATERLEVEL(Open,High,Low,Close,Volume);
PopFilter = IIf(BarsSinceXOUp < BarsSinceXODn AND (C > KPWaterLevel),
True, IIf(BarsSinceXODn < BarsSinceXOUp AND (C < KPWaterLevel), True, False));
break;
case "KPMedium":
dummy = E_TSKPMEDIUM(Close);
KPMediumUp = tskp_mediumup;
KPMediumDn = tskp_mediumdown;
KPMediumMA = tskp_mediumma;
KPMedium = KPMediumUp + KPMediumDn;
PopFilter = IIf(BarsSinceXOUp < BarsSinceXODn AND (KPMedium >
KPMediumMA), True, IIf(BarsSinceXODn < BarsSinceXOUp AND (KPMedium <
KPMediumMA), True, False));
break;
}
//calculations
UBB = BBandTop(C, parmBBPeriod, parmBBSD);
LBB = BBandBot(C, parmBBPeriod, parmBBSD);

if(parmDebug == 1)
{
printf("Fast2: %1.0f% \nUBB: %0.6f%\nLBB: %0.6f%\nC: %g%\n", KPFast2, UBB,
LBB, C);
printf("Bars since Last XOUp: %1.0f%\nBars since last XODn: %1.0f%\n",
BarsSinceXOUp, BarsSinceXODn );
printf("Bars since PPTrnd =1: %1.0f%\nBars since PPTrnd = -1: %1.0f%\n",
BarsSince(PPTrend ==1), BarsSince(PPTrend == -1) );
printf("ParmFilter: " + parmFilter + "\nPopFilter: %g%\n", PopFilter);
switch(parmFilter)
{
case "None":
break;
case "KPMSL":
printf("KPMSL: %g%\n", KPMSL);
break;
case "KPWaterLevel":
printf("KPWaterlevel: %g%\n", KPWaterLevel);
break;
case "KPMedium":
printf("KPMedium: %g%\nKPMediumMA: %g%\n", KPMedium, KPMediumMA);
break;
}
}
PPopUp = (BarsSince(PPTrend == 1) <= parmBarCancel) AND (BarsSince(XOUp) <=
parmBarCancel) AND (KPA900 >= KPAutoStop) AND(KPFast2 == 1) AND (KPScoreCard
>= 5)
AND PopFilter
AND (C > UBB) AND (C > O) ;
PPopUp = IIf( PPopUp AND Sum(PPopUP, BarsSince(XOUp)+1) == 1, True, False );
//keep only the 1st signal
PPopDn = (BarsSince(PPTrend == -1) <= parmBarCancel) AND (BarsSince(XODn) <=
parmBarCancel) AND (KPA900 <= KPAutoStop) AND(KPFast2 == -1) AND (KPScoreCard
<= -5)
AND PopFilter
AND (C < LBB) AND (C < O) ;
PPopDn = IIf( PPopDn AND Sum(PPopDn, BarsSince(XODn) + 1) == 1, True,
False); //keep only the first signal
if(parmDebug == 1)
{
printf(WriteIf(PPopUp,"PPopUp: True", "PPopUp: False") + WriteIf(PPopDn, "
PPopDn: True\n", " PPopDn: False\n") );
printf("PPopUp sum: %1.0f% \nPPopDn sum: %1.0f%", Sum(PPopUP,
BarsSince(XOUp)) , Sum(PPopDn, BarsSince(XODn)) );
}
// Plots
PlotShapes(IIf(PPopUp, shapeHollowUpArrow, shapeNone), colorDarkBlue, 0, L,
-30);
PlotShapes(IIf(PPopDn, shapeHollowDownArrow, shapeNone), colorDarkRed, 0, H,
-30);

if(ParmPlotPPIndicators == 1) //plot the Pivot Pop Indicators


{
Plot(UBB, "Upper BB", parmBBColor, parmBBStyle);
Plot(LBB, "Lower BB", parmBBColor, parmBBStyle);
if(parmPlotA900AutoStop == 1)
{
Plot(KPA900, "A900", parmA900Color, parmA900Style);
Plot(KPAutoStop, "AutoStop", parmAutoStopColor, parmAutoStopStyle);
}
Plot( 0.5, "Fast2", IIf(tskp_fast2val1 > 0, parmPPTrndColorUp,
parmPPTrndColorDn) , styleArea | styleNoLabel | styleOwnScale , 0, 10);
} //endif parmPlotPPIndicators
if(parmPlotFilter == 1)
{
switch(parmFilter)
{
case "None":
break;
case "KPMSL":
Plot(KPMSL, "KPMSL", parmFilterColor, parmFilterStyle);
break;
case "KPWaterLevel":
Plot(KPWaterLevel, "KPWaterLevel", parmFilterColor, parmFilterStyle);
break;
case "KPMedium":
// HMM how to print Medium on a price chart
break;
}
} //endif parmPlotFilter
} // end if parmPivotPop
_SECTION_END();

_SECTION_BEGIN("NICK MA Swing");
DayH = TimeFrameGetPrice("H", in15Minute*2, -1);// yesterdays high
DayL = TimeFrameGetPrice("L", in15Minute*2, -1);//low
DayC = TimeFrameGetPrice("C", in15Minute*2, -1);//close
DayO = TimeFrameGetPrice("O", in15Minute*2 );//open today

R6 = (DayH / DayL) * DayC * 1.002;


R5 = (DayH / DayL) * DayC;
R4 = (((DayH / DayL) + 0.83) / 1.83) * DayC;
R3 = ( ( (DayH / DayL) + 2.66) / 3.66) * DayC;
R2 = ( ( (DayH / DayL) + 4.5) / 5.5) * DayC;
R1 = ( ( (DayH / DayL) + 10) / 11) * DayC;

S1 = (2- ( ( (DayH / DayL) + 10) / 11)) * DayC;


S2 = (2-( (DayH / DayL) + 4.5) / 5.5) * DayC;
S3 = (2-(( DayH / DayL) + 2.66) / 3.66) * DayC;
S4 = (2-( (DayH / DayL) + 0.83) / 1.83) * DayC;
S5 = (2-( DayH / DayL)) * DayC;
S6 = (2-( DayH / DayL)) * DayC * 0.998;

//Plot(s3, "", colorGreen,styleThick+styleDashed);


//Plot(s4, "", colorGreen,styleThick+styleDashed);
//Plot(r3, "", colorRed,styleThick+styleDashed);
//Plot(r4, "", colorRed,styleThick+styleDashed);

pivot = (DayH+DayL+DayC)/3;
NW = pivot;
J = MA(Close,3);
piv = (H+L+C)/3;
_SECTION_END();

CCI_diff = round(10*(CCI(14) - Ref(CCI(14),-1)))/10;


//
=================TITLE========================================================
========================================
_SECTION_BEGIN("Title");
Title = EncodeColor(colorWhite)+ "Line Chart" + " - " + Name() + " - " +
EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +
" - " + Date() +

"\n"+
WriteIf(H > Ref(H,-1),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+"ex
"+Ref(H,-1)+" Hi "+H+"\n"+
EncodeColor(colorWhite)+"Op "+O+EncodeColor(colorAqua)+" Cl : " +C+"\n"+
WriteIf(L < Ref(L,-1),EncodeColor(colorRed),EncodeColor(colorBrightGreen))+"ex
"+Ref(L,-1)+" Lo "+L+
"\n"+

//WriteIf (Buy ,EncodeColor(colorGreen)+ " GO LONG / Reverse Signal at "+C+"


","")+
//WriteIf (Sell ,EncodeColor(colorRed)+ " EXIT LONG / Reverse Signal at "+C+"
","")+"\n"+EncodeColor(colorWhite)+
//WriteIf(Sell , EncodeColor(colorRed)+"Total Profit/Loss for the Last Trade
Rs."+round(C-BuyPrice)+"","")+
//WriteIf(Buy ,EncodeColor(colorGreen)+ "Total Profit/Loss for the Last trade
Rs."+round(SellPrice-C)+"","")+
//WriteIf(Long AND NOT Buy,EncodeColor(colorGreen)+ "Trade : Long - Entry
price Rs."+(BuyPrice),"")+
//WriteIf(shrt AND NOT Sell,EncodeColor(colorRed)+ "Trade : Short - Entry
price Rs."+(SellPrice),"")+"\n"+
//WriteIf(Long AND NOT Buy, EncodeColor(colorYellow)+"Current Profit/Loss
Rs."+round(C-BuyPrice)+"\n Place SL at "+s4,"")+
//WriteIf(shrt AND NOT Sell,EncodeColor(colorYellow)+ "Current Profit/Loss
Rs."+round(SellPrice-C)+"\n Place SL at "+R4,"")+
//"\n"+
WriteIf(C > R6,EncodeColor(colorYellow)+"\n Price "+C,"")+
EncodeColor(colorDarkRed)+"\n H6 : "+R6+
WriteIf(C > R5 AND C < r6,EncodeColor(colorYellow)+" \n Price "+C,"")+
EncodeColor(colorDarkRed)+"\n H5 : "+R5+
WriteIf(C > R4 AND C < r5,EncodeColor(colorYellow)+" \n Price "+C,"")+
EncodeColor(colorRed)+"\n H4 : "+R4+
WriteIf(C > R3 AND C < r4,EncodeColor(colorYellow)+" \n Price "+C,"")+
EncodeColor(colorRed)+"\n H3 : "+R3+

WriteIf(C > s3 AND C < r3,EncodeColor(colorYellow)+" \n Price "+C,"")+


EncodeColor(colorBrightGreen)+"\n L3 : "+S3+
WriteIf(C > s4 AND C < s3,EncodeColor(colorYellow)+" \n Price "+C,"")+
EncodeColor(colorBrightGreen)+"\n L4 : "+S4+
WriteIf(C > s5 AND C < s4,EncodeColor(colorYellow)+" \n Price "+C,"")+
EncodeColor(colorDarkGreen)+"\n L5 : "+S5+
WriteIf(C > s6 AND C < s5,EncodeColor(colorYellow)+" \n Price "+C,"")+
EncodeColor(colorDarkGreen)+"\n L6 : "+S6+
WriteIf(C < s6,EncodeColor(colorYellow)+" \n Price "+C,"")+
"\n"+"\n"+
WriteIf(a1 > 0, EncodeColor(colorBrightGreen),EncodeColor(colorRed))+"MAIN
"+
WriteIf(a1 > Ref(a1,-1), EncodeColor(colorBrightGreen)
+"POS",EncodeColor(colorRed)+"NEG")+round(a1*10)/10+
"\n"+
WriteIf(a2 > 0, EncodeColor(colorBrightGreen),EncodeColor(colorRed))+"MID
"+
WriteIf(a2 > Ref(a2,-1), EncodeColor(colorBrightGreen)
+"POS",EncodeColor(colorRed)+"NEG")+round(a2*10)/10+
"\n"+
WriteIf(a3 > 0, EncodeColor(colorBrightGreen),EncodeColor(colorRed))+"Trigger
"+
WriteIf(a3 > Ref(a3,-1), EncodeColor(colorBrightGreen)
+"POS",EncodeColor(colorRed)+"NEG")+round(a3*10)/10+
"\n"+
"\n"+
WriteIf(Ref(CCI(14),-1) > Ref(CCI(14),-
2),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+
"CCI-14 \n Ex "+round(10*Ref(CCI(14),-1))/10+ " "+
WriteIf(CCI(14) > 100,EncodeColor(colorBlue)+"Now
"+round(10*CCI(14))/10,WriteIf(CCI(14) < -100,EncodeColor(colorCustom12)+"Now
"+round(10*CCI(14))/10,WriteIf(CCI(14) > Ref(CCI(14),-
1),EncodeColor(colorBrightGreen)+"Now
"+round(10*CCI(14))/10,EncodeColor(colorRed)+"Now "+round(10*CCI(14))/10)))+
"\n"+
WriteIf(Ref(cci_diff,-1) > Ref(cci_diff,-
2),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+"diff Ex
"+Ref(CCI_diff,-1)+

WriteIf(cci_diff > Ref(cci_diff,-


1),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+" Now"+CCI_diff

Jump to
Sections of this page
Accessibility help
Press alt + / to open this menu

Facebook
Email or
Password
phone

Forgotten account?
Sign Up
See more of AFL Amibroker on Facebook
Log In
or
Create New Account
Related Pages

Niftystocktrend

Financial service

Amibroker Plugins

Software

Deep Learning Vietnam

Charitable organisation

Amibroker by LuiHoon

Software

The Art of Trading

Local business

Sharesoft pvt ltd

Internet company

Elliott Wave Trading- Hướng dẫn giao dịch theo sóng Elliott

Financial service

Homeland Security EXPO

Occupational health and safety service

Investing in Vietnam's Stock Market

Investing service

DCG Megastock

Investing service


Deep learning và ứng dụng

Education

Tatechnics

Business & economy website

Recent post by Page

AFL Amibroker
10 March at 05:06
https://www.facebook.com/profile.php… PLEASE SUBSCRIBE MY FACEBOOK FOR
MORE UPDATES AND AFL
22
Share
English (UK) · Tiếng Việt · 中文(台灣) · Español · Português (Brasil)
Privacy · Terms · Advertising · AdChoices · Cookies ·
More
Meta © 2022

AFL Amibroker

31 August 2014 ·

// TRADING THE MACD Ver 1.0 by Karthik Marar.

_SECTION_BEGIN("MACD");
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
r4 = Param( "Wk slow", 17, 2, 200, 1 );
r5 = Param( "Wk fast", 8, 2, 200, 1 );
m1=MACD(r1,r2);
s1=Signal(r1,r2,r3);
GraphXSpace =20;

mycolor=IIf(m1<0 AND m1>s1, 51,IIf(m1>0 AND m1>s1,colorLime,IIf(m1>0 AND


m1<s1,colorOrange,colorRed)));
Plot( m1, StrFormat(_SECTION_NAME()+"(%g,%g)", r1, r2), mycolor,ParamStyle("MACD
style") );
Plot( s1 ,"Signal" + _PARAM_VALUES(), ParamColor("Signal color", colorBlue ),
ParamStyle("Signal style") );
histcolor = IIf((m1-s1)-Ref((m1-s1),-1)> 0, colorLime, colorRed );

TimeFrameSet( inDaily );// weekly


m1w=MACD(r4,r5);
s1w=Signal(r4,r5,r3);
kp=m1w-s1w;
kph=Ref(kp,-1);
TimeFrameRestore();

kw=TimeFrameExpand( kp, inDaily ); // expand for display


khw=TimeFrameExpand( kph, inDaily ); // expand for display
mw=TimeFrameExpand( m1w, inDaily ); // expand for display
sw=TimeFrameExpand( s1w, inDaily ); // expand for display

hcolor=IIf(mw<0 AND mw>sw, 51,IIf(mw>0 AND mw>sw,colorLime,IIf(mw>0 AND


mw<sw,colorOrange,colorRed)));
gcolor=IIf(kw>khw,IIf(kw>0,colorDarkYellow,colorYellow),IIf(kw>0,colorSkyblue,colorBlue)
);

Plot( 2,"Wkly MACD ribbon",hcolor,styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );


Plot( 2,"Ribbon",gcolor,styleOwnScale|styleArea|styleNoLabel, -0.4, 40,-0.6 );

Plot( m1-s1, "MACD Histogram", mycolor, styleHistogram | styleThick| styleOwnScale );

_SECTION_END();

_SECTION_BEGIN("Signals");
//Zero crossover up

j1=Cross(m1,0);
PlotShapes(IIf(j1,shapeDigit1 ,Null),colorPaleGreen,0,Min(0,0),Min(0,0));
PlotShapes(IIf(j1,shapeUpArrow,Null),colorGreen,0,Min(0,0),-10);
// crossover above zero

j2=Cross(m1,s1) AND m1>0;


PlotShapes(IIf(j2,shapeDigit2 ,Null),colorYellow,0,0,0);
PlotShapes(IIf(j2,shapeUpArrow,Null),colorGreen,0,0,-10);

//Zero crossover down

j3=Cross(s1,m1) AND m1>0;


PlotShapes(IIf(j3,shapeDigit3 ,Null),colorOrange,0,Min(0,0),0);
PlotShapes(IIf(j3,shapeDownArrow,Null),colorOrange,0,Min(0,0),-10);

// crossover below zero

j4=Cross(0,m1);
PlotShapes(IIf(j4,shapeDigit4 ,Null),colorRed,0,0,0);
PlotShapes(IIf(j4,shapeDownArrow,Null),colorRed,0,0,-10);

// Histogram peak and troughs


pt=m1-s1;
Tp = Ref(pT,-1) == HHV(pT,3);
Vl = Ref(pT,-1)==LLV(pT,3);
PlotShapes(IIf(Vl AND m1>s1 ,shapeSmallCircle+
shapePositionAbove,shapeNone),IIf(m1<0 ,colorYellow,colorLime),0,0,0);
PlotShapes(IIf(Tp AND m1<s1 ,shapeSmallCircle+
shapePositionAbove,shapeNone),colorRed,0,0,0);

//Zeroline reject bearish


zd=BarsSince(j1);
zlrd1=(zd<6 )AND j4;
PlotShapes(IIf(zlrd1,shapeStar+ shapePositionAbove,shapeNone),colorDarkRed,0,0,20);

//hooks bearish
Hu=BarsSince(j2);
Hu1=(Hu<6)AND j3;
PlotShapes(IIf(Hu1,shapeStar+ shapePositionAbove,shapeNone),colorRed,0,0,20);

//Zeroline reject Bullish


zu=BarsSince(j4);
zlru=zu<6 AND j1;
PlotShapes(IIf(zlru,shapeStar+ shapePositionAbove,shapeNone),colorPink,0,0,20);

//Hook Bullish
Hd=BarsSince(j3);
Hd1=Hd<6 AND j2;
PlotShapes(IIf(Hd1,shapeStar+ shapePositionAbove,shapeNone),colorLime,0,0,20);

//ADX related calculations


plus=EMA(PDI(14),3)>Ref(EMA(PDI(14),3),-5);
ap=EMA(ADX(14),3)>Ref(EMA(ADX(14),3),-5);
Minus=EMA(MDI(14),3)>Ref(EMA(MDI(14),3),-5);

//Power Dips - Bullish


PDIp=ADX(14)>MDI(14) AND PDI(14)>MDI(14) AND ap AND Vl AND m1>s1 AND plus ;
PlotShapes(IIf(PDIp,shapeHollowCircle+
shapePositionAbove,shapeNone),colorCustom12,0,0,0);

//power buys
pr2=ADX(14)>20 AND PDI(14)>20 AND ADX(14)>MDI(14) AND PDI(14)>MDI(14) AND
plus AND j2;
PlotShapes(IIf(pr2,shapeHollowCircle+
shapePositionAbove,shapeNone),colorCustom12,0,0,20);

//Power Dips - Bearish


PDIm=ADX(14)>PDI(14) AND MDI(14)>PDI(14) AND ap AND Tp AND m1<s1 AND Minus
;
PlotShapes(IIf(PDIm,shapeHollowCircle+ shapePositionAbove,shapeNone),colorWhite,0,0,0);

//Power shorts
sr2=ADX(14)>20 AND MDI(14)>20 AND ADX(14)>PDI(14) AND MDI(14)>PDI(14) AND
Minus AND j4;
PlotShapes(IIf(sr2,shapeHollowCircle+ shapePositionAbove,shapeNone),colorRed,0,0,-20);

//powerbuy2
pr2a=ADX(14)>20 AND PDI(14)>20 AND ADX(14)>MDI(14) AND PDI(14)>MDI(14) AND
plus AND j1;
PlotShapes(IIf(pr2a,shapeHollowCircle+
shapePositionAbove,shapeNone),colorCustom12,0,0,20);
_SECTION_END();

_SECTION_BEGIN("Exploration");
Filter = j1 OR j2 OR j3 OR j4 OR PDIp OR PDIm OR pr2 OR sr2 ;

AddColumn(j1,"ZL UP",1);
AddColumn(J2,"MA Up",1);
AddColumn(j3,"MA DN",1);
AddColumn(J4,"ZL DN",1);
AddColumn(PDIp,"PDIP UP",1);
AddColumn(pr2,"PHK UP",1);
AddColumn(PDIm,"PDIP DN",1);
AddColumn(sr2,"PHk UP",1);
_SECTION_END();

_SECTION_BEGIN("Display the Signals");


Title = "Trading the MACD" + " - " + Name() + " - " + EncodeColor(colorRed)+ Interval(2) +
EncodeColor() +

" - " + Date() +" - " +EncodeColor(colorLime)+ "MACD=


"+WriteVal(m1)+"--"+EncodeColor(colorYellow)+
WriteIf (j1, " MACD Crossed above zero","")+
WriteIf (j2, " Bullish crossover above zero","")+
WriteIf (j4, " MACD Crossed below Zero","")+
WriteIf (j3, " Bearish crossover above zero","")+
WriteIf (PDIP, " Bullish Power Dip","")+
WriteIf (pr2, " & Power Buy","")+
WriteIf (sr2, " & Power Short","")+
WriteIf (PDIm, " Bearish Power Dip","")+
WriteIf (Hd1, " & Bullish Hook","")+
WriteIf (Hu1, " & Bearish Hook","")+
WriteIf (zlrd1, " & Bearish zeroline Reject","")+
WriteIf (zlru, " & Bullish Zeroline Reject","");
_SECTION_END();

3131
8 comments4 shares
Share
// TRADING THE MACD Ver 1.0 by Karthik Marar.
_SECTION_BEGIN(“MACD”);
r1 = Param( “Fast avg”, 12, 2, 200, 1 );
r2 = Param( “Slow avg”, 26, 2, 200, 1 );
r3 = Param( “Signal avg”, 9, 2, 200, 1 );
r4 = Param( “Wk slow”, 17, 2, 200, 1 );
r5 = Param( “Wk fast”, 8, 2, 200, 1 );
m1=MACD(r1,r2);
s1=Signal(r1,r2,r3);
GraphXSpace =20;
mycolor=IIf(m1<0 AND m1>s1, 51,IIf(m1>0 AND m1>s1,colorLime,IIf(m1>0 AND
m1 0, colorLime, colorRed );
TimeFrameSet( inDaily );// weekly
m1w=MACD(r4,r5);
s1w=Signal(r4,r5,r3);
kp=m1w-s1w;
kph=Ref(kp,-1);
TimeFrameRestore();
kw=TimeFrameExpand( kp, inDaily ); // expand for display
khw=TimeFrameExpand( kph, inDaily ); // expand for display
mw=TimeFrameExpand( m1w, inDaily ); // expand for display
sw=TimeFrameExpand( s1w, inDaily ); // expand for display
hcolor=IIf(mw<0 AND mw>sw, 51,IIf(mw>0 AND mw>sw,colorLime,IIf(mw>0 AND
mwkhw,IIf(kw>0,colorDarkYellow,colorYellow),IIf(kw>0,colorSkyblue,colorBlue));
Plot( m1-s1, “MACD Histogram”, mycolor, styleHistogram | styleThick|
styleOwnScale );
_SECTION_END();
_SECTION_BEGIN(“Signals”);
//Zero crossover up
j1=Cross(m1,0);
PlotShapes(IIf(j1,shapeDigit1 ,Null),colorPaleGreen,0,Min(0,0),Min(0,0));
PlotShapes(IIf(j1,shapeUpArrow,Null),colorGreen,0,Min(0,0),-10);
// crossover above zero
j2=Cross(m1,s1) AND m1>0;
PlotShapes(IIf(j2,shapeDigit2 ,Null),colorYellow,0,0,0);
PlotShapes(IIf(j2,shapeUpArrow,Null),colorGreen,0,0,-10);
//Zero crossover down
j3=Cross(s1,m1) AND m1>0;
PlotShapes(IIf(j3,shapeDigit3 ,Null),colorOrange,0,Min(0,0),0);
PlotShapes(IIf(j3,shapeDownArrow,Null),colorOrange,0,Min(0,0),-10);
// crossover below zero
j4=Cross(0,m1);
PlotShapes(IIf(j4,shapeDigit3 ,Null),colorRed,0,0,0);
PlotShapes(IIf(j4,shapeDownArrow,Null),colorRed,0,0,-10);
// Histogram peak and troughs
pt=m1-s1;
Tp = Ref(pT,-1) == HHV(pT,3);
Vl = Ref(pT,-1)==LLV(pT,3);
PlotShapes(IIf(Vl AND m1>s1 ,shapeSmallCircle+
shapePositionAbove,shapeNone),IIf(m1<0 ,colorYellow,colorLime),0,0,0);
PlotShapes(IIf(Tp AND m1<s1 ,shapeSmallCircle+
shapePositionAbove,shapeNone),colorRed,0,0,0);
//Zeroline reject bearish
zd=BarsSince(j1);
zlrd1=(zd<6 )AND j4;
PlotShapes(IIf(zlrd1,shapeStar+ shapePositionAbove,shapeNone),colorDarkRed,0,0,20);
//hooks bearish
Hu=BarsSince(j2);
Hu1=(Hu<6)AND j3;
PlotShapes(IIf(Hu1,shapeStar+ shapePositionAbove,shapeNone),colorRed,0,0,20);
//Zeroline reject Bullish
zu=BarsSince(j4);
zlru=zu<6 AND j1;
PlotShapes(IIf(zlru,shapeStar+ shapePositionAbove,shapeNone),colorPink,0,0,20);
//Hook Bullish
Hd=BarsSince(j3);
Hd1=Hd<6 AND j2;
PlotShapes(IIf(Hd1,shapeStar+ shapePositionAbove,shapeNone),colorLime,0,0,20);
//ADX related calculations
plus=EMA(PDI(14),3)>Ref(EMA(PDI(14),3),-5);
ap=EMA(ADX(14),3)>Ref(EMA(ADX(14),3),-5);
Minus=EMA(MDI(14),3)>Ref(EMA(MDI(14),3),-5);
//Power Dips – Bullish
PDIp=ADX(14)>MDI(14) AND PDI(14)>MDI(14) AND ap AND Vl AND m1>s1
AND plus ;
PlotShapes(IIf(PDIp,shapeHollowCircle+
shapePositionAbove,shapeNone),colorCustom12,0,0,0);
//power buys
pr2=ADX(14)>20 AND PDI(14)>20 AND ADX(14)>MDI(14) AND PDI(14)>MDI(14)
AND plus AND j2;
PlotShapes(IIf(pr2,shapeHollowCircle+
shapePositionAbove,shapeNone),colorCustom12,0,0,20);
//Power Dips – Bearish
PDIm=ADX(14)>PDI(14) AND MDI(14)>PDI(14) AND ap AND Tp AND m1<s1
AND Minus ;
PlotShapes(IIf(PDIm,shapeHollowCircle+
shapePositionAbove,shapeNone),colorWhite,0,0,0);
//Power shorts
sr2=ADX(14)>20 AND MDI(14)>20 AND ADX(14)>PDI(14) AND MDI(14)>PDI(14)
AND Minus AND j4;
PlotShapes(IIf(sr2,shapeHollowCircle+ shapePositionAbove,shapeNone),colorRed,0,0,-
20);
//powerbuy2
pr2a=ADX(14)>20 AND PDI(14)>20 AND ADX(14)>MDI(14) AND
PDI(14)>MDI(14) AND plus AND j1;
PlotShapes(IIf(pr2a,shapeHollowCircle+
shapePositionAbove,shapeNone),colorCustom12,0,0,20);
_SECTION_END();
_SECTION_BEGIN(“Exploration”);
Filter = j1 OR j2 OR j3 OR j4 OR PDIp OR PDIm OR pr2 OR sr2 ;
AddColumn(j1,”ZL UP”,1);
AddColumn(J2,”MA Up”,1);
AddColumn(j3,”MA DN”,1);
AddColumn(J4,”ZL DN”,1);
AddColumn(PDIp,”PDIP UP”,1);
AddColumn(pr2,”PHK UP”,1);
AddColumn(PDIm,”PDIP DN”,1);
AddColumn(sr2,”PHk UP”,1);
_SECTION_END();
_SECTION_BEGIN(“Display the Signals”);
Title = “Trading the MACD” + “ – “ + Name() + “ – “ + EncodeColor(colorRed)+
Interval(2) + EncodeColor() +
“ – “ + Date() +” – “ +EncodeColor(colorLime)+ “MACD=
“+WriteVal(m1)+”–”+EncodeColor(colorYellow)+
WriteIf (j1, “ MACD Crossed above zero”,”“)+
WriteIf (j2, “ Bullish crossover above zero”,”“)+
WriteIf (j4, “ MACD Crossed below Zero”,”“)+
WriteIf (j3, “ Bearish crossover above zero”,”“)+
WriteIf (PDIP, “ Bullish Power Dip”,”“)+
WriteIf (pr2, “ & Power Buy”,”“)+
WriteIf (sr2, “ & Power Short”,”“)+
WriteIf (PDIm, “ Bearish Power Dip”,”“)+
WriteIf (Hd1, “ & Bullish Hook”,”“)+
WriteIf (Hu1, “ & Bearish Hook”,”“)+
WriteIf (zlrd1, “ & Bearish zeroline Reject”,”“)+
WriteIf (zlru, “ & Bullish Zeroline Reject”,”“);
_SECTION_END();
_SECTION_BEGIN(“Earth-2”);
//Copyright 9Trading.com
VAR2=(High+Low+(Close)(2))/(4); B = ((EMA((VAR2-LLV(VAR2,15))/(HHV(Low,15)-
LLV(VAR2,15)),2))(38));
Plot(b, ““, 4, 1+4);
bot1 = ((((-1))(EMA((VAR2-LLV(VAR2,15))/(HHV(Low,15)-LLV(VAR2,15)),2))+0.01)
(38));
Plot(bot1, ““, 4, 1+4);
VAR22=((Close-LLV(Low,10))/(HHV(High,10)-LLV(Low,10)))(100);
VAR33=EMA(VAR22,10); VAR44=EMA(VAR33,10); VAR55=(3)(VAR33)-
(2)*(VAR44);
VAR66=EMA(VAR55,5);
BridgeT = (EMA(VAR66,1));
Plot(bridget, ““, IIf(bridget > Ref(bridget,-1),colorBlue,colorYellow), 1+4);
Plot(-bridget, ““, IIf(bridget > Ref(bridget,-1),colorBlue,colorYellow), 1+4);
trend = (5)(EMA(((Close-LLV(Low,27))/(HHV(High,27)-LLV(Low,27)))(100),5))-
(3)(EMA(EMA(((Close-LLV(Low,27))/(HHV(High,27)-LLV(Low,27)))(100),5),3))-
EMA(EMA(EMA(((Close-LLV(Low,27))/(HHV(High,27)-
LLV(Low,27)))*(100),5),3),2);
Buy1 = Cross(trend,5);
PlotShapes( IIf( Buy1, shapeSmallSquare, shapeNone ), colorGreen, layer = 0, yposition
= 0, offset = 3 );
PlotShapes( IIf( Buy1, shapeSmallSquare, shapeNone ),colorGreen, layer = 0, yposition
= 0, offset = -4 );
VARA1=((Close>=Ref(Close,-1)) AND (Ref(Close,-1)>=Ref(Close,-2)) AND
(Ref(Close,-1)<=Ref(Close,-3)) AND (Ref(Close,-2)<=Ref(Close,-3)) AND
((Ref(Close,-4)>Ref(Close,-2)) OR (Ref(Close,-4)<=Ref(Close,-2)) AND (Ref(Close,-
5)>=Ref(Close,-3))) OR (Close>=Ref(Close,-1)) AND (Ref(Close,-1)<=Ref(Close,-2))
AND (Close>=Ref(Close,-2)) AND ((Ref(Close,-3)>Ref(Close,-1)) OR (Ref(Close,-
3)<=Ref(Close,-1)) AND (Ref(Close,-4)>=Ref(Close,-2))));
VARA2=LLV(Low,5);
VARA3=HHV(High,5);
VARA4=EMA(((Close-VARA2)/(VARA3-VARA2))(100),4);
VARA5=EMA((0.66699999)(Ref(VARA4,-1))+(0.333)*(VARA4),2);
VARA6=(VARA5<24) AND (Open<MA(Close,20));
Buy2 =IIf(VARA1 AND (VARA6),30,0);
Plot(Buy2, ““, 8,2+4);
Plot(-Buy2, ““, 8,2+4);
_N(Title = StrFormat(“\c02.{{NAME}} | {{DATE}} | {{VALUES}}”)
+EncodeColor(colorBrightGreen)+WriteIf(Buy2==30,”BuySignal-A”,”“ )
+EncodeColor(colorBrightGreen)+WriteIf(Buy1==1,” | BuySignal-B”,”“));
_SECTION_BEGIN(“Earth-3”);
n = Param(“Periods”, 14, 5, 25, 1 );
var6=(2Close+High+Low)/4; var7=LLV(L,n); var8=HHV(H,n); var9=EMA((var6-
var7)/(var8-var7)100,5);
varA=EMA(0.333Ref(var9,-1)+0.667var9,3);
UP=Var9;
DOWN=Vara;
barcolor2=
IIf( (Ref(up,-1)>Ref(down,-1) AND Ref(up,-1)>up AND up>down )
OR (Ref(up,-1)down,5,4));
Plot(0,”“,barcolor2,styleLine);
_SECTION_END();
_SECTION_BEGIN(“Earth-1”);
EB1 = Close > Ref(Close, -1) AND Ref(Close, -1) > Ref(Close, -2) AND Ref(Close, -1)
< Ref(Close, -3) AND IIf(Ref(Close, -3) < Ref(Close, -4), 1, IIf(Ref(Close, -4) <
Ref(Close, -5),Ref(Close, -1) < Ref(Close, -4) OR( Ref(Close, -2) < Ref(Close, -4) AND
Ref(Close, -3) >= Ref(Close, -5) ),IIf(Ref(Close, -5) < Ref(Close, -6), 1,Ref(Close, -6) <
Ref(Close, -7)))); ES1 = Close < Ref(Close, -1) AND Ref(Close, -1) < Ref(Close, -2)
AND Ref(Close, -1) > Ref(Close, -3) AND IIf(Ref(Close, -3) > Ref(Close, -4), 1,
IIf(Ref(Close, -4) > Ref(Close, -5),Ref(Close, -1) > Ref(Close, -4) OR( Ref(Close, -2) >
Ref(Close, -4) AND Ref(Close, -3) <= Ref(Close, -5) ),IIf(Ref(Close, -5) > Ref(Close, -
6), 1,Ref(Close, -6) > Ref(Close, -7))));
PlotShapes( IIf( EB1, shapeHollowSmallSquare, shapeNone ), colorWhite, layer = 0, 0, 0
);
PlotShapes( IIf( ES1, shapeHollowSmallSquare, shapeNone ), colorOrange, layer = 0, 0,
0 );
_SECTION_END();
_SECTION_BEGIN(“Exploration”);
LastBar = Cum( 1 ) == LastValue( Cum( 1 ) );
Filter = LastBar;
pfrom = Param(“Price From”, 0, 0, 1000, 0.5 );
pto = Param(“Price To”, 1000, 0, 1000, 0.5 );
Minv = Param(“Minimum Volume (K)”, 500, 0, 1000, 50);
dd = Param(“Decimal Digits”, 1.2, 1, 1.7, 0.1 );
EB21= Buy1;
EB22=Buy2;
//Filter = Buy AND C>pfrom AND C1000*Minv;
Color = IIf(Close>Open, colorGreen, colorRed);
bcolor = IIf(Buy1 OR Buy2, colorGreen, 1);
AddTextColumn(WriteIf(EB1,”Buy”,WriteIf(ES1,”Sell”,”“)),”Earth-1″,colorDefault,-1);
AddTextColumn(WriteIf(Buy1==1,”Buy-A”,” “),”Earth-2a”,colorDefault,-1);
AddTextColumn(WriteIf(Buy2==30,”Buy-B”,” “),”Earth-2b”,colorDefault,-1);
AddTextColumn(WriteIf(bridget > Ref(bridget,-1) AND Ref(bridget,-1)Ref(bridget,-
2),”Sell”,”“)),”Earth-2c”,colorDefault,-1);
AddTextColumn(WriteIf(barcolor2==colorBlue,”Modarate”,WriteIf(barcolor2==4,”Buy
”,WriteIf(barcolor2==5,”Sell”,”“))),”Earth-3″,colorDefault,-1);
//AddColumn(Buy, “Buy” , 1.1, bcolor);
//AddColumn(O, “Open”, dd, textColor = Color);
//AddColumn(C, “Close”, dd, textColor = Color);
//AddColumn(V, “Volume”, 1, textColor = Color);
//AddTextColumn(FullName(),”Name”);
_SECTION_END();
// created by chandrakant
//modified on 120309..credit goes to of Karthik sir
/*1. Here are some observations to keep in mind that will help assure
you are in a good trending move which is detrimental to the success
of the trade moving higher before the inevitable over exhausted trend.
2 Consider only going long on the 5M if the 30M (two rows above) is also blue.
3 Consider the 1hr row as well being blue since it has an effect too.
4 The 15M row has to be blue with NO exceptions
5 The 30M row if blue has less effect on the trade as compared to the 15M row
but keep this in mind. The 30M row being blue helps the 15M row continue to stay blue.
6 The 1hr row has even less effect OR importance but it too keeps the 30M
from weakening to some minor degree.
*/
// Define label bar (x) position location
blankRightBars = 5; //insert actual blank right bars specified in Preferences
barsInView = Status(“lastvisiblebarindex”) – Status(“firstvisiblebarindex”) –
blankRightBars;
Offset = Param(“Offset Bar”, 0.95, 0, 1, 0.01);
textOffset = BarCount – (Offset * barsInView);
_SECTION_BEGIN(“default”);
HaClose =EMA((O+H+L+C)/4,3);
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
PlotText(“Heinkein 4T tf :”+Interval(2), textoffset, 41.01, colorYellow);
Color = IIf( Haopen > Haclose,4, IIf( Haopen == Haclose,colorYellow, 6));
Plot(10,”“, Color, styleHistogram+styleThick|styleOwnScale|styleNoLabel, 0, 100 );
Plot( 11,”“,colorBlack,styleOwnScale|styleArea|styleNoLabel,0, 100 );
_SECTION_BEGIN(“4”);
Compress4= Param(“Compression4”,8,2,10,1);
TimeFrameSet(Compress4* Interval());
HaClose4 =EMA((O+H+L+C)/4,3);
HaOpen4 = AMA( Ref( HaClose4, -1 ), 0.5 );
HaHigh4 = Max( H, Max( HaClose4, HaOpen4 ) );
HaLow4 = Min( L, Min( HaClose4, HaOpen4 ) );
PlotText(“Heinkein 4T tf :”+Interval(2), textoffset, 41.14, colorYellow);
TimeFrameRestore();
HAopen4f=TimeFrameExpand( Haopen4, Compress4* Interval());
Haclose4f=TimeFrameExpand( Haclose4, Compress4* Interval());
HaHigh4f=TimeFrameExpand( Hahigh4, Compress4* Interval());
HaLow4f=TimeFrameExpand( Halow4, Compress4* Interval());
Color4 = IIf( Haopen4f > Haclose4f,4, IIf( Haopen4f == Haclose4f ,colorYellow, 6));
Plot(10,”“, Color4, styleHistogram+styleThick|styleOwnScale|styleNoLabel, 0, 100 );
Plot( 41,”“,colorBlack,styleOwnScale|styleArea|styleNoLabel,0, 100 );
_N(Title = “{{NAME}} – {{INTERVAL}} {{DATE}} “+_DEFAULT_NAME()+” :
{{OHLCX}} {{VALUES}}” );

You might also like