Skip to main content

Mother Candle Formation Strategy for Amibroker (AFL)

joby Kumar over 8 years ago Amibroker (AFL)

  • Rating:
    5 / 5 (Votes 2)
  • Tags:
    amibroker, pattern, candlestick, trading system

Here is another Trade Plan using simple candlestick analysis.

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”. Plugin should be placed into amibroker (c/programfiles/amibroker/plugins) folder.This AFL will work only if microsoft visual c++ 2017 redistributable package (x86). You Can download from microsoft website https://go.microsoft.com/fwlink/?LinkId=746571.

Please Use Amibroker 6.0 above version For error Free trading Experience

Files

Indicator / Formula

Copy & Paste Friendly
_SECTION_BEGIN( "Mother Candle Formation Strategy" );

/*

Here is another Trade Plan using simple candlestick analysis.
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 or 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".
Plugin should be placed into amibroker (c/programfiles/amibroker/plugins) folder.
This AFL will work only if microsoft visual c++ 2017 redistributable package (x86).
You Can dowload from microsoft website https://go.microsoft.com/fwlink/?LinkId=746571.

Created By Viatrades Algo Team.
viatradess@gmail.com
*/

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();

13 comments

over 8 years ago

Hi MANIIS123,
Use amibroker version above 6.0 for better results and please follow the below steps
1) Download the Plugin attached
2) Plugin should be placed into amibroker (c/programfiles/amibroker/plugins) folder.
3)This AFL will work only if microsoft visual c++ 2017 redistributable package (x86) is Installed.
You Can dowload from microsoft website https://go.microsoft.com/fwlink/?LinkId=746571.

over 8 years ago

What antivirus are you using and what was the warning? The file was checked using virustotal before it was approved and nothing was found:

https://www.virustotal.com/#/file/d21c25440e6996ec174cdd8af1fb448b924270d9a1c3b3326f0ff4690a2b52a1/detection

6. SPASHA
over 8 years ago

HI,ADMIN

THW ABOVE STRATEGY IS NOT EXECUTING SELL AND COVER ORDERS AS PER STRATEGY ,
THOUGH BUY AND SHORTS ARE GETTING

THANKS.

about 8 years ago

Hi SPASHA ,
I have checked the STRATEGY in all algo system, it working perfectly
thanks

8. pankit
about 8 years ago

get synax error 30 identifier mother candle is unidentified

about 8 years ago

still lot of errors
1. mother candle undefined
2.Buytrig not intiated etc

about 8 years ago

we are using a plugin named “MotherCandle”.
Plugin should be placed into amibroker (c/programfiles/amibroker/plugins) folder.
This AFL will work only if microsoft visual c++ 2017 redistributable package (x86).
You Can dowload from microsoft website https://go.microsoft.com/fwlink/?LinkId=746571.

12. ninhhv90
over 7 years ago

I installed successfully. But do not show buy / sell signals. Please help me.

13. ronnie
almost 7 years ago

Awsome sir thanks for this afl..
Giving accurate signals..
In my system sell orders are not getting in backtest.
Buy getting triggred with good profit.
In some scripts this afl working like we are running the market

Leave Comment

Please login here to leave a comment.