_SECTION_BEGIN("Karthik Options ");
////////// http://www.traderji.com/technical-analysis/90669-karthiks-options-trading-strategy-36.html#post904681
// AFL for Karthiks Options Trading Strategy. Implemented by mastermind007. Traderji.
// All rights are Reserved by mastermind007. This notice on top must not be removed ever.
// Disclaimer: Use this code at your risk.
// It is ONLY meant for a bonafide personal non-commercial use for members of Traderji.
// You are not allowed to copy-paste this code on any other site under any circumstances
// Move all Option's data in amibroke to a new market using its organizer and then set market's name here
if (((Interval(0) == 900) OR (Interval(0) == 1800)) AND MarketID(1) == "Options")
{
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 ) ) ));
// Replace this line to color the candles
Plot( Close, "Prices", colorBlack, styleNoTitle | styleCandle );
WMAPeriods = Param(" WMA Periods", 5, 2, 300, 1, 10 );
CCIPeriods = Param(" CCI Periods", 14, 2, 300, 1, 10 );
profitType = ParamToggle("Profit Target as ", "Fixed Value|Percentage", 0);
profitValue = Param("Profit Target Parameter", 10, 1, 100, 1, 1);
wmaHigh = WMA( High, WMAPeriods);
wmaLow = WMA( Low, WMAPeriods);
cciClose = CCI(CCIPeriods);
Plot( wmaHigh, "WMA-H", colorBlue, styleDashed | styleNoLabel);
Plot( wmaLow, "WMA-L", colorRed, styleDashed | styleNoLabel);
Plot( cciClose, "CCI", colorBlack, styleOwnScale | styleNoLine | styleNoLabel );
/////////////////////////////////////////////////////////////////
//IMPLEMENTED Rule 1). We look for the 15 or 30 Min candle to close above High of WMA5
//IMPLEMENTED Rule 2). CCI Reading > 50
//IMPLEMENTED Rule 3). Don't consider the setup when CCI Reading is >=200
//IMPLEMENTED Rule 4). 15 or 30 Min candle should not touch High & Low of WMA5
//NOT IMPLEMENTED "As of now have not made that condition but the trigger can become void if Low of 5WMA touch by the subsequent candle Low. Let me analyse and post it here"
/////////////////////////////////////////////////////////////////
SetupRules = Close > wmaHigh AND cciClose > 50 AND cciClose < 200 AND L > wmaLow;
// Normally trigger price and stop loss price set here is valid only for the next candle after the setup.
// If next candle does not cause a trade to be triggered, setup is discarded
// Problem occurs when two setups can occur one after another; This parameter toggle controls which setup takes precedence.
// However do note that If you've set this parameter to "NO" AND more than 3 setups occur consecutively,
// it will still only look back to one setup prior only.
if (ParamToggle("Use Most Recent Setups", "Yes|No") == 1)
{
//PlotText("aaaaa", SelectedValue(BarIndex()), SelectedValue(Low - 10), colorBlack);
triggerPriceOrig = IIf(Ref(SetupRules, -1) == 1, Ref(High, -1), IIf(SetupRules == 1, High, Null)); // Previous better than Current
stopLossPriceOrig = IIf(Ref(SetupRules, -1) == 1, Ref(Low, -1), IIf(SetupRules == 1, Low, Null)); // Previous better than Current
} else
{
triggerPriceOrig = IIf(SetupRules == 1, High, IIf(Ref(SetupRules, -1) == 1, Ref(High, -1), Null)); // Current better than Previous
stopLossPriceOrig = IIf(SetupRules == 1, Low, IIf(Ref(SetupRules, -1) == 1, Ref(Low, -1), Null)); // Current better than Previous
}
targetPriceOrig = IIf(profitType == 0, triggerPriceOrig + profitValue, triggerPriceOrig * (1 + profitValue/ 100));
// new Setup on current candle causes previous setup to be discarded
/// ENTRY CONDITIONS
/////////////////////////////////////////////////////////////////
// Note that Buy will never trigger on a setup candle if current values are used because
// trade will enter when high is breached and candle can never close above its own high.
tradeTriggered = Ref(SetupRules, -1) == 1 AND Close > triggerPriceOrig;
/////////////////////////////////////////////////////////////////
// Normally, Trigger Price and Stop loss price set are valid only for the next candle after the setup.
// When trade occurs, we need to retain them for display purposes.
// If next candle does not cause a trade, setup is discarded
triggerPrice = ValueWhen(tradeTriggered, triggerPriceOrig);
stopLossPrice = ValueWhen(tradeTriggered, stopLossPriceOrig);
targetPrice = ValueWhen(tradeTriggered, targetPriceOrig);
/////////////////////////////////////////////////////////////////
/// EXIT CONDITIONS
targetAchived = High >= targetPrice;
stopLossHit = Low <= stopLossPrice;
timedOut = TimeNum() >= 153000;
tradeClosed = targetAchived OR stopLossHit OR timedOut ;
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
/// DISCARD EXCESS SIGNALS
/////////////////////////////////////////////////////////////////
Buy = ExRem(tradeTriggered, tradeClosed);
Sell = ExRem(tradeClosed, tradeTriggered);
Short = Cover=Null;
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// DISPLAY DEPARTMENT
//for( i = 0; i < BarCount; i++ )
//{
//// USE EITHER THIS
//if( Buy[i] ) PlotText( "Entry @ " + NumToStr(triggerPrice[i]), i, L[ i ]-dist[i], colorGreen );
//if( Sell[i] ) PlotText( "Exit @ " + NumToStr(targetPrice[i]), i, H[ i ]+dist[i],colorRed);
//// OR THIS
//if( Buy[i] ) PlotText( "Entry @ " + NumToStr(triggerPrice[i]) + NumToStr(targetPrice[i]), i, L[ i ]-dist[i], colorGreen );
//}
// Blue Circle indicates setup created
PlotShapes(IIf(SetupRules, shapeHollowCircle, shapeNone),colorBlue, 0,L, Offset=-10);
// Red dot indicates that the setup created on prior candle has failed
// Sometimes, you will see red dot inside a blue candle.
// This means that new setup was created on candle that was actually being watched for entry
PlotShapes(IIf(Ref(SetupRules,-1) AND NOT tradeTriggered, shapeSmallCircle, shapeNone),colorRed, 0,L, Offset=-10);
PlotShapes(IIf(Buy , shapeUpArrow, shapeNone),colorGreen, 0,L, Offset=-25);
// Down arrow inside a Circle means target was achieved
PlotShapes(IIf(targetAchived AND Sell, shapeDownArrow, shapeNone),colorRed, 0,H, Offset=-15);
PlotShapes(IIf(targetAchived AND Sell, shapeHollowCircle, shapeNone),colorRed, 0,H, Offset=10);
// Down arrow inside a square means stop loss was hit
PlotShapes(IIf(stopLossHit AND Sell, shapeDownArrow , shapeNone),colorRed, 0,H, Offset=-20);
PlotShapes(IIf(stopLossHit AND Sell, shapeHollowSquare , shapeNone),colorRed, 0,H, Offset=15);
} else
{
Title = "Sorry, This AFL is meant to work only for 15 or 30 minute time frame in Options Market Only";
}
_SECTION_END();