Skip to main content

MAGIC TREND



*/
/*Magical Trend Indicator with update
Created By : Rakesh Solanki
For www.nascenttraders.com
Date: 11/02/2017  Cost 4500/- inr */
_SECTION_BEGIN("Magic Trend Indicator Update");
SetBarsRequired(sbrAll,sbrAll);
SetFormulaName( "Magic Trend Indicator Update" );
SetOption( "Initialequity", 100000 );
SetOption( "AccountMargin", 0.25 );
SetOption( "MinShares", 1 );
MaxOpenPos = Param( "MaxOpenPos", 20, 1, 200, 1 );
SetOption( "MaxOpenPositions", MaxOpenPos );
SetOption( "PriceBoundChecking", 1 );
SetOption( "CommissionMode", 1 );
SetOption( "CommissionAmount", 0.01 );
PositionSize = -400 / ( MaxOpenPos );
P = Param("Period",20,2,25,1);
m = Param("Multiplier",3,0.1,5,0.1);
A = ATR(P);
for(i=0;i<P;i++)
{
 S[i] = C[i]-m*(A[i]);
 T[i] = 1;
}
for(i=P;i<BarCount;i++)
{
 if(C[i] > S[i-1])
 {
 if(T[i-1]==1)
 {
 S[i] = Max(C[i] - m*A[i],S[i-1]);
 T[i] = 1;
 }
 else
 {
 S[i] = C[i] - m*A[i];
 T[i] = 1;
 }

 }
 else
 {
 if(T[i-1]==-1)
 {
 S[i] = Min(C[i] + m*A[i],S[i-1]);
 T[i] = -1;
 }
 else
 {
 S[i] = C[i] + m*A[i];
 T[i] = -1;
 }
 }
}
Buy = Cover = C>S;
Short = Sell = C<S;
Buy = ExRem(Buy,Sell OR Short);
Sell = ExRem(Sell,Buy);
Short = ExRem(Short,Cover OR Buy);
Cover = ExRem(Cover,Short);
BuyPrice = ValueWhen(Buy,C,1);
SellPrice = ValueWhen(Sell,C,1);
ShortPrice = ValueWhen(Short,C,1);
CoverPrice = ValueWhen(Cover,C,1);
Offset = -12;
PlotShapes(Buy*shapeUpArrow,colorBrightGreen,0,Min(S,L),Offset);
PlotShapes(Short*shapeDownArrow,colorRed,0,Max(S,H),Offset);
PlotShapes(Cover*shapeHollowUpArrow,colorBrightGreen,0,Min(S,L),Offset);
PlotShapes(Sell*shapeHollowDownArrow,colorRed,0,Max(S,H),Offset);
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(S,"STOP",IIf(C>S,colorBrightGreen,colorRed),styleDots|styleStaircase|styleThick|styleNoTitle );
PlotOHLC(O,H,L,C,"Close",colorDefault,styleCandle|styleNoTitle);
GfxSetOverlayMode(1);
GfxSelectFont("Verdana", 12, 800, True );
GfxSetBkMode(0);
GfxSetTextColor(ColorRGB(18,18,18));
GfxTextOut("Created By: Rakesh Solanki", 800 , 430 );
GfxSelectFont("Verdana", 14, 800, True );
GfxSetBkMode(1);
GfxTextOut("www.nascenttraders.com" , 800 ,400 );
Open_Long = Flip( Buy, Sell );
Open_Short = Flip( Sell, Buy );
Buy_Price = ValueWhen( Buy, BuyPrice, 1 );
Short_Price = ValueWhen( Short, ShortPrice, 1 );
Sell_Price = IIf( Sell, ValueWhen( Sell, SellPrice, 1 ), Short_Price );
Cover_Price = IIf( Cover, ValueWhen( Cover, CoverPrice, 1 ), Buy_Price );
Profit = IIf( Open_Long, ( Close - Buy_Price ), IIf( Open_Short, ( Short_Price - Close ), 0 ) );
Last_Profit = IIf( Ref( Open_Long, -1 ) == 1 AND Open_Long != 1, ( Sell_Price - Buy_Price ), IIf( Ref( Open_Short, -1 ) == 1 AND Open_Short != 1, ( Short_Price - Cover_Price ), 0 ) );
Cum_Profit[0] = Last_Profit[0];
PreviousProfit = ValueWhen(Last_Profit!=0,Last_Profit,1);
for ( i = 1;i < BarCount;i++ )
{
 Cum_Profit[i] = Cum_Profit[i-1] + Last_Profit[i];
}
Trade[0] = 0;
for ( i = 1;i < BarCount;i++ )
{
 if ( Buy[i] == 1 OR Short[i] == 1 )
 {
 Trade[i] = Trade[i-1] + 1;
 }
 else
 {
 Trade[i] = Trade[i-1];
 }
}
// Trade Report //
TR = ParamToggle( "Trade Report", "Show|Hide", 1 );

if ( TR == 1 )
{
 GfxSelectFont( "Verdana", 10, 100 );
 GfxSetBkMode( 1 );
 GfxSetTextColor( ColorRGB(50,50,50) );
 y = Status( "pxchartheight" );

 GfxTextOut( ( "Total Trades : " + WriteVal( Trade, 3.0 ) ), 13, y - 125 );
 GfxTextOut( ( "Total Profit : " + WriteVal( Cum_Profit, 4.2 ) ), 13, y - 100 );
 GfxTextOut( ( "Previous Profit : " + WriteVal( PreviousProfit, 2.2 ) ), 13, y - 50 );
 GfxTextOut( ( "Price : " + WriteVal( Close, 2.2 ) ), 13, y - 75 );
 GfxTextOut( ( "Current Profit : " + WriteVal( Profit, 2.2 ) ), 13, y - 25 );
}
_SECTION_END();

Comments

Popular posts from this blog

STAN WEINSTEIN'S STRATEGY - Halan Manoj Kumar

// THIS AFL INCORPORATES MOST OF THE CONCEPTS OF STAN WEINSTEINS TRADING METHODOLOGY. // USE ONLY WEEKLY CHART. // THIS AFL DOES NOT GUARANTEE ANY POSITIVE RETURNS. // USE THIS AFL AT YOUR OWN RISK // THIS AFL WAS DEVELOPED BY HALAN MANOJ KUMAR, MSC,CAIIB,FRM,PRM,CMA,ACMA. HOWEVER IN SOME CASES INDIVIDUAL CODE SNIPPETS ARE FROM DIFFERENT SOURCES AND I THANK THOSE DEVELOPERS. // ANY CONCEPTUAL QUERIES OR COMMENTS CAN BE MAILED TO scorpiomanoj73@gmail.com _SECTION_BEGIN("CHART"); SetChartOptions(0,chartShowArrows|chartShowDates); _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%)", O, H, L, C, SelectedValue( ROC( C, 1 ) ) )); Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); _SECTION_END(); //RELATIVE STRENGTH // IF YOUR NIFTY TRADING SYMBOL IS DIFFERENT, PLEASE USE THAT INSTEAD OF ONE MENTIONED HERE. rsmaPeriod...

10K AFL FREE INTRADAY TRADING.afl

_SECTION_BEGIN("Price1"); SetChartOptions(0,chartShowArrows|chartShowDates); Plot( C, "Close", ParamColor("Color", colorRed ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); _SECTION_END(); //_SECTION_BEGIN("Pivot")     YH = TimeFrameGetPrice("H", inDaily, -1);        // yesterdays high     YL = TimeFrameGetPrice("L", inDaily, -1);        //                low     YC = TimeFrameGetPrice("C", inDaily, -1);        //                close     YO = TimeFrameGetPrice("O", inDaily);            // current day open     //Normal Pivot     PP = (YH + YL + YC) / 3;     R1 = (2 * PP) - YL;     R2 = PP + (YH - YL); ...

Wilders Most Succesful Intraday Intraday

PM1 = Param("MA1",7.5,1,1500,1); PM2 = Param("MA2",11,1,1500,1); M1 = Wilders(Close,PM1); M2 = Wilders(Close,PM2); A = Cross(M1,M2); B = Cross(M2,M1); Hor1=Param(" LEFT/RIGHT",1,1,1660,1); Ver1=Param(" UP DOWN",35,1,830,1); FS1=Param(" Font Size",15,11,100,1); GfxSelectFont("Tahoma", FS1, 200 ); GfxSetBkColor(colorBlack); GfxSetTextColor(colorGold); //GfxTextOut("EMA "+ PM1 + " "+ Prec(M1,2),Hor1,Ver1); GfxSetTextColor(colorGreen); //GfxTextOut("EMA "+ PM2 + " "+ Prec(M2,2),Hor1,Ver1+25); Plot(M1," EMA: "+pm1,ParamColor("FAST EMA COLOR",colorBrightGreen)); Plot(M2," EMA: "+pm2,ParamColor("SLOW EMA COLOR",colorRed)); PlotShapes(IIf(A,shapeUpArrow,shapeNone),colorBrightGreen,0,L,Offset= -30); PlotShapes(IIf(B,shapeDownArrow,shapeNone),colorRed,0,H,Offset = -30); Filter = (A == 1) OR (B == 1); AddColumn(A,"BUY/SELL",1,IIf(A,colorGreen,c...