Mr.Karthick EMA and CCI Strategy.
======================================================
Let's go to the strategy!!
Setup
1). Timeframe : 5min chart
2). EMA : 110 period
3). CCI : 14 days
Why EMA 110? To be frank no idea but when tested proved with results to guage the TREND!
RULE
BUY / GO LONG CONDITION
a). The 5 min candle should be above 110 EMA.
b). CCI should be > 100. We consider CCI reading only for ENTRY not for EXIT. This CCI will act as a FILTER to avoid false Traps
c). A 0.10% filter on the High price
SELL / GO SHORT CONDITION
a). The 5 min candle should be below 110 EMA.
b). CCI should be < -100. We consider CCI reading only for ENTRY and not for EXIT. This CCI will act as a FILTER to avoid false Traps
c). A 0.10% filter on the Low price
EXIT : Rs.10/- min
SL : Rs.10/- (as I want to keep RR as 1:1)
Recommended Scrips : MARUTI, AXISBANK, LT, TCS, ICICIBANK & SBI
I have tested the strategy with the above scrips and hence posted as recommendation. Why I have selected the above scrip is bacause of the highly traded volume.
I will explain in detail with the Charts
Karthik
=========================================================
I am trying to create AFL for Above Mr.Karthick's Strategy.
AFL Code :
TimeFrameSet( in5Minute);
dec = (Param("Decimals",2,0,7,1)/10)+1;
EMA110=EMA(C,110);
pt=CCI()>100;nt=CCI()<-100;
Buy2show = 0;
Sell2show = 0;
// Check if it is time to close the postions.
EOD = IIf(TimeNum()>152900, 1, 0);
noEOD = IIf(TimeNum() < 152900,1, 0);
// Logic for uptrend or downtrend
uptrend = C>EMA110 AND pt;
downtrend=C<EMA110 AND nt;
// Ignore the previous day bar
Datefine = IIf(Ref(DateNum(),1) == Ref(DateNum(),-1),1,0);
// The current bar should be more than previous bar value + 0.1% for buy in uptrend
BuyV = uptrend AND Ref(uptrend, -1) AND (H > ( Ref(H, -1)+ H*.001 )) AND Datefine ;
// the current bar should be less than previous bar value - 0.1% for sell in downtrend
SellV = downtrend AND Ref(downtrend,-1) AND (L < ( Ref(L, -1)-L*.001 )) AND Datefine ;
// Bars since previous buy or sell signal.
BuySB = BarsSince(Ref(BuyV,-1)) ;
SellSB= BarsSince(Ref(SellV,-1));
BuyPrice = IIf(BuyV==1 AND BuySB > SellSB ,Max(O,Ref(H,-1)+H*.001 ),0);
SellPrice = IIf(SellV==1 AND BuySB < SellSB ,Min(O,Ref(L,-1)-L*.001 ),0);
Bp = ValueWhen(BuyPrice !=0,BuyPrice);
Sp = ValueWhen(SellPrice !=0,SellPrice);
// We can signal buy only if previous signal was a sell.
Buy = BuyV AND BuySB > SellSB AND Datefine ;
// We can signal sell only if previous signal was a buy.
Sell =SellV AND BuySB < SellSB AND Datefine ;
//Cover = BuyPrice;
//Short = SellPrice;
CP = 0;
Trend = 1;
//***************************************************************************************//
for( i = 0; i < BarCount; i++ )
{
if( Buy )
{
PlotText( "\n"+"\n"+"\n"+"Buy@" +WriteVal( Bp[ i],1.2), i-5, L[ i ]-Trend, colorWhite, colorBlue);
Buy2show=Bp;
}
if( Sell )
{
PlotText( "\n"+"\n"+"\n"+"Sell@" +WriteVal (Sp[ i ],1.2), i-5, L[ i ]+Trend, colorWhite, colorRed );
Sell2show=Sp;
}
}
SetChartOptions(0, chartShowDates);
//Plot(C,"\nC",colorWhite,64);
PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorGreen,0,L,-15);
PlotShapes(IIf(Buy,shapeHollowUpArrow,shapeNone),colorWhite,0,L,-15);
PlotShapes(IIf(Buy,shapeHollowSmallCircle,shapeNone),colorWhite,0,BuyPrice,0);
PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorRed,0,H,-15);
PlotShapes(IIf(Sell,shapeHollowDownArrow,shapeNone),colorWhite,0,H,-15);
PlotShapes(IIf(Sell,shapeHollowSmallCircle,shapeNone),colorWhite,0,SellPrice,0);
//PlotShapes(IIf(Short,shapeDownArrow,shapeNone),colorYellow,0,H,-15);
//PlotShapes(IIf(Cover,shapeUpArrow,shapeNone),colorYellow,0,L,-15);
_SECTION_BEGIN("Price");
Graph0 = Close;
Graph0Style = 128;
barcolor = IIf( downtrend, colorRed, IIf( uptrend, colorGreen ,colorWhite ) );
Graph0BarColor = ValueWhen( barcolor != 0, barcolor );
SetBarFillColor( IIf( downtrend,colorRed, colorGreen) );
SetChartBkGradientFill( ParamColor("BgTop", colorBlack),ParamColor("BgBottom", colorBlack),ParamColor("Titleblock",colorLightGrey));
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Uptrend %g,Open %g, Hi %g, Lo %g,Close %g (%.1f%%) {{VALUES}}", uptrend,O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
ToolTip=StrFormat("Open: %g\nHigh: %g\nLow: %g\nClose: %g (%.1f%%)\nVolume: "+NumToStr( V, 1 ), O, H, L, C) + "\n" + "\n" ;
Plot( C, "Close", ParamColor("Color", colorWhite ), styleNoTitle |
ParamStyle("Style") | GetPriceStyle() );
Plot( 2, /* defines the height of the ribbon in percent of pane width*/ "ribbon",
IIf( uptrend, colorGreen, IIf( downtrend, colorRed, colorTan )), /* choose color */
styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
//filters
Filter=Buy | Sell;
SetOption("NoDefaultColumns", True);
AddTextColumn(Name(), "SYMBOL");
AddColumn(DateTime(), "DATE", formatDateTime);
AddColumn(TimeNum() ,"Time",1, 75);
AddColumn(IIf(Buy, 66, 83), "TRIGGER", formatChar, colorWhite, IIf(Buy, colorGreen, colorRed));
AddColumn(IIf(Buy, BuyPrice,SellPrice), "TRIG PRICE", 1.2);
AddColumn(IIf(Buy, (BuyPrice)+10, (SellPrice)-10), "Target", 1.2);
AddColumn(IIf(Buy, (BuyPrice)-10, (SellPrice)+10), "Stop Loss", 1.2);
AddColumn(C, "Last Close", 1.2);
SetSortColumns( -3 );Title = EncodeColor(29)+ Title = Name() + " " + EncodeColor(32)
+ Date() + " " + EncodeColor(29) + "{{INTERVAL}} " +
EncodeColor(29)+ " Open = "+ EncodeColor(17)+ NumToStr
(O,dec) +
EncodeColor(29)+ " High = "+ EncodeColor(17) + NumToStr
(H,dec) +
EncodeColor(29)+ " Low = "+ EncodeColor(17)+ NumToStr
(L,dec) +
EncodeColor(29)+ " Close = "+ EncodeColor(17)+ NumToStr
(C,dec) +
EncodeColor(29)+ " Volume = "+ EncodeColor(17)+ NumToStr
(V,1.0) +"\n"+"\n"+
WriteIf (Buy , " GO LONG / Reverse Signal at "+BuyPrice+" ","")+
WriteIf (Sell , " EXIT LONG / Reverse Signal at "+SellPrice+" ","")+"\n"+EncodeColor(colorWhite)+
WriteIf(Sell , "Total Profit/Loss for the Last Trade Rs."+(SellPrice-Bp)+"","")+
WriteIf(Buy , "Total Profit/Loss for the Last trade Rs."+(Sp-BuyPrice)+"","");
GraphXSpace=12;
_SECTION_BEGIN("EMA2");
P = ParamField("Price field",-1);
Periods = Param("Periods", 110, 2, 300, 1, 10 );
Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorBlue ), ParamStyle("Style",styleThick) );
_SECTION_END();
========================================================
I like to add below condition :-
1) If I have Long position still 3.25 then I should show here Sell(or Short) signal in chart .
2) If I have Short position still 3.25 then I should show here Buy(or Cover) signal in chart .
3) Fresh Day first Signal dont check previous signal is buy or sell.
Example :- Current day sell signal come as per above strategy, Last Day Trade signal also show sell in chart in this condition, current day first sell signal not show in chart. (If Last Trade day Last signal show Buy signal then show today's first trade sell signal correctly ).
Here I attached Screenshot :-
=======================
Axisbank Futures:
=============
Yesterday Axisbank futures Show Last Signal sell @ 9.20 a.m. (only one trade). Today also Sell signal should come @ 11 a.m. But not show in chart.
Tcs Futures :
===========
Yesterday Tcs futures Show Last Signal Buy @ 3.20 a.m. Today Sell Signal is Correctly showing @ 9.20 a.m.
======================================================
Let's go to the strategy!!
Setup
1). Timeframe : 5min chart
2). EMA : 110 period
3). CCI : 14 days
Why EMA 110? To be frank no idea but when tested proved with results to guage the TREND!
RULE
BUY / GO LONG CONDITION
a). The 5 min candle should be above 110 EMA.
b). CCI should be > 100. We consider CCI reading only for ENTRY not for EXIT. This CCI will act as a FILTER to avoid false Traps
c). A 0.10% filter on the High price
SELL / GO SHORT CONDITION
a). The 5 min candle should be below 110 EMA.
b). CCI should be < -100. We consider CCI reading only for ENTRY and not for EXIT. This CCI will act as a FILTER to avoid false Traps
c). A 0.10% filter on the Low price
EXIT : Rs.10/- min
SL : Rs.10/- (as I want to keep RR as 1:1)
Recommended Scrips : MARUTI, AXISBANK, LT, TCS, ICICIBANK & SBI
I have tested the strategy with the above scrips and hence posted as recommendation. Why I have selected the above scrip is bacause of the highly traded volume.
I will explain in detail with the Charts
Karthik
=========================================================
I am trying to create AFL for Above Mr.Karthick's Strategy.
AFL Code :
TimeFrameSet( in5Minute);
dec = (Param("Decimals",2,0,7,1)/10)+1;
EMA110=EMA(C,110);
pt=CCI()>100;nt=CCI()<-100;
Buy2show = 0;
Sell2show = 0;
// Check if it is time to close the postions.
EOD = IIf(TimeNum()>152900, 1, 0);
noEOD = IIf(TimeNum() < 152900,1, 0);
// Logic for uptrend or downtrend
uptrend = C>EMA110 AND pt;
downtrend=C<EMA110 AND nt;
// Ignore the previous day bar
Datefine = IIf(Ref(DateNum(),1) == Ref(DateNum(),-1),1,0);
// The current bar should be more than previous bar value + 0.1% for buy in uptrend
BuyV = uptrend AND Ref(uptrend, -1) AND (H > ( Ref(H, -1)+ H*.001 )) AND Datefine ;
// the current bar should be less than previous bar value - 0.1% for sell in downtrend
SellV = downtrend AND Ref(downtrend,-1) AND (L < ( Ref(L, -1)-L*.001 )) AND Datefine ;
// Bars since previous buy or sell signal.
BuySB = BarsSince(Ref(BuyV,-1)) ;
SellSB= BarsSince(Ref(SellV,-1));
BuyPrice = IIf(BuyV==1 AND BuySB > SellSB ,Max(O,Ref(H,-1)+H*.001 ),0);
SellPrice = IIf(SellV==1 AND BuySB < SellSB ,Min(O,Ref(L,-1)-L*.001 ),0);
Bp = ValueWhen(BuyPrice !=0,BuyPrice);
Sp = ValueWhen(SellPrice !=0,SellPrice);
// We can signal buy only if previous signal was a sell.
Buy = BuyV AND BuySB > SellSB AND Datefine ;
// We can signal sell only if previous signal was a buy.
Sell =SellV AND BuySB < SellSB AND Datefine ;
//Cover = BuyPrice;
//Short = SellPrice;
CP = 0;
Trend = 1;
//***************************************************************************************//
for( i = 0; i < BarCount; i++ )
{
if( Buy )
{
PlotText( "\n"+"\n"+"\n"+"Buy@" +WriteVal( Bp[ i],1.2), i-5, L[ i ]-Trend, colorWhite, colorBlue);
Buy2show=Bp;
}
if( Sell )
{
PlotText( "\n"+"\n"+"\n"+"Sell@" +WriteVal (Sp[ i ],1.2), i-5, L[ i ]+Trend, colorWhite, colorRed );
Sell2show=Sp;
}
}
SetChartOptions(0, chartShowDates);
//Plot(C,"\nC",colorWhite,64);
PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorGreen,0,L,-15);
PlotShapes(IIf(Buy,shapeHollowUpArrow,shapeNone),colorWhite,0,L,-15);
PlotShapes(IIf(Buy,shapeHollowSmallCircle,shapeNone),colorWhite,0,BuyPrice,0);
PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorRed,0,H,-15);
PlotShapes(IIf(Sell,shapeHollowDownArrow,shapeNone),colorWhite,0,H,-15);
PlotShapes(IIf(Sell,shapeHollowSmallCircle,shapeNone),colorWhite,0,SellPrice,0);
//PlotShapes(IIf(Short,shapeDownArrow,shapeNone),colorYellow,0,H,-15);
//PlotShapes(IIf(Cover,shapeUpArrow,shapeNone),colorYellow,0,L,-15);
_SECTION_BEGIN("Price");
Graph0 = Close;
Graph0Style = 128;
barcolor = IIf( downtrend, colorRed, IIf( uptrend, colorGreen ,colorWhite ) );
Graph0BarColor = ValueWhen( barcolor != 0, barcolor );
SetBarFillColor( IIf( downtrend,colorRed, colorGreen) );
SetChartBkGradientFill( ParamColor("BgTop", colorBlack),ParamColor("BgBottom", colorBlack),ParamColor("Titleblock",colorLightGrey));
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Uptrend %g,Open %g, Hi %g, Lo %g,Close %g (%.1f%%) {{VALUES}}", uptrend,O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
ToolTip=StrFormat("Open: %g\nHigh: %g\nLow: %g\nClose: %g (%.1f%%)\nVolume: "+NumToStr( V, 1 ), O, H, L, C) + "\n" + "\n" ;
Plot( C, "Close", ParamColor("Color", colorWhite ), styleNoTitle |
ParamStyle("Style") | GetPriceStyle() );
Plot( 2, /* defines the height of the ribbon in percent of pane width*/ "ribbon",
IIf( uptrend, colorGreen, IIf( downtrend, colorRed, colorTan )), /* choose color */
styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
//filters
Filter=Buy | Sell;
SetOption("NoDefaultColumns", True);
AddTextColumn(Name(), "SYMBOL");
AddColumn(DateTime(), "DATE", formatDateTime);
AddColumn(TimeNum() ,"Time",1, 75);
AddColumn(IIf(Buy, 66, 83), "TRIGGER", formatChar, colorWhite, IIf(Buy, colorGreen, colorRed));
AddColumn(IIf(Buy, BuyPrice,SellPrice), "TRIG PRICE", 1.2);
AddColumn(IIf(Buy, (BuyPrice)+10, (SellPrice)-10), "Target", 1.2);
AddColumn(IIf(Buy, (BuyPrice)-10, (SellPrice)+10), "Stop Loss", 1.2);
AddColumn(C, "Last Close", 1.2);
SetSortColumns( -3 );Title = EncodeColor(29)+ Title = Name() + " " + EncodeColor(32)
+ Date() + " " + EncodeColor(29) + "{{INTERVAL}} " +
EncodeColor(29)+ " Open = "+ EncodeColor(17)+ NumToStr
(O,dec) +
EncodeColor(29)+ " High = "+ EncodeColor(17) + NumToStr
(H,dec) +
EncodeColor(29)+ " Low = "+ EncodeColor(17)+ NumToStr
(L,dec) +
EncodeColor(29)+ " Close = "+ EncodeColor(17)+ NumToStr
(C,dec) +
EncodeColor(29)+ " Volume = "+ EncodeColor(17)+ NumToStr
(V,1.0) +"\n"+"\n"+
WriteIf (Buy , " GO LONG / Reverse Signal at "+BuyPrice+" ","")+
WriteIf (Sell , " EXIT LONG / Reverse Signal at "+SellPrice+" ","")+"\n"+EncodeColor(colorWhite)+
WriteIf(Sell , "Total Profit/Loss for the Last Trade Rs."+(SellPrice-Bp)+"","")+
WriteIf(Buy , "Total Profit/Loss for the Last trade Rs."+(Sp-BuyPrice)+"","");
GraphXSpace=12;
_SECTION_BEGIN("EMA2");
P = ParamField("Price field",-1);
Periods = Param("Periods", 110, 2, 300, 1, 10 );
Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorBlue ), ParamStyle("Style",styleThick) );
_SECTION_END();
========================================================
I like to add below condition :-
1) If I have Long position still 3.25 then I should show here Sell(or Short) signal in chart .
2) If I have Short position still 3.25 then I should show here Buy(or Cover) signal in chart .
3) Fresh Day first Signal dont check previous signal is buy or sell.
Example :- Current day sell signal come as per above strategy, Last Day Trade signal also show sell in chart in this condition, current day first sell signal not show in chart. (If Last Trade day Last signal show Buy signal then show today's first trade sell signal correctly ).
Here I attached Screenshot :-
=======================
Axisbank Futures:
=============
Yesterday Axisbank futures Show Last Signal sell @ 9.20 a.m. (only one trade). Today also Sell signal should come @ 11 a.m. But not show in chart.
Tcs Futures :
===========
Yesterday Tcs futures Show Last Signal Buy @ 3.20 a.m. Today Sell Signal is Correctly showing @ 9.20 a.m.