+91-0000000000

}

Monday – Friday : 9:00 AM – 6:30 PM

Kartik NMA Swing System With Exploration

This AFL, when integrated with Amibroker data feeds, provides a systematic approach to swing trading. It employs the NMA (Narrow Moving Average) strategy to identify trend reversals and potential trading opportunities. Utilizing this AFL in Amibroker enables traders to scan markets for stocks meeting specific criteria, streamlining their analysis process.

/_SECTION_BEGIN("NICK MA Swing");
SetBarsRequired(200,0);

GraphXSpace = 5;
SetChartOptions(0,chartShowArrows|chartShowDates);
k =  Optimize("K",Param("K",1,0.25,5,0.25),0.25,5,0.25);
Per= Optimize("atr",Param("atr",4,3,20,1),3,20,1);
HACLOSE=(O+H+L+C)/4;
HaOpen = AMA( Ref( HaClose,  -1 ),  0.5 );
HaHigh = Max( H,  Max( HaClose,  HaOpen ) );
HaLow = Min( L,  Min( HaClose,  HaOpen ) );
PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "" + Name(), colorBlack, styleCandle | styleNoLabel );
j=Haclose;

//=======================================================================================================================
//=========================Indicator==============================================================================================
f=ATR(14);

rfsctor = WMA(H-L, Per);

revers = k * rfsctor;

Trend = 1;  
NW[0] = 0;  


for(i = 1; i < BarCount; i++)
{
 if(Trend[i-1] == 1)                
 {
  if(j[i] < NW[i-1])                 
  {
   Trend[i] = -1;                   
   NW[i] = j[i] + Revers[i];        
  }
  else                              
  {
   Trend[i] = 1;
   if((j[i] - Revers[i]) > NW[i-1])
   {
    NW[i] = j[i] - Revers[i]; 
   }
   else
   {
    NW[i] = NW[i-1];
   }
  } 
 }
 if(Trend[i-1] == -1)               
 {
  if(j[i] > NW[i-1])                
  {
   Trend[i] = 1;                    
   NW[i] = j[i] - Revers[i];        
  }
  else                              
  {
   Trend[i] = -1;
   if((j[i] + Revers[i]) < NW[i-1]) 
   {
    NW[i] = j[i] + Revers[i]; 
   }
   else
   {
    NW[i] = NW[i-1];
   }
  }
 }
}

//===============system================


Buy=Cover=Cross(j,nw);
Sell=Short=Cross(nw,j);
SellPrice=ValueWhen(Sell,C,1);
BuyPrice=ValueWhen(Buy,C,1);
Long=Flip(Buy,Sell);
Shrt=Flip(Sell,Buy );

Filter=Buy OR Sell;

AddColumn(IIf(Buy,BuyPrice,IIf(Sell,-SellPrice,Null)) ,"nmaBS",1.0,colorWhite,IIf(Buy,colorBrightGreen,IIf(Sell,colorRed,colorBlack))); 


_SECTION_END();
//=================TITLE================================================================================================
_SECTION_BEGIN("Title");
if( Status("action") == actionIndicator ) 
(
Title = EncodeColor(colorWhite)+ "NICK MA Swing System" + " - " +  Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +
 "  - " + Date() +" - "+"\n" +EncodeColor(colorBlack) +"Op-"+O+"  "+"Hi-"+H+"  "+"Lo-"+L+"  "+
"Cl-"+C+"  "+ "Vol= "+ WriteVal(V)+"\n"+ 
EncodeColor(colorRed)+
WriteIf (Buy , " GO LONG / Reverse Signal at "+C+"  ","")+
WriteIf (Sell , " EXIT LONG / Reverse Signal at "+C+"  ","")+"\n"+EncodeColor(colorWhite)+
WriteIf(Sell , "Total Profit/Loss for the Last Trade Rs."+(C-BuyPrice)+"","")+
WriteIf(Buy  , "Total Profit/Loss for the Last trade Rs."+(SellPrice-C)+"","")+
WriteIf(Long AND NOT Buy, "Trade : Long - Entry price Rs."+(BuyPrice),"")+
WriteIf(shrt AND NOT Sell, "Trade : Short - Entry price Rs."+(SellPrice),"")+"\n"+ 
WriteIf(Long AND NOT Buy, "Current Profit/Loss Rs."+(C-BuyPrice)+"","")+
WriteIf(shrt AND NOT Sell, "Current Profit/Loss Rs."+(SellPrice-C)+"",""));
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);                      
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45); 
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);                      
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
AlertIf( Buy, "SOUND C:\\Windows\\Media\\Ringin.wav", "Audio alert", 2 );
AlertIf( Sell, "SOUND C:\\Windows\\Media\\Ringin.wav", "Audio alert", 2 );
_SECTION_END();

_SECTION_BEGIN("MA");
P = ParamField("Price field",-1);
Periods = Param("Periods", 8, 2, 200, 1 );
Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") | styleNoRescale ); 
_SECTION_END();

_SECTION_BEGIN("Mid MA");
P = ParamField("Price field",-1);
Periods = Param("Periods", 34, 2, 300, 1 );
Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") | styleNoRescale ); 
_SECTION_END();

_SECTION_BEGIN("Long MA");
P = ParamField("Price field",-1);
Periods = Param("Periods", 200, 2, 400, 1 );
Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") | styleNoRescale ); 
_SECTION_END();

_SECTION_BEGIN("shiree FPSR");
PlotOHLC(O,H,L,C,"Price",IIf(C>O,colorGreen,colorRed),styleCandle);
// Get Previous Day's close, Low and High
Prev_Close = TimeFrameGetPrice( "C", inDaily, -1, expandFirst) ;
Prev_Low = TimeFrameGetPrice( "L", inDaily, -1, expandFirst) ;
Prev_High = TimeFrameGetPrice( "H", inDaily, -1, expandFirst) ;
Today = LastValue(Day( ) );


//////////////////////////////30 MT STRATEGY /////////////////////////////////////////////////////////////
BS=(Prev_High-Prev_Low)/3;


Y=R30=Prev_Close+BS;
X=S30=Prev_Close-BS;

BSColor = colorBlue;
//Plot(X,"",colorBlue,styleThick|styleNoLabel);
//Plot(Y,"",colorBlue,styleThick|styleNoLabel);

///////////////////////////////////////////////////////////////////////////////////////////////////////

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( C, "Close", ParamColor("Color", colorPink ), styleNoTitle | styleCandle|styleNoLabel); 
Show_Prev = ParamToggle( "Display Pivots", "No|Yes", 1);
////////////////////// FPSR AS BUNCH OF LINES/////////////////////////////////////////////////////////////
XY=Y-X;
Z1=X+0.0025*XY;
Z2=X+0.0050*XY;
Z3=X+0.0075*XY;
Z4=X+0.0100*XY;
Z5=X+0.0125*XY;
Z6=X+0.0150*XY;
Z7=X+0.0175*XY;
Z8=X+0.0200*XY;
Z9=X+0.0225*XY;
Z0=X+0.0250*XY;

Z11=Y-0.0025*XY;
Z12=Y-0.005*XY;
Z13=Y-0.0075*XY;
Z14=Y-0.01*XY;
Z15=Y-0.0125*XY;
Z16=Y-0.0150*XY;
Z17=Y-0.0175*XY;
Z18=Y-0.02*XY;
Z19=Y-0.0225*XY;
Z20=Y-0.025*XY;


//ColorR=ColorRGB(150,20,100);
ColorXY=ParamColor("XY", colorYellow);
////////////////////////////////////////////////////////////////////////////
if(Show_Prev)
{
Plot(IIf(Today == Day(),Z1, Null), "Z1", ColorXY,styleLine|styleThick|styleNoRescale|styleNoLabel);
Plot(IIf(Today == Day(),Z2, Null),"Z2", ColorXY,styleLine|styleThick|styleNoRescale|styleNoLabel);
Plot(IIf(Today == Day(),Z3, Null),"Z3", ColorXY,styleLine|styleThick|styleNoRescale|styleNoLabel);
Plot(IIf(Today == Day(),Z4, Null),"Z4", ColorXY,styleLine|styleThick|styleNoRescale|styleNoLabel);
Plot(IIf(Today == Day(),Z5, Null),"Z5", ColorXY,styleLine|styleThick|styleNoRescale|styleNoLabel);
Plot(IIf(Today == Day(),Z6, Null),"Z6", ColorXY,styleLine|styleThick|styleNoRescale|styleNoLabel);
Plot(IIf(Today == Day(),Z7, Null),"Z7", ColorXY,styleLine|styleThick|styleNoRescale|styleNoLabel);
Plot(IIf(Today == Day(),Z8, Null),"Z8", ColorXY,styleLine|styleThick|styleNoRescale|styleNoLabel);
Plot(IIf(Today == Day(),Z9, Null),"Z9", ColorXY,styleLine|styleThick|styleNoRescale|styleNoLabel);
Plot(IIf(Today == Day(),Z0, Null),"Z0", ColorXY,styleLine|styleThick|styleNoRescale|styleNoLabel);

Plot(IIf(Today == Day(),Z11, Null),"Z11", ColorXY,styleLine|styleThick|styleNoRescale|styleNoLabel);
Plot(IIf(Today == Day(),Z12, Null),"Z12", ColorXY,styleLine|styleThick|styleNoRescale|styleNoLabel);
Plot(IIf(Today == Day(),Z13, Null),"Z13", ColorXY,styleLine|styleThick|styleNoRescale|styleNoLabel);
Plot(IIf(Today == Day(),Z14, Null),"Z14", ColorXY,styleLine|styleThick|styleNoRescale|styleNoLabel);
Plot(IIf(Today == Day(),Z15, Null),"Z15", ColorXY,styleLine|styleThick|styleNoRescale|styleNoLabel);
Plot(IIf(Today == Day(),Z16, Null),"Z16", ColorXY,styleLine|styleThick|styleNoRescale|styleNoLabel);
Plot(IIf(Today == Day(),Z17, Null),"Z17", ColorXY,styleLine|styleThick|styleNoRescale|styleNoLabel);
Plot(IIf(Today == Day(),Z18, Null),"Z18", ColorXY,styleLine|styleThick|styleNoRescale|styleNoLabel);
Plot(IIf(Today == Day(),Z19, Null),"Z19", ColorXY,styleLine|styleThick|styleNoRescale|styleNoLabel);
Plot(IIf(Today == Day(),Z20, Null),"Z20", ColorXY,styleLine|styleThick|styleNoRescale|styleNoLabel);}

_SECTION_END();

_SECTION_BEGIN("VOLUME_Hight of Volume Bars Control");


PlotVOL = ParamToggle( "plot Volume?","No| Yes",0);

VolColor = (C>O OR (C==O AND
(H-C)<=(C-L) ))*ParamColor( "VUpColor" ,colorBlueGrey) +

(C(C-L)) )*ParamColor( "VDnColor" ,colorPink) ;

VolScale = Param("1/Vol. Height (TimeBar chart)(fraction of window) 5=1/5=20%",10, 2, 100, 1.0) ; // Timebars

if (PlotVOL >0) 

{

Vheight = VolScale;

Plot(Prec(Volume ,0),"V",VolColor,
styleNoTitle| styleOwnScale| styleNoLabel| styleThick| ParamStyle( "VStyle", styleHistogram,maskHistogram| styleNoLabel) ,Vheight ); }
//Plot(MA(Volume,50),"",colorLightBlue,styleLine);
_SECTION_END();

Open chat
1
Hi, how can I help you?