My afl collection

Status
Not open for further replies.

shivangi77

Well-Known Member
Nilesh's System







Code:
SetChartOptions(0,chartShowArrows|chartShowDates);

_SECTION_BEGIN("Background_Setting");
SetChartBkGradientFill( ParamColor("BgTop", colorBlack),

ParamColor("BgBottom", colorBlack),ParamColor("titleblock",colorDarkTeal ));
_SECTION_END();



_SECTION_BEGIN("Flower");
Prd1=Param("ATR Period",4,1,20,1);
Prd2=Param("Look Back",7,1,20,1);
green = HHV(LLV(L,Prd1)+ATR(Prd1),Prd2);
red = LLV(HHV(H,Prd1)-ATR(Prd1),Prd2);
flowerClose = EMA((Open+High+Low+Close)/4,3) ;
flowerOpen = EMA((Ref(Open,-1) + Ref(flowerClose,-1))/2,3);
Temp = Max(High, flowerOpen);
flowerHigh = EMA(Max(Temp, flowerClose),3);
Temp = Min(Low,flowerOpen);
flowerLow = EMA(Min(Temp, flowerClose),3);
barColor=IIf(C>Green ,colorBrightGreen,IIf(C < RED,colorRed,colorWhite));
PlotOHLC( IIf(flowerOpen<flowerClose, flowerOpen, flowerClose),flowerHigh,flowerLow,IIf(flowerOpen<flowerClose, flowerClose, flowerOpen), "Close", barColor, styleNoTitle | styleCandle);


_SECTION_END();

_SECTION_BEGIN("OsSetting");

OBSetting=Param("Setting",45,1,500,1);
Bline = StochD(OBSetting);
Oversold=Bline<=30;
Overbought=Bline>=85;


PlotShapes (IIf(Oversold, shapeSmallCircle, shapeNone) ,colorBrightGreen, layer = 0, yposition = flowerLow, offset = -8 );
PlotShapes (IIf(Overbought, shapeSmallCircle, shapeNone) ,colorRed, layer = 0, yposition = flowerHigh, offset = 7 );
_SECTION_END();

_SECTION_BEGIN("Breakout Setting");
Buyperiods=Param("Breakout periods best is usually 18",5,1,100,1,1); //10 is good for adding
Sellperiods=Param("Exit Breakout",6,1,100,1,1); //4 is good for adding
Buy= C>Ref(HHV(H,Buyperiods),-1);
Sell= O<Ref(LLV(O,Sellperiods),-1);

/* exrem is one method to remove surplus strade signals. It removes excessive signals of arrow */
top=Max(Close,Ref(Close,-1));

Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);
shapeUpArrow = Param("Buy Shape Typ",59,1,60,1);
//shapeDownArrow = Param("Sell Shape Typ",60,1,60,1);
PlotShapes(shapeUpArrow * Buy, ParamColor("Buy Arrow", colorYellow),0,flowerLow, - 15);
//PlotShapes(shapeDownArrow * Sell, ParamColor("sell Arrow", colorRed),0,flowerLow, - 15);
PlotShapes( IIf( Sell, shapeDownArrow, shapeNone ), colorCustom12, layer = 0, yposition = top, offset = -60  );


_SECTION_END();




_SECTION_BEGIN("Parameters");
LB1= Param("Long LookBack Periods",42,1,60,1);
LB3= Param("Mid LookBack Periods",18,1,30,1);
LB2= Param("Short LookBack Periods",6,1,30,1);

_SECTION_END();




_SECTION_BEGIN("ResistanceLong");

RsColor=ParamColor("LongResColor",colorOrange);
BrCount=Param("LongBarLength",65,1,500,1);
for (i=0;i<BarCount-BrCount;i++) //hide the line except most recent 10 bars
{
    RsColor[i] = colorBlack;
}

flowerClose = EMA((Open+High+Low+Close)/4,3) ;
flowerOpen = EMA((Ref(Open,-1) + Ref(flowerClose,-1))/2,3);
Temp = Max(High, flowerOpen);
flowerHigh = EMA(Max(Temp, flowerClose),3);
Temp = Min(Low,flowerOpen);
flowerLow = EMA(Min(Temp, flowerClose),3);

R=ValueWhen(Cross(MA(flowerClose,LB1),C),HHV(flowerHigh,LB1),-1);
Plot(R,"Resistance",RsColor,ParamStyle("LongResStyle",styleNoTitle|styleLine|styleDots|styleStaircase|styleThick,maskAll));
_SECTION_END();

_SECTION_BEGIN("ResistanceMid");
Rs3Color=ParamColor("MidResColor",colorCustom4);
BrCount3=Param("MidBarLength",40,1,500,1);
for (i=0;i<BarCount-BrCount3;i++) //hide the line except most recent 10 bars
{
    Rs3Color[i] =colorBlack;
}

flowerClose = EMA((Open+High+Low+Close)/4,3) ;
flowerOpen = EMA((Ref(Open,-1) + Ref(flowerClose,-1))/2,3);
Temp = Max(High, flowerOpen);
flowerHigh = EMA(Max(Temp, flowerClose),3);
Temp = Min(Low,flowerOpen);
flowerLow = EMA(Min(Temp, flowerClose),3);

RM2=ValueWhen(Cross(EMA(flowerClose,LB3),C),HHV(flowerHigh,LB3),-1);
Plot(RM2,"MidRes",Rs3Color,ParamStyle("MidResStyle",styleLine|styleStaircase|styleNoTitle,maskAll));
_SECTION_END();

_SECTION_BEGIN("ResistanceShort");
Rs2Color=ParamColor("ShortResColor",colorCustom12);
BrCount2=Param("ShortResLength",12,1,500,1);
for (i=0;i<BarCount-BrCount2;i++) //hide the line except most recent 10 bars
{
    Rs2Color[i] = colorBlack;
}

flowerClose = EMA((Open+High+Low+Close)/4,3) ;
flowerOpen = EMA((Ref(Open,-1) + Ref(flowerClose,-1))/2,3);
Temp = Max(High, flowerOpen);
flowerHigh = EMA(Max(Temp, flowerClose),3);
Temp = Min(Low,flowerOpen);
flowerLow = EMA(Min(Temp, flowerClose),3);

RM=ValueWhen(Cross(TEMA(flowerClose,LB2),C),HHV(flowerHigh,LB2),-1);
Plot(RM,"ShortRes",Rs2Color,ParamStyle("ShortResStyle",styleDashed|styleThick|styleNoTitle|styleStaircase,maskAll));
_SECTION_END();




_SECTION_BEGIN("SupportLong");
Sup1Color=ParamColor("LongSupColor",colorBlue);
BrCount4=Param("LongSupBarLength",65,1,500,1);
for (i=0;i<BarCount-BrCount4;i++) //hide the line except most recent 10 bars
{
    Sup1Color[i] =colorBlack;
}

flowerClose = EMA((Open+High+Low+Close)/4,3) ;
flowerOpen = EMA((Ref(Open,-1) + Ref(flowerClose,-1))/2,3);
Temp = Max(High, flowerOpen);
flowerHigh = EMA(Max(Temp, flowerClose),3);
Temp = Min(Low,flowerOpen);
flowerLow = EMA(Min(Temp, flowerClose),3);

S=ValueWhen(Cross(MA(flowerClose,LB1),C),LLV(flowerLow,LB1),-1);
Plot(s,"Support",Sup1Color,ParamStyle("SupStyle",styleLine|styleDots|styleStaircase|styleThick|styleNoTitle,maskAll));
_SECTION_END();

_SECTION_BEGIN("SupportMid");
Sup3Color=ParamColor("MidSupColor",colorDarkYellow);
BrCount6=Param("MidBarLength",40,1,500,1);
for (i=0;i<BarCount-BrCount6;i++) //hide the line except most recent 10 bars
{
    Sup3Color[i] =colorBlack;
}

flowerClose = EMA((Open+High+Low+Close)/4,3) ;
flowerOpen = EMA((Ref(Open,-1) + Ref(flowerClose,-1))/2,3);
Temp = Max(High, flowerOpen);
flowerHigh = EMA(Max(Temp, flowerClose),3);
Temp = Min(Low,flowerOpen);
flowerLow = EMA(Min(Temp, flowerClose),3);

SM2=ValueWhen(Cross(EMA(flowerClose,LB3),C),LLV(flowerLow,LB3),-1);
Plot(SM2,"MidSup",Sup3Color,ParamStyle("MidSupStyle",styleLine|styleStaircase|styleNoTitle,maskAll));
_SECTION_END();

_SECTION_BEGIN("SupportShort");
Sup2Color=ParamColor("ShortSupColor",colorPink);
BrCount5=Param("ShortSupBarLength",12,1,500,1);
for (i=0;i<BarCount-BrCount5;i++) //hide the line except most recent 10 bars
{
    Sup2Color[i] =colorBlack;
}


flowerClose = EMA((Open+High+Low+Close)/4,3) ;
flowerOpen = EMA((Ref(Open,-1) + Ref(flowerClose,-1))/2,3);
Temp = Max(High, flowerOpen);
flowerHigh = EMA(Max(Temp, flowerClose),3);
Temp = Min(Low,flowerOpen);
flowerLow = EMA(Min(Temp, flowerClose),3);

SM=ValueWhen(Cross(TEMA(flowerClose,LB2),C),LLV(flowerLow,LB2),-1);
Plot(SM,"ShortSup",Sup2Color,ParamStyle("ShortSupStyle",styleDashed|styleThick|styleNoTitle|styleStaircase,maskAll));
_SECTION_END();

_SECTION_BEGIN("Cloud Setting");
//Cloud
ParmCloud = ParamToggle("Cloud", "No|Yes", 0);

CloudResColor=ParamColor("CloudResColor",colorDarkTeal);
BrCount7=Param("CloudResLength",15,1,500,1);
for (i=0;i<BarCount-BrCount7;i++) //hide the line except most recent 10 bars
{
    CloudResColor[i] = colorBlack;
}

flowerClose = EMA((Open+High+Low+Close)/4,3) ;
flowerOpen = EMA((Ref(Open,-1) + Ref(flowerClose,-1))/2,3);
Temp = Max(High, flowerOpen);
flowerHigh = EMA(Max(Temp, flowerClose),3);
Temp = Min(Low,flowerOpen);
flowerLow = EMA(Min(Temp, flowerClose),3);

CS=ValueWhen(Cross(WMA(flowerClose,LB2),C),LLV(flowerLow,LB2),-1);
CR=ValueWhen(Cross(WMA(flowerClose,LB2),C),HHV(flowerHigh,LB2),-1);


if(parmCloud == 1)
{
    PlotOHLC( CS, CS, CR,CR, "Band", CloudResColor, styleCloud | styleNoLabel|styleNoTitle); 
}

_SECTION_END();



Title = StrFormat("\\c02 {{NAME}} | {{DATE}} | Open : %g | High : %g | Low : %g | Close : %g | Change = %.1f%% | Volume = " +WriteVal( V, 1.0 ) +", {{VALUES}}",
O, H, L, C, SelectedValue( ROC( C, 1 )) );


_SECTION_BEGIN("Keltner Bands");
Smooth = Param("Smoothness",14,2,100,1);
Length = 20; Num_ATRs = 1.5;
// Length and Num_ATRs parameters should be personalized for your preferred settings.

Mov_Avg = MA((H+L+C)/3,Length);
KUP = Mov_Avg + Num_ATRs * ATR(Length);
KDOWN = Mov_Avg - Num_ATRs * ATR(Length);


Plot (MA(KUP,smooth),"KUP",colorGreen,styleLine);
Plot (MA(KDown,smooth), "Kdown",colorRed,styleLine);
Plot (MA(Mov_Avg,smooth),"Mov_Avg",colorYellow , styleDashed);
_SECTION_END();

Somehow similar to buy sell signal arrows of Nirvana but signals occur earlier than nirvana so results in more whipsaws. Invented much before Nirvana by Nilesh.
 
Hi Brother,
When i Back tasting on chart I got different data from different data provider. I have manshi rt and global data feed. May i know which data provider's data I should follow?
 

sr114

Well-Known Member
Hi Brother,
When i Back tasting on chart I got different data from different data provider. I have manshi rt and global data feed. May i know which data provider's data I should follow?
Hi Soumen

if u have Global Data feed and u r subscribing to them then u obviously USE data from Global data feed as the data is purest pure and is in real time. manshi captures data from ur trading terminal

so stick to global data for better result

sr
 

shivangi77

Well-Known Member
NAKSHATRA






Code:
_SECTION_BEGIN("MA Diff");
T=26;
KMA=((C-MA(C,T))/MA(C,T))*100;
Graph0=KMA;
Graph0Style=2+4;
Graph0BarColor=IIf(KMA>0,5,4);
GraphXSpace=5;

_SECTION_END();

_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
Plot( C, "Close", ParamColor("Color", colorRed ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();

//------------------------------------------------------------------------------

_SECTION_BEGIN("ZIG-ZAG");
P = ParamField( "Price field" );
change = Param("% change",5,0.1,25,0.1);
_SECTION_END();

_SECTION_BEGIN("EMA");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 300, 1, 10 );
_SECTION_END();

_SECTION_BEGIN("MACD Exploration");
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
Z=Param("zig",1,0,10,0.1);


Cond1 = Cross(MACD(r1,r2),Signal(r1,r2,r3));

Cond3 = Zig(C,z)>Ref(Zig(C,z),-4);
Buy = Cond1 AND Cond3;

Cond4 = Cross(Signal(r1,r2,r3),MACD(r1,r2));

Cond6 = Zig(C,z)<Ref(Zig(C,z),-4);
Sell = Cond4 AND Cond6;
Trigger = WriteIf(Buy, "Buy", "") + WriteIf(Sell, "Sell", "");

_N(Title = StrFormat("{{NAME}} {{DATE}} {{INTERVAL}}: O=%1.2f, H=%1.2f, L=%1.2f, C=%1.2f, V=%1.0f\n{{VALUES}}", O, H, L, C, V));

BG = IIf(Buy, colorPaleGreen, IIf(Sell, colorRose, colorDefault));
FG = IIf(Buy, colorDarkGreen, IIf(Sell, colorDarkRed, colorDefault));

if(Status("action") == actionIndicator)
{
Plot(C, "", colorGrey50, styleBar);
PlotShapes(IIf(Buy, shapeCircle, shapeNone),colorBlue, 0,L, Offset=-60);
PlotShapes(IIf(Sell, shapeCircle, shapeNone),colorWhite, 0,H, Offset=-30);
PlotShapes(shapeDownArrow*Sell,colorYellow,0,SellPrice,0);
PlotShapes(shapeUpArrow*Buy,colorYellow,0,BuyPrice,0);

}

//------------------------------------------------------------------------------------------------
if(Status("action") == actionExplore)

Filter = Buy OR Sell;
SetOption("NoDefaultColumns", True);

AddTextColumn(Name(), "Symbol", 77, FG, BG, 120);
AddColumn(DateTime(), "Date", formatDateTime, FG, BG, 100);
AddColumn(TimeNum() ,"Time",1);
AddColumn( C, "Close", 1.3 );
AddColumn( H, "High", 1.3 );
AddColumn(V, "Volume");
AddColumn(Ref(V,-1),"P-Vol");
AddColumn(V/Ref(V,-1)*100,"Increase in Vol");
AddColumn( Buy, "Buy", 1 );
AddColumn( Sell, "Sell", 1 );

shape = Buy * shapeHollowUpTriangle + Sell * shapeHollowDownTriangle;

PlotShapes( shape, IIf( Buy, colorBlue, colorWhite ), 0, IIf( Buy, Low, High ) );

GraphXSpace = 7;

GraphXSpace = 7;
_SECTION_END();

_SECTION_BEGIN("EMA3");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 300, 1, 10 );
_SECTION_END();


_SECTION_BEGIN("Background text");
C13=Param("fonts",20,10,30,1 );
C14=Param("left-right",2.1,1.0,5.0,0.1 );
C15=Param("up-down",12,1,20,1 );
Miny = Status("axisminy");
Maxy = Status("axismaxy");
lvb = Status("lastvisiblebar");
fvb = Status("firstvisiblebar");
pxwidth = Status("pxwidth");
pxheight = Status("pxheight");
GfxSetBkMode(transparent=1);
GfxSetOverlayMode(1);
GfxSelectFont("Tahoma", Status("pxheight")/C13 );
GfxSetTextAlign( 6 );
GfxSetTextColor( ColorRGB (217,217,213));
GfxTextOut( Name(), Status("pxwidth")/C14, Status("pxheight")/C15 );
GfxSelectFont("Tahoma", Status("pxheight")/C13*0.5 );
GfxSetTextColor( ColorRGB (103,103,103));
GfxTextOut( "By", Status("pxwidth")/C14, Status("pxheight")/C15*2.5 );
GfxSelectFont("Tahoma", Status("pxheight")/C13*0.5 );
GfxSetTextColor( ColorRGB (103,103,103));
GfxTextOut( "Nakshatra", Status("pxwidth")/C14, Status("pxheight")/C15*4 );
GfxSelectFont("MS Sans Serif", 10, 500, False, False, 0);
//Second phase starts Here
//File: BHS Chart
_SECTION_BEGIN("BHS1.02");
SetChartBkColor(ParamColor("Outer panel color ",colorLightYellow));
SetChartBkColor(ParamColor("BackGround Color", colorDarkGrey));
pShowtradeLines = ParamToggle("Show Trade Lines", "No|Yes", 1);
pShowMarkers = ParamToggle("Show Markers", "No|Yes", 1);
synch=ParamToggle("Synchronize buy/short with foreign index", "No|Yes", 1);
Volmin=Param("Volume minimum",5000,0,10000000,50);
Volmax=Param("Volume maximum",1000000,0,10000000,50);
priceRL=Param("Price Range Min",150,1,20000,1);
priceRH=Param("Price Range Max",3000,1,20000,1);
PercChangemin=Param("Percentage Change Min set", -25, -100, 100, 0.1);
PercChangemax=Param("Percentage Change Max set", 25, -100, 100, 0.1);
PerctakeProfit=Param("Take Profit Percent Set",0.6,0.3,30,0.1);
PercStoploss=Param("StopLoss Percent Set",0.25,0.2,5,0.1);

//PlotOHLC(Open,High,Low,Close,"",colorWhite,styleCandle);
Bars = 0;
xpdh = 90;

{
Plot_Range = (TimeNum() >= 85500 AND TimeNum()<= 153500) AND (DateNum()==LastValue(DateNum()));
FH_Range = (TimeNum() >= 085500 AND TimeNum()<= 093000) AND (DateNum()==LastValue(DateNum()));

FH_Prices = High * FH_Range;
FH_Marker = BarsSince(FH_Range>0);

Num_Bars = 36000 / Interval(1);

TimeFrameSet(inDaily);
TOP_ = Open;
PDH_ = Ref(High,-1);
PDL_ = Ref(Low,-1);
PDO_ = Ref(Open,-1);
PDC_ = Ref(Close,-1);
PDM_ = (PDH_+PDL_)/2;
TimeFrameRestore();

isAll = True;
isRth = TimeNum() >= 085400 AND TimeNum() <= 093000;
isdRth = TimeNum() >= 085400 AND TimeNum() <= 160000;

aRthL = IIf(isRth, L, 1000000);
aRthH = IIf(isdRth, H, Null);
aRthLd = IIf(isdRth, L, 1000000);

TOP = TimeFrameExpand(TOP_,inDaily,expandFirst);
PDH = TimeFrameExpand(PDH_,inDaily,expandFirst);
PDL = TimeFrameExpand(PDL_,inDaily,expandFirst);
PDO = TimeFrameExpand(PDO_,inDaily,expandFirst);
PDC = TimeFrameExpand(PDC_,inDaily,expandFirst);
PDM = TimeFrameExpand(PDM_,inDaily,expandFirst);
FHH = Ref(HHV(High*FH_Range,Num_Bars),-FH_Marker);
FHL = TimeFrameCompress( aRthL, inDaily, compressLow );
FHL = TimeFrameExpand( FHL, inDaily, expandFirst );
DayH = TimeFrameCompress( aRthH, inDaily, compressHigh );
DayH = TimeFrameExpand( DayH, inDaily, expandFirst );
DayL = TimeFrameCompress( aRthLd, inDaily, compressLow );
DayL = TimeFrameExpand( DayL, inDaily, expandFirst );


FC1=((PDH-PDL)*0.433);
FC2=((PDH-PDL)*0.7666);
FC3=((PDH-PDL)*1.355);
FC4=(FHH-FHL);

A=IIf((FC4<=FC1+PDH*0.005),FC1,0);
B=IIf((FC4<=FC2+PDH*0.005 AND FC4>FC1+PDH*0.005),FC2,0);
Cl=IIf((FC4<=FC3 AND FC4>FC2+PDH*0.005),FC3,0);
AF=(A+B+Cl);

//foreign
_SECTION_BEGIN ("foreign Index bar graph");
Vr=ParamList("Index",List = "NIFTY_SPT,^NSEI,^NSEBANK,^CNXIT,^NSMIDCP,RELIANCE.NS,SBIN.N S",0);
SetForeign(Vr);
HaC =(O+H+L+C)/4;
HaO = AMA( Ref( HaC, -1 ), 0.5 );
HaH = Max( H, Max( HaC, HaO) );
HaL = Min( L, Min( HaC, HaO) );
BG3=HHV(LLV(HaL,4)+ATR(4),8);
BR3=LLV(HHV(HaH ,4)-ATR(4),8);
co = IIf(Hac>BG3 ,colorBrightGreen,IIf(Hac < BR3,colorRed,colorGrey50));
Plot(4, "", Co,styleArea+styleOwnScale | styleNoLabel, -1, 100);
RestorePriceArrays();

_SECTION_END();

BuyPrice=(DayL+AF);
BuyTP1=(BuyPrice+(BuyPrice*(PerctakeProfit/100)));
BuyTP2=(C>=BuyTP1);
SellPrice=(DayH-AF);
SellTP1=(SellPrice-(SellPrice*(PerctakeProfit/100)));
SellTP2=(C<=SellTP1);
percchange=(((C-TOP)/TOP)*100);
Vol=(V>=Volmin AND V<=Volmax);
Percentage=(percchange>=PercChangemin AND percchange<=PercChangemax);
prc=(C>=priceRL AND C<=priceRH);
BuyStop1=(BuyPrice-(BuyPrice*(PercStoploss/100)));
BuyStop2=IIf((BuyStop1<=SellPrice) AND SellPrice<=BuyPrice,SellPrice,BuyStop1);
SellStop1=(SellPrice+(SellPrice*(PercStoploss/100)));
SellStop2=IIf((SellStop1>=BuyPrice) AND SellPrice<=BuyPrice, BuyPrice,SellStop1);

BuyStop=IIf((Buy AND NOT BuyTP2),BuyStop2,Null);
BuyTP=IIf(Buy AND NOT BuyStop,BuyTP2,Null);

Bars = BarsSince(TimeNum() >= 85400 AND TimeNum() < 092900);
x0 = BarCount-LastValue(Bars);
x1 = BarCount-1;
TOP_Line = LineArray(x0,LastValue(TOP),x1,LastValue(TOP),0);
PDH_Line = LineArray(x0,LastValue(PDH),x1,LastValue(PDH),0);
PDL_Line = LineArray(x0,LastValue(PDL),x1,LastValue(PDL),0);
PDC_Line = LineArray(x0,LastValue(PDC),x1,LastValue(PDC),0);
PDM_Line = LineArray(x0,LastValue(PDM),x1,LastValue(PDM),0);
FHH_Line = LineArray(x0,LastValue(FHH),x1,LastValue(FHH),0);
FHL_Line = LineArray(x0,LastValue(FHL),x1,LastValue(FHL),0);
BuyPriceline=LineArray(x0,LastValue(BuyPrice),x1,LastValue(BuyPrice),0);
BuyStopline=LineArray(x0,LastValue(BuyStop2),x1,LastValue(BuyStop2),0);
BuyTPline=LineArray(x0,LastValue(BuyTP1),x1,LastValue(BuyTP1),0);
SellPriceline=LineArray(x0,LastValue(SellPrice),x1 ,LastValue(SellPrice),0);
SellStopline=LineArray(x0,LastValue(SellStop2),x1, LastValue(SellStop2),0);
SellTPline=LineArray(x0,LastValue(SellTP1),x1,LastValue(SellTP1),0);
DayHline=LineArray(x0,LastValue(DayH),x1,LastValue (DayH),0);
DayLline=LineArray(x0,LastValue(DayL),x1,LastValue (DayL),0);


Plot(IIf(pShowtradeLines,BuyStopline,Null),"BuySto p",colorBrightGreen,styleDots|styleNoRescale| styleNoLine);
Plot(IIf(pShowtradeLines,SellPriceline,Null),"Shor t Here",colorRed,styleDots|styleNoRescale);
PlotShapes(IIf(pShowMarkers AND Buy, shapeHollowUpArrow, Null), colorDarkGreen, 0,L,Offset=-30);

if( Status("action") == actionIndicator )
(
Title = EncodeColor(colorWhite)+ "Nakshatra Super " + " - " + Name() + " - " + EncodeColor(colorYellow)+ Interval(2) + EncodeColor(colorYellow) +
" - " + Date() +" - "+ EncodeColor(colorYellow) + "-Open="+WriteVal(O,1) + EncodeColor(colorYellow) + "- High= "+ WriteVal(H,1)+ EncodeColor(colorYellow) + "- Low= "+ WriteVal(L,1)+ EncodeColor(colorYellow) + "- Close= "+ WriteVal(C,1)+ EncodeColor(colorYellow) + "- Vol= "+ WriteVal(V,1)+("\n")
+WriteIf(Percchange, " % Change = "+(Percchange)+" ","")+" Previous DayHigh="+WriteVal(PDH,1)+", Previous DayLow="+WriteVal(PDL,1)+", Today High="+WriteVal(DayH,1)+", Todays Low="+WriteVal(DayL,1)+
WriteIf(Hac>BG3,EncodeColor(colorBrightGreen)+"+Up ",
WriteIf(Hac<BR3,EncodeColor(colorRed)+"-Down",EncodeColor(colorLightYellow)+"< Flat >")));
/*
GfxSetOverlayMode( mode = 0 );
GfxSelectPen( colorRed, 3 );
GfxSelectSolidBrush( colorPink );
GfxRoundRect( 20, 55, 180, 175, 15, 15 );
GfxSetBkMode(1);
GfxSelectFont( "Arial", 10, 700, False );
GfxSetTextColor( colorDarkBlue );
GfxSetTextAlign(0);
GfxTextOut( WriteIf(SellPrice, "TRP level: "+(SellPrice),""), 30, 60);
GfxTextOut( WriteIf(BuyPrice, "Buy Above: "+(BuyPrice),""), 30, 75);
GfxTextOut( WriteIf(BuyStop2, "Long SL: "+(BuyStop2),""), 30, 90);
GfxTextOut( WriteIf(BuyTP1 , "Long Target 1: "+(BuyTP1),""), 30, 105);
GfxTextOut( WriteIf(SellPrice, "Sell Below: "+(SellPrice),""), 30, 120);
GfxTextOut( WriteIf(SellStop2, "Short SL: "+(SellStop2),""), 30, 135);
GfxTextOut( WriteIf(SellTP1, "Short Target: "+(SellTP1),""), 30, 150);
*/
AddColumn(V,"Volume",1.0);
AddColumn(Percchange,"Change %",1.2);
AddColumn(BuyPrice,"Buy at",1.2);
AddColumn(BuyStop,"Buy Stop at",1.2);
AddColumn(BuyTP1,"Buy Profit at",1.2);
AddColumn(SellPrice,"Short at",1.2);
AddColumn(SellTP1,"Short profit at",1.2);

}

_SECTION_END();


_SECTION_BEGIN("short signal");
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 ) );
BG2=HHV(LLV(Low,4)+ATR(4),8);
BR2=LLV(HHV(High,4)-ATR(4),8);
SetBarFillColor( IIf(O <C, colorSeaGreen,colorOrange) );
k = Optimize("K",Param("K",1.75,1,5,0.25),1,5,0.25);
Per= Optimize("atr",Param("atr",10,3,30,1),3,30,1);
j=HaClose;
nm= (H-L);
rfsctor = WMA(nm, 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];
}
}
}
}

Plot(NW, "", IIf(Trend == 1, 6, 4), 4);

Buy=Cross(j,nw);
Short=Cross(nw,j);
Sell=Cross(nw,j);
Cover=Cross(j,nw);
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Short=ExRem(Short,Cover);
Cover=ExRem(Cover,Short);
dist = 1.5*ATR(15);
for( i = 0; i < BarCount; i++ )
{
//if( Buy[i] ) PlotText( "Buy@" + O[ i ], i, L[ i ]-Trend[i], colorDarkBlue, colorYellow );
//if( Sell[i] ) PlotText( "Sell@" +H[ i ], i-4, L[ i ]+Trend[i], colorRed, colorYellow );
}

//PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,halow,-30);
//PlotShapes(IIf(Sell, shapeHollowDownTriangle, shapeNone),colorWhite, 0,hahigh,-15);
//PlotShapes(IIf(Cover, shapeHollowUpTriangle, shapeNone),colorWhite, 0,halow,-15);
//PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,hahigh,-30);

Gives nice result for nifty on 3 or 5 mins chart but as it looks future so use with caution.
 
HTML:
if u have Global Data feed and u r subscribing to them then u obviously USE data from Global data feed as the data is purest pure and is in real time. manshi captures data from ur trading terminal

so stick to global data for better result

sr
ok. But my question is how it is possible that same chart same time frame (5min), but data is different in between manshi rt and gfdl.?
 

sr114

Well-Known Member
HTML:
if u have Global Data feed and u r subscribing to them then u obviously USE data from Global data feed as the data is purest pure and is in real time. manshi captures data from ur trading terminal

so stick to global data for better result

sr
ok. But my question is how it is possible that same chart same time frame (5min), but data is different in between manshi rt and gfdl.?
Actually global's data are tick data . but for manshi, it captures data from trading terminal and the lag is 3 sec and overall it is not tick data. in between the 3 sec lag, if any trade happens it is not captured by manshi, so the differences arises between global and manshi

sr
 
Ranjit's Swing System


See -> http://i.imgur.com/aZEAf.png



Code:
//R2=> Heinkin Ashi Price Action
//R1=> Decorative Works
_SECTION_BEGIN("Chart Settings");
	SetChartOptions(0,chartShowArrows|chartShowDates);
	SetChartBkColor(ParamColor("Outer Panel",colorPaleBlue));
	SetChartBkGradientFill(ParamColor("Upper Chart",1),ParamColor("Lower Chart",23));
	GraphXSpace=Param("GraphXSpace",10,0,100,1);
	dec = (Param("Decimals",2,0,7,1)/10)+1;
	bi = BarIndex();
	Lbi = LastValue(BarIndex());
	sbi = SelectedValue(bi);
	x1= BarCount-1;
Title = EncodeColor(55)+  Title = Name() + "     " + EncodeColor(32) + Date() +
"      " + EncodeColor(5) + "{{INTERVAL}}  " +
	EncodeColor(55)+ "     Open = "+ EncodeColor(52)+ WriteVal(O,dec) + 
	EncodeColor(55)+ "     High = "+ EncodeColor(5) + WriteVal(H,dec) +
	EncodeColor(55)+ "      Low = "+ EncodeColor(32)+ WriteVal(L,dec) + 
	EncodeColor(55)+ "    Close = "+ EncodeColor(52)+ WriteVal(C,dec)+
	EncodeColor(55)+ "    Volume = "+ EncodeColor(52)+ WriteVal(V,1);
_SECTION_END();

_SECTION_BEGIN("MPLite Kaka");
//PlotOHLC(O,H,L,C,"Price",IIf(C>O,colorGreen,colorRed),styleCandle);

function Lastthursday()
{
 Daysinmonth=IIf(Month()==1 OR Month()==3 OR Month()==5 OR Month()==7 OR Month()==8 OR Month()==10 OR Month()==12,31,30);
 Daysinmonthfeb=IIf(Year()%4 == 0 AND Year()%100!=0,29,28);
 Daysinmonthfinal=IIf(Month()==2,Daysinmonthfeb,Daysinmonth);
 returnvalue=IIf(Daysinmonthfinal-Day()<7 AND DayOfWeek()==4,1,IIf(Daysinmonthfinal-Day()<8 AND DayOfWeek()==3 AND Ref(DayOfWeek(),1)!=4,1,0));
 return returnvalue;
}

FirstVisibleBar = Status( "FirstVisibleBar" );
Lastvisiblebar = Status( "LastVisibleBar" );

totalVisible=Lastvisiblebar-FirstVisibleBar;
//if(totalVisible<1500){

//Den = Param("Density", 1, 0.1, 10, 0.1);
percent=Param("Value Area", 70, 1, 100, 1);
Type=ParamList("Type","Price Profile|Volume Profile");
Period= ParamList("Base","Hourly|Daily|Weekly|Monthly|Lastthursday|Yearly",1);
x_scale=Param("Horizontal_scale", 2, 0, 10, 0.1);
EnMP2= ParamStyle("Style",styleLine|styleNoLabel,maskAll);
styleLines=styleDots;
ViewYvalues= ParamToggle("Show Yesterdays Values", "No|Yes",1);
ViewVlines= ParamToggle("Show Vertical Base Lines", "No|Yes",1);
Viewvalues= ParamToggle("Show Values", "No|Yes",0);
ViewVpoc= ParamToggle("Show Virgin POC", "No|Yes",1);
ViewTPO=ParamToggle("Show TPO Count", "No|Yes",0);

if(Period=="Hourly"){
BarsInDay = BarsSince(Hour() != Ref(Hour(), -1));Bot = TimeFrameGetPrice("L", inHourly, 0);Top = TimeFrameGetPrice("H", inHourly, 0);Vol = TimeFrameGetPrice("V", inHourly, 0);
}
if(Period=="Daily" ){//OR Interval()==3600
BarsInDay = BarsSince(Day() != Ref(Day(), -1));Bot = TimeFrameGetPrice("L", inDaily, 0);Top = TimeFrameGetPrice("H", inDaily, 0);Vol = TimeFrameGetPrice("V", inDaily, 0);
}
if(Period=="Weekly" OR Interval()==24 * 3600 ){ 
BarsInDay = BarsSince(DayOfWeek() < Ref( DayOfWeek(), -1 ));Bot = ValueWhen(Ref(BarsInDay,1)==1 OR BarIndex()>BarCount-2 ,LLV(L,BarsInDay),0);Top =ValueWhen(Ref(BarsInDay,1)==1 OR BarIndex()>BarCount-2,HHV(H,BarsInDay),0);Vol = TimeFrameGetPrice("V", inWeekly, 0);
}
if(Period=="Monthly"  ){
BarsInDay = BarsSince(Month() != Ref(Month(), -1));Bot = TimeFrameGetPrice("L", inMonthly, 0);Top = TimeFrameGetPrice("H", inMonthly, 0);Vol = TimeFrameGetPrice("V", inMonthly, 0);
}

if(Period=="Lastthursday"  ){
BarsInDay = BarsSince(Lastthursday()==1 AND Ref(Lastthursday(), -1)==0);Bot = ValueWhen(Ref(BarsInDay,1)==1 OR BarIndex()>BarCount-2 ,LLV(L,BarsInDay),0);Top =ValueWhen(Ref(BarsInDay,1)==1 OR BarIndex()>BarCount-2,HHV(H,BarsInDay),0);Vol = TimeFrameGetPrice("V", inMonthly, 0);
}

if(Period=="Yearly"  ){
BarsInDay = BarsSince(Year() != Ref(Year(), -1));Bot = TimeFrameGetPrice("L", inYearly, 0);Top = TimeFrameGetPrice("H", inYearly, 0);Vol = TimeFrameGetPrice("V", inYearly, 0);
}

Range =  Top-Bot;
coverage=LastValue(ATR(10));

den=(coverage/10);

//multiplier=IIf(round(totalVisible)>500,IIf(round(totalVisible)>1000,3,2),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 ) ); 
xDiff = (HaHigh - Halow) * 10000;
barcolor = IIf(HaClose >= HaOpen,colorGreen,colorRed);
PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "", barcolor, styleCandle );

multiplier=IIf(round(totalVisible)/300<1,1,round(totalVisible)/300);


if(ViewVlines==1)
{
Plot(BarsInDay==0, "", ParamColor("Base Line Color",colorDarkGrey), styleHistogram | styleOwnScale | styleLine | styleNoLabel);
}


relTodayRange = 0;
x=0;
basey=0;
basex=0;
newday=0;
total=0;
shiftup=0;
shiftdn=0;
Line=Null;
Voloumeunit=0;


for (  i = FirstVisibleBar; i <Lastvisiblebar AND i<BarCount-1 ; i++  )
{
	if(BarsInDay[i]==0)
	{t=BarsInDay[i-1];



		//////////////////////////////////
poc=0;pocj=0;
midrange = int(relTodayRange/2)+1;


for (j=1; j<= relTodayRange+1 ; j++) 
	{
		if(poc < x[j])
		{
		poc=x[j]; pocj=j;}
		else if(poc == x[j])
			{
			if (abs(midrange-j)< abs(midrange-pocj)){
			poc = x[j]; pocj = j; 
			}
		}
  
	}

for ( n = 1; n <= relTodayRange; n++ )
	{
		total[n]=x[n]+total[n-1];
	}

Value_area=(total[relTodayRange]*percent)/100;


for ( a = 1; a <= relTodayRange; a++ )
{
	if(pocj-a>0 AND pocj+a<relTodayRange)
	{
		if(poc+total[pocj+a]-total[pocj]+(total[pocj]-poc)-total[pocj-(a+1)]>=Value_area) {shiftup=a; shiftdn=a; break;}
	 	}	
		else if(pocj-a<1 ) 
		{
		if(poc+total[pocj+a]-total[pocj]+(total[pocj]-poc)>=Value_area){shiftup=a; shiftdn=pocj; break;}		
   		}
		else if(pocj+a>relTodayRange ) 
		{
		if(poc+total[relTodayRange]-total[pocj]+(total[pocj]-poc)-total[pocj-(a+1)] >=Value_area){shiftup=floor(relTodayRange)-pocj; shiftdn=a+1; break;}		
   	}
}


if(ViewVpoc==1)
{
Virginpoc=basey+pocj*den;
newi=0;
for( j = i+1; j <= (BarCount - 1) ; j++ )
if( L[j] < Virginpoc AND H[j]>Virginpoc )
{newi=j;break;}
else{newi=BarCount;}
vishycolor=IIf(BarCount%2==0,colorRed,colorBlue);
Plot(LineArray(basex[i],basey+pocj*den,newi,basey+pocj*den),"",vishycolor,styleLine|styleNoRescale);
//Plot(LineArray(basex[i],basey+pocj*den,newi,basey+pocj*den),"",colorYellow,styleLine|styleNoRescale);
}

Vah = LineArray(baseX[i], baseY+(pocj+shiftup)*den, i, baseY+(pocj+shiftup)*den);
Val = LineArray(baseX[i], baseY+(pocj-shiftdn)*den, i, baseY+(pocj-shiftdn)*den);
pocline=LineArray(basex,basey+pocj*den,basex[i]+poc,basey+pocj*den);

//Plot(Vah,"",ParamColor("Color_VAH_Line", colorBlueGrey),styleLine|styleNoRescale);
//Plot(Val,"",ParamColor("Color_VAL_Line", colorBlueGrey),styleLine|styleNoRescale);

Vahn = LineArray(i, baseY+(pocj+shiftup)*den, i+t, baseY+(pocj+shiftup)*den);
pocn = LineArray(i, baseY+(pocj)*den, i+t, baseY+(pocj)*den);
Valn = LineArray(i, baseY+(pocj-shiftdn)*den, i+t, baseY+(pocj-shiftdn)*den);

Plot(pocline,"",ParamColor("Color_POC_Line",colorDarkBlue),styleLine|styleNoRescale|styleNoLabel);

if(ViewYvalues==1)
{
Plot(Vahn,"",ParamColor("YVAH",colorBrightGreen),styleDashed|styleNoRescale);
Plot(Valn,"",ParamColor("YVAL",colorYellow),styleDashed|styleNoRescale);
Plot(pocn,"",ParamColor("YPOC",colorDarkRed),styleDashed|styleNoRescale);

}
//PlotOHLC(Vahn,Vahn,Valn,Valn,"",colorPink,styleCloud|styleOwnScale);


if(ViewTPO==1)
{
nnn=HHV(H,BarsInDay);
PlotText(""+(total[relTodayRange]-total[pocj]),basex[i],nnn[i],colorLightGrey);
PlotText(""+(total[pocj-1]),basex[i],basey-den,colorLightGrey);
}

if(Viewvalues==1)
{
PlotText(""+((basey+pocj*den)),baseX[i],basey+pocj*den,colorWhite,colorDarkGrey);
PlotText(""+((baseY+(pocj+shiftup)*den)),baseX[i],baseY+(pocj+shiftup)*den,colorWhite,colorDarkGrey);
PlotText(""+((baseY+(pocj-shiftdn)*den)),baseX[i],baseY+(pocj-shiftdn)*den,colorWhite,colorDarkGrey);
}


for (p = 0; p <= relTodayRange+1; p=p+multiplier)
{
	if(P>0){
	line = LineArray(baseX, baseY+(p)*Den, baseX+x[p], baseY+(p)*Den);

	}
	
	Plot(line,"",IIf(p>(pocj+shiftup),ParamColor("Color_Above_VA",  colorDarkRed),IIf(p<=(pocj+shiftup)AND p>=(pocj-shiftdn),ParamColor("Color_VA", colorDarkBlue),ParamColor("Color_Below_VA",   colorDarkRed))) , EnMP2);

	
}

Plot(pocline,"",ParamColor("Color_POC_Line",colorDarkRed),styleLine|styleNoRescale);

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

basex=0;
		x=0;
		Basex=i;
		baseY=Bot[i];
		relTodayRange=Range[i]/Den;
		Voloumeunit=Vol[i]/LastValue(BarsInDay);

	}

	for (j=0; j<= relTodayRange ; j++) 
	{	
		if (L[i] <= Bot[i]+j*Den AND H[i] >= Bot[i]+j*Den  ) 
		{
			if(Type=="Price Profile"){x[j]=(x[j])+x_scale;}
			else if(Type=="Volume Profile"){x[j]=x[j]+round(V[i]/Voloumeunit)+1;}
		}
	}
}

	
//////////////////////////////////
poc=0;pocj=0;
midrange = int(relTodayRange/2)+1;

for (j=1; j<= relTodayRange+1 ; j++) 
	{
		if(poc < x[j])
		{
		poc=x[j]; pocj=j;}
		else if(poc == x[j])
			{
			if (abs(midrange-j)< abs(midrange-pocj)){
			poc = x[j]; pocj = j; 
			}
		}
  
	}

for ( n = 1; n <= relTodayRange; n++ )
	{
		total[n]=x[n]+total[n-1];
	}

Value_area=(total[relTodayRange]*percent)/100;


for ( a = 1; a <= relTodayRange; a++ )
{
	if(pocj-a>0 AND pocj+a<relTodayRange)
	{
		if(poc+total[pocj+a]-total[pocj]+(total[pocj]-poc)-total[pocj-(a+1)]>=Value_area) {shiftup=a; shiftdn=a; break;}
	 	}	
		else if(pocj-a<1 ) 
		{
		if(poc+total[pocj+a]-total[pocj]+(total[pocj]-poc)>=Value_area){shiftup=a; shiftdn=pocj; break;}		
   		}
		else if(pocj+a>relTodayRange ) 
		{
		if(poc+total[relTodayRange]-total[pocj]+(total[pocj]-poc)-total[pocj-(a+1)] >=Value_area){shiftup=floor(relTodayRange)-pocj; shiftdn=a+1; break;}		
   	}
}

Vah = LineArray(baseX[i], baseY+(pocj+shiftup)*den, i, baseY+(pocj+shiftup)*den);
Val = LineArray(baseX[i], baseY+(pocj-shiftdn)*den, i, baseY+(pocj-shiftdn)*den);
pocline=LineArray(basex,basey+pocj*den,basex[i]+poc,basey+pocj*den);

if(ViewTPO==1)
{
PlotText(""+(total[relTodayRange]-total[pocj]),basex[i],top[i],colorLightGrey);
PlotText(""+(total[pocj-1]+x_scale),basex[i],basey-den,colorLightGrey);
}

if(Viewvalues==1)
{
PlotText(""+((basey+pocj*den)),baseX[i],basey+pocj*den,colorWhite,colorDarkGrey);
PlotText(""+((baseY+(pocj+shiftup)*den)),baseX[i],baseY+(pocj+shiftup)*den,colorWhite,colorDarkGrey);
PlotText(""+((baseY+(pocj-shiftdn)*den)),baseX[i],baseY+(pocj-shiftdn)*den,colorWhite,colorDarkGrey);
}

for (p = 0; p <= relTodayRange+1; p=p+multiplier)
{
	line = LineArray(baseX, baseY+p*Den, baseX+x[p], baseY+p*Den);

	Plot(line,"",IIf(p>(pocj+shiftup),ParamColor("Color_Above_VA",  colorGrey40),IIf(p<=(pocj+shiftup)AND p>=(pocj-shiftdn),ParamColor("Color_VA", colorBlueGrey),ParamColor("Color_Below_VA",colorGrey40))),EnMP2);
	
	Plot(pocline,"",ParamColor("Color_POC_Line",colorYellow),styleLine|styleNoRescale|styleNoLabel);
}
_SECTION_END();

_SECTION_BEGIN("Volume");
Plot( Volume, _DEFAULT_NAME(), ParamColor("Color", colorDarkGreen), styleNoTitle | ParamStyle( "Style", styleHistogram | styleOwnScale | styleThick | styleNoLabel, maskHistogram  ), 2 );
_SECTION_END();
//SetChartOptions(0,chartShowArrows | chartShowDates);
_SECTION_BEGIN("Heikin Ashi");

_SECTION_END();

_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 );
_SECTION_END();
//=================TITLE================================================================================================
_SECTION_BEGIN("Title");
if( Status("action") == actionIndicator ) 
(
Title = EncodeColor(colorWhite)+ "Ranjit's 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();
My AFL here ? excited
 
Status
Not open for further replies.

Similar threads