AFL for Mother Candle Formation Strategy

MarketSecrets - Learn To Trade Like a Pro

AFL for Mother Candle Formation Strategy

The idea on this strategy is to catch a break from a sudden move of a big candle move. It can be done on any time series of chart, but recommended on the 10 to 60 minute charts. Only one trade Per symbol per day, recommended to trade in minimum 7 symbols (mini lots). Optimization can be done only on profit and target for Entry we are using a plugin named “MotherCandle”.

Script:
_SECTION_BEGIN( “Mother Candle Formation Strategy” );

SetPositionSize( 1, spsShares );
SetBarsRequired( sbrAll, sbrAll );

SetChartOptions( 0, chartShowArrows | chartShowDates );
SetChartBkGradientFill( colorBlack, colorBlack, colorBlack );
Plot( C, “”, IIf( C > O, colorBlueGrey, IIf( C <= O, colorOrange, colorLightGrey ) ), 64 | styleNoTitle, 0, 0, 0, 0 );

GraphXSpace = 10;

DN = DateNum();
TN = TimeNum();

function Asign( x )
{
y = Null;

for( i = 0; i < BarCount; i++ )
{
y[i] = x;
}

return y;
}

Target = Param( “Target %”, 1, 0.1, 50, 0.01 ) / 100;
StopLoss = Param( “Stop Loss %”, 0.75, 0.1, 50, 0.01 ) / 100;
DaysTrades = Param( “Trades / Day”, 2, 0, 50, 1 );

DayStart = DN != Ref( DN, -1 );
DayEnd = Ref( DayStart, 1 );
////If below line ( MotherCandle();) is in Black color please install microsoft visual c++ 2017 redistributable package (x86).
//you Can dowload from microsoft website” https://go.microsoft.com/fwlink/?LinkId=746571 “.
MotherCandle();

Buy = Asign( False );
Sell = Asign( False );
Short = Asign( False );
Cover = Asign( False );

BuyPrice = Null;
ShortPrice = Null;

BYPRSV = Null;
SHPRSV = Null;

LF1 = False;
LF2 = False;
SF1 = False;
SF2 = False;

LSL = Null;
SSL = Null;

LTGT = Null;
STGT = Null;

count = 0;

for( i = 1; i < BarCount; i++ )
{
if( DayStart[i] == True )
{
count = 0;
}

// Long Trade
if( BuyTrig[i] != 0 && High[i] >= BuyTrig[i] && LF1 == False && LF2 == False && DayStart[i] == False && count < DaysTrades )
{
Buy[i] = True;
LF1 = True;
BYPRSV = BuyTrig[i];

if( Open[i] > BYPRSV )
{
BYPRSV = Open[i];
}

LF2 = True;
count++;
}

if( LF1 == False && Close[i – 1] < BuyTrig[i] )
{
LF2 = False;
}

if( LF1 == True )
{
BuyPrice[i] = BYPRSV;
LSL[i] = BYPRSV – ( BYPRSV * StopLoss );
LTGT[i] = BYPRSV + ( BYPRSV * Target );
}

if( LF1 == True && High[i] > LTGT[i] )
{
Sell[i] = True;
SellPrice[i] = Close[i];
LF1 = False;
BuyPrice[i] = Null;
LSL[i] = Null;
LTGT[i] = Null;
}

if( LF1 == True && Low[i] < LSL[i] )
{
Sell[i] = True;
SellPrice[i] = Close[i];
LF1 = False;
BuyPrice[i] = Null;
LSL[i] = Null;
LTGT[i] = Null;
}

if( LF1 == True && DayEnd[i] == True )
{
Sell[i] = True;
SellPrice[i] = Close[i];
LF1 = False;
BuyPrice[i] = Null;
LSL[i] = Null;
LTGT[i] = Null;
}

// Short Trade
if( ShortTrig[i] != 0 && Low[i] < ShortTrig[i] && SF1 == False && SF2 == False && DayStart[i] == False && count < DaysTrades )
{
Short[i] = True;
SF1 = True;
SHPRSV = ShortTrig[i];

if( Open[i] < SHPRSV )
{
SHPRSV = Open[i];
}

SF2 = True;
count++;
}

if( SF1 == False && Close[i – 1] > ShortTrig[i] )
{
SF2 = False;
}

if( SF1 == True )
{
ShortPrice[i] = SHPRSV;
SSL[i] = SHPRSV + ( SHPRSV * StopLoss );
STGT[i] = SHPRSV – ( SHPRSV * Target );
}

if( SF1 == True && Low[i] < STGT[i] )
{
Cover[i] = True;
CoverPrice[i] = Close[i];
SF1 = False;
ShortPrice[i] = Null;
SSL[i] = Null;
STGT[i] = Null;
}

if( SF1 == True && High[i] > SSL[i] )
{
Cover[i] = True;
CoverPrice[i] = Close[i];
SF1 = False;
ShortPrice[i] = Null;
SSL[i] = Null;
STGT[i] = Null;
}

if( SF1 == True && DayEnd[i] == True )
{
Cover[i] = True;
CoverPrice[i] = Open[i];
SF1 = False;
ShortPrice[i] = Null;
SSL[i] = Null;
STGT[i] = Null;
}
}

Plot( BuyPrice, “Buy Price”, colorYellow, styleStaircase | styleDashed );
Plot( LTGT, “Long Target”, colorBrightGreen, styleStaircase | styleDashed );
Plot( LSL, “Long Stop Loss”, colorCustom12, styleStaircase | styleDashed );

Plot( ShortPrice, “Short Price”, colorYellow, styleStaircase | styleDashed );
Plot( STGT, “Short Target”, colorBrightGreen, styleStaircase | styleDashed );
Plot( SSL, “Short StopLoss”, colorCustom12, styleStaircase | styleDashed );

PlotShapes( IIf( Buy, shapeUpArrow, shapeNone ), colorBlueGrey, 0, Low, -15, 0 );
PlotShapes( IIf( Short, shapeDownArrow, shapeNone ), colorOrange, 0, High, -15, 0 );
PlotShapes( IIf( Cover, shapeCircle, shapeNone ), colorBlueGrey, 0, Low, -35, 0 );
PlotShapes( IIf( Sell, shapeCircle, shapeNone ), colorOrange, 0, High, 35, 0 );

_SECTION_END();

error: Content is protected !!