nakshatra modified

#1
one of my friend give me this afl he combine two or more formulas i think it helps to avoid some false signals in nakshatra.credit goees to orginal programming experts.



_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", colorBlack ), 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),colorBlue, 0,H, Offset=-30);

}

//------------------------------------------------------------------------------------------------
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, colorBlue ), 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( "AJEET SINGH", Status("pxwidth")/C14, Status("pxheight")/C15*2.5 );
GfxSelectFont("Tahoma", Status("pxheight")/C13*0.5 );
GfxSetTextColor( ColorRGB (103,103,103));
GfxTextOut( "", 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("Trading");
//SetChartBkColor(ParamColor("Outer panel color ",colorLightYellow));
SetChartBkColor(ParamColor("BackGround Color", colorBlack));
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 = "^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));

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)+ "Trading System" + " - " + 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( colorLightBlue, 3 );
GfxSelectSolidBrush( colorLightYellow );
GfxRoundRect( 20, 55, 180, 175, 15, 15 );
GfxSetBkMode(1);
GfxSelectFont( "Arial", 10, 700, False );
GfxSetTextColor( colorBrown );
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 < NW[i-1])
{
Trend = -1;
NW = j + Revers;
}
else
{
Trend = 1;
if((j - Revers) > NW[i-1])
{
NW = j - Revers;
}
else
{
NW = NW[i-1];
}
}
}
if(Trend[i-1] == -1)
{
if(j > NW[i-1])
{
Trend = 1;
NW = j - Revers;
}
else
{
Trend = -1;
if((j + Revers) < NW[i-1])
{
NW = j + Revers;
}
else
{
NW = 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 ) PlotText( "Buy@" + O[ i ], i, L[ i ]-Trend, colorDarkBlue, colorYellow );
if( Sell ) PlotText( "Sell@" +H[ i ], i-4, L[ i ]+Trend, 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);

_SECTION_BEGIN("Price");
Ribbon1=IIf( EMA( Close , 13 )>EMA( Close ,34 ) ,colorGreen, IIf(EMA( Close , 34 )>EMA( Close , 13 ), colorRed,colorYellow));
Plot(2, "Ribbon", Ribbon1, styleOwnScale| styleArea| styleNoLabel,-0.5,100);
_SECTION_END();

_SECTION_BEGIN("sheroune");

SetChartBkColor( colorBlack ) ;
f = Param("fast ema",12,1,50,1);
s = Param("Slow ema",26,2,100,1);
t = Param ("signal",9,1,50,1);
A1=EMA(C,f)-EMA(C,s);
a2 = EMA(a1,t);
Hist = a1-a2;
em = EMA(Hist,2);
D1=14;

ST33=StochD(14);
Ar=EMA(RSI(5),13);
RSI13 = EMA( ar, 13 );

Bar_col = IIf( st33 > 80,colorBlue,IIf( st33 < 20,colorOrange,IIf(st33 > Ref(st33,-1), colorBrightGreen, colorRed)));

em34 = EMA(C,34);
em20 = EMA(C,20);
PlotOHLC(em34,IIf(em34 > em20,em34,em20),IIf(em34 < em20,em34,em20),em34,"",IIf(em20 > em34,colorGreen,colorRed),styleCloud+styleNoLabel);

_SECTION_END();

_SECTION_BEGIN("Support-Resistance");
SupRes=ParamToggle("Sup-Res","No|Yes",1);
SupResA = Param("Sup-Res A Period",20,0,100,1);
SupResB = Param("Sup-Res B Period",25,0,100,1);

Res1 = ParamColor("Resistance High", colorRed );
Res2 = ParamColor("Resistance Low", colorDarkRed );
Sup1 = ParamColor("Support High", colorDarkGreen );
Sup2 = ParamColor("Support Low", colorBrightGreen );
if(SupRes)
{
MaxGraph = 12;
BuyOffSet = SupResA;//Optimize("BuyOffSet",18,15,20,1);
SellOffset = BuyOffSet;//Optimize("SellOffset",2,2,14,2);
RegLength = 5;//Optimize("RegLength",5, 2,11,2);
BuyATRPeriod = 2;//Optimize("BuyATRPeriod",2,2,5,1);
SellATRPeriod = BuyATRPeriod;//Optimize("SellATRPeriod",4,2,11,2);
ATRMultiplier = 0.5;//Optimize("ATRMultiplier",1,0.7,1.25,.05);
SuppA = HHV(H-ATRMultiplier*ATR(BuyATRPeriod),BuyOffset); /* RED */
RessB = LLV(L+ATRMultiplier*ATR(SellATRPeriod),SellOffset); /* GREEN */


nn=SupResB;
mmm=100;
TYP=(High + Low + 2*Close)/4;
CI=(TYP-MA(TYP,14))/(0.015*StDev(TYP,14));
CCCI=EMA(CI,5)+mmm;
Hh=HHV(H,nn);
Ll=LLV(L,nn);
MM=(Hh+Ll)/2;
CCCC=EMA(CCCI*(Hh-Ll)/(2*mmm)+Ll,5);

}
_SECTION_END();

Cover=Buy;
Short=Sell;

Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
AlertIf( Buy, "", "BUY @ " + C, 1 );
AlertIf( Sell, "", "SELL @ " + C, 2 );
no=Param( "Swing", 8, 1, 55 );
tsl_col=ParamColor( "Color", colorLightGrey );
res=HHV(H,no);
sup=LLV(L,no);
avd=IIf(C>Ref(res,-1),1,IIf(C<Ref(sup,-1),-1,0));
avn=ValueWhen(avd!=0,avd,1);
tsl=IIf(avn==1,sup,res);

no = Optimize("TSL",Param("A (Change To Optimise)",10, 1, 55 ,1),1, 55 ,1);

tsl_col=ParamColor( "Color", colorLightGrey );
res=HHV(H,no);
sup=LLV(L,no);
avd=IIf(C>Ref(res,-1),1,IIf(C<Ref(sup,-1),-1,0));
avn=ValueWhen(avd!=0,avd,1);
dtsl=IIf(avn==1,sup,res);
SellPrice=ValueWhen(Short,C,1);
BuyPrice=ValueWhen(Buy,C,1);
Long=Flip(Buy,Sell);
Shrt=Flip(Short,Cover);
Relax = NOT Long AND NOT Buy AND NOT shrt AND NOT Sell AND NOT Sell AND NOT Cover;
SellSL=ValueWhen(Short,DTSL,1);
BuySL=ValueWhen(Buy,DTSL,1);
BuyDifference= BuyPrice - BuySL;
SellDifference = SellSL - SellPrice;

tar1 = IIf(Buy OR Long AND NOT Relax AND NOT Sell AND NOT Cover, (BuyPrice + BuyDifference), (SellPrice - SellDifference));
tar2 = IIf(Buy OR Long AND NOT Relax AND NOT Sell AND NOT Cover, (BuyPrice + (2*BuyDifference)), (SellPrice - (2*SellDifference)));
tar3 = IIf(Buy OR Long AND NOT Relax AND NOT Sell AND NOT Cover, (BuyPrice + (4*BuyDifference)), (SellPrice - (4*SellDifference)));


CloseAtEnd = ParamToggle("Close Positions EOD", "No|Yes");
stopreverse =ParamToggle("Switch To Stop And Reverse","No|Yes",0);
Trend = ATR(21) < StDev (C,21);
Range = ATR(21) > StDev (C,21);
no=10;
C13=20;
C14=2.1;
C15=12;

tsl_col=ParamColor( "Color", colorLightGrey );
res=HHV(H,no);
sup=LLV(L,no);
avd=IIf(C>Ref(res,-1),1,IIf(C<Ref(sup,-1),-1,0));
avn=ValueWhen(avd!=0,avd,1);
dtsl=IIf(avn==1,sup,res);

SellPrice=ValueWhen(Short,C,1);
BuyPrice=ValueWhen(Buy,C,1);
Long=Flip(Buy,Sell);
Shrt=Flip(Short,Cover);
Relax = NOT Long AND NOT Buy AND NOT shrt AND NOT Sell AND NOT Sell AND NOT Cover;
SellSL=ValueWhen(Short,DTSL,1);
BuySL=ValueWhen(Buy,DTSL,1);
BuyDifference= BuyPrice - BuySL;
SellDifference = SellSL - SellPrice;

tar1 = IIf(Buy OR Long AND NOT Relax AND NOT Sell AND NOT Cover, (BuyPrice + BuyDifference), (SellPrice - SellDifference));
tar2 = IIf(Buy OR Long AND NOT Relax AND NOT Sell AND NOT Cover, (BuyPrice + (2*BuyDifference)), (SellPrice - (2*SellDifference)));
tar3 = IIf(Buy OR Long AND NOT Relax AND NOT Sell AND NOT Cover, (BuyPrice + (4*BuyDifference)), (SellPrice - (4*SellDifference)));
buyach1 = IIf((Buy OR Long AND NOT Relax AND NOT Cover AND NOT Short AND NOT Shrt), H > tar1, 0);
buyach2 = IIf((Buy OR Long AND NOT Relax AND NOT Cover AND NOT Short AND NOT Shrt), H > tar2 , 0);
buyach3 = IIf((Buy OR Long AND NOT Relax AND NOT Cover AND NOT Short AND NOT Shrt), H > tar3, 0);

sellach1 = IIf((Short OR Shrt AND NOT Relax AND NOT Sell AND NOT Buy AND NOT Long), L < tar1 , 0);
sellach2 = IIf((Short OR Shrt AND NOT Relax AND NOT Sell AND NOT Buy AND NOT Long), L < tar2, 0);
sellach3 = IIf((Short OR Shrt AND NOT Relax AND NOT Sell AND NOT Buy AND NOT Long), L < tar3, 0);



//Settings for exploration

Filter=Buy OR Short;
AddColumn( IIf( Buy, 66 , 83 ), "Signal", formatChar, colorDefault, IIf( Buy , colorGreen, colorRed ) );
AddColumn(Close,"Entry Price",1.4, colorDefault, IIf( Buy , colorGreen, colorRed ));
AddColumn(dtsl,"Stop Loss",1.4, colorDefault, IIf( Buy , colorGreen, colorRed ));
AddColumn(tar1,"Target 1",1.4, colorDefault, IIf( Buy , colorGreen, colorRed ));
AddColumn(tar2,"Target 2",1.4, colorDefault, IIf( Buy , colorGreen, colorRed ));
AddColumn(tar3,"Target 3",1.4, colorDefault, IIf( Buy , colorGreen, colorRed ));
AddColumn(Volume,"Volume",1.0, colorDefault, IIf ((Volume > 1.25 * EMA( Volume, 34 )),colorBlue,colorYellow));




//Short = Sell;
//Cover = Buy;

//Short = ExRem(Short, Cover);
//Cover = ExRem(Cover, Short);

GraphXSpace = 5;
pxHeight = Status( "pxchartheight" ) ;
xx = Status( "pxchartwidth");
Left = 1100;
width = 310;
x = 5;
x2 = 280;

y = pxHeight;
dist = 2*ATR(10);
dist1 = 3*ATR(10);
i=BarCount;
bars = i;

messageboard = ParamToggle("Message Board","Show|Hide",1);
if(messageboard)
{
for( i = 0; i < BarCount; i++ )
{
if( Buy )
{
// PlotText( "\nBuy:" + L[ i ] + "\nT= " + (L*1.005) + "\nSL= " + (L*0.9975), i, L[ i ]-dist, colorGreen, colorWhite );

// Signal Display Panel //

SellPrice=ValueWhen(Sell,C,1);
BuyPrice=ValueWhen(Buy,L[ i ]);
Long=Flip(Buy,Sell);
Shrt=Flip(Sell,Buy );
BuyStop2 = L*0.9975;
BuyTP1 = L*1.070;
BuyTP2 = L*1.050;
BuyTP3 = L*1.035;
buyach1 = IIf((Buy OR Long AND NOT Relax AND NOT Cover AND NOT Short AND NOT Shrt), H > BuyTP3, 0);
buyach2 = IIf((Buy OR Long AND NOT Relax AND NOT Cover AND NOT Short AND NOT Shrt), H > BuyTP2, 0);
buyach3 = IIf((Buy OR Long AND NOT Relax AND NOT Cover AND NOT Short AND NOT Shrt), H > BuyTP1, 0);
GfxSelectFont( "Tahoma", 13, 100 );
GfxSetOverlayMode( mode = 0 );
GfxSelectPen( colorBrightGreen, 3 );
GfxSelectSolidBrush( colorBrightGreen);
GfxRoundRect( x, y - 163, x2, y , 7, 7 ) ;
GfxSetTextColor( colorGold );
GfxTextOut( ( " Trading System "),73,y-165);
GfxTextOut( (" "),27,y-160);
GfxSetBkMode(1);
GfxSelectFont( "Arial", 10, 700, False );
GfxSetTextColor( colorBlue );
GfxSetTextAlign(0);
GfxSelectFont( "Tahoma", 13, 100 );

GfxTextOut( WriteIf(L[ i ], "Buy Above: "+L[ i ],""), 13, y-140);
GfxSetTextColor( colorGold );
GfxTextOut( WriteIf(BuyStop2, "Long SL: "+(BuyStop2),""), 13, y-120);
GfxSetTextColor( colorWhite );
GfxTextOut( WriteIf(BuyTP1, "Buy TGT1: "+(BuyTP3),""), 13,y- 100);
GfxTextOut( WriteIf(BuyTP2, "Buy TGT2: "+(BuyTP2),""), 13,y- 80);
GfxTextOut( WriteIf(BuyTP3, "BuyTGT3: "+(BuyTP1),""), 13,y- 60);
GfxSetTextColor( colorViolet );
GfxTextOut( ("Current P/L : " + WriteVal(IIf(Buy ,(C-BuyPrice),(C-BuyPrice)),2.2)), 88, y-22);
GfxTextOut( ("Buy Signal came " + (BarCount-bars +1) * Interval()/2 + " mins ago"), 13, y-40) ;
GfxTextOut
( ("" + WriteIf (buyach1, " Done: "+BuyTP3,"")), 160, y-100);
GfxTextOut
( ("" + WriteIf (buyach2, " Done: "+BuyTP2,"")), 160, y-80);
GfxTextOut
( ("" + WriteIf (buyach3, " Done: "+BuyTP1,"")), 160, y-60);
// END of Signal Display Panel //
}
if( Sell )
{
// PlotText( "Sell:" + H[ i ] + "\nT= " + (H*0.995) + "\nSL= " + (H*1.0025), i, H[ i ]+dist1, colorRed, colorWhite );

// Signal Display Panel //
SellPrice=ValueWhen(Sell,C,1);
BuyPrice=ValueWhen(Buy,H[ i ]);
Long=Flip(Buy,Sell);
Shrt=Flip(Sell,Buy );
SellStop2 = H*1.0025;
SellTP1 = H*0.978;
SellTP2 = H*0.982;
SellTP3 = H*0.988;
sellach1 = IIf((Short OR Shrt AND NOT Relax AND NOT Sell AND NOT Buy AND NOT Long), L < SellTP3 , 0);
sellach2 = IIf((Short OR Shrt AND NOT Relax AND NOT Sell AND NOT Buy AND NOT Long), L < SellTP2, 0);
sellach3 = IIf((Short OR Shrt AND NOT Relax AND NOT Sell AND NOT Buy AND NOT Long), L < SellTP1, 0);

GfxSelectFont( "Tahoma", 13, 100 );
GfxSetOverlayMode( mode = 0 );
GfxSelectPen( colorRed, 3 );
GfxSelectSolidBrush( colorRed );
GfxRoundRect( x, y - 163, x2, y , 7, 7 ) ;

GfxTextOut( (" "),27,y-160);
GfxSetBkMode(1);
GfxSelectFont( "Arial", 10, 700, False );
GfxSetTextColor( colorWhite );
GfxSetTextAlign(0);
GfxSelectFont( "Tahoma", 13, 100 );
GfxSetTextColor( colorGold );
GfxTextOut( ( " Trading System "),73,y-165);
GfxSetTextColor( colorWhite );
GfxTextOut( WriteIf(H[ i ], "Sell Below: "+H[ i ],""), 13, y-140);
GfxSetTextColor( colorGold );
GfxTextOut( WriteIf(SellStop2, "Short SL: "+(SellStop2),""), 13, y-120);
GfxSetTextColor( colorBlue );
GfxTextOut( WriteIf(SellTP1, "Short TGT1: "+(SellTP3),""), 13, y-100);
GfxTextOut( WriteIf(SellTP2, "Short TGT2: "+(SellTP2),""), 13, y-80);
GfxTextOut( WriteIf(SellTP3, "Short TGT3: "+(SellTP1),""), 13, y-60);
GfxSetTextColor( colorGold );
GfxTextOut( ("Current P/L : " + WriteVal(IIf(Sell ,(SellPrice-C),(SellPrice-C)),2.2)), 88, y-22);
GfxTextOut( ("sell Signal came " + (BarCount-bars +1) * Interval()/2 + " mins ago"), 13, y-40) ;
GfxTextOut
( ("" + WriteIf (sellach1, " Done: "+SellTP3,"")), 160, y-100);
GfxTextOut
( ("" + WriteIf (sellach2, " Done: "+SellTP2,"")), 160, y-80);
GfxTextOut
( ("" + WriteIf (sellach3, " Done: "+SellTP1,"")), 160, y-60);
// END of Signal Display Panel //
}}}



Long=Flip(Buy,Sell);
Shrt=Flip(Sell,Buy);

BuyPrice=ValueWhen(Buy,C);
SellPrice=ValueWhen(Sell,C);


Edc=(
WriteIf (Buy AND Ref(shrt,-1), " BUY @ "+C+" ","")+
WriteIf (Sell AND Ref(Long,-1), " SEll @ "+C+" ","")+
WriteIf(Sell , "Last Trade Profit Rs."+(C-BuyPrice)+"","")+
WriteIf(Buy , "Last Trade Profit Rs."+(SellPrice-C)+"",""));

//============== TITLE ==============
_SECTION_BEGIN("Title");
no=Param( "Swing", 6, 1, 55 );
res=HHV(H,no);
sup=LLV(L,no);
avd=IIf(C>Ref(res,-1),1,IIf(C<Ref(sup,-1),-1,0));
avn=ValueWhen(avd!=0,avd,1);
tsl=IIf(avn==1,sup,res);
dec = (Param("Decimals",2,0,7,1)/10)+1;
if( Status("action") == actionIndicator )
(
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.25)




+"\n"+EncodeColor(colorBrightGreen)+

WriteIf (Buy , "Signal: Go Long - Entry Price: "+WriteVal(C)+" - Traget: "+WriteVal((BuyPrice-tsl)+BuyPrice)

+" - StopLoss:"+WriteVal(tsl)+" "

,"")+

"\n"+EncodeColor(colorRed)+
WriteIf (Sell , "Signal: Go Short - Entry Price: "+WriteVal(C)+" - Target: "+WriteVal((tsl-SellPrice)-SellPrice)+" - StopLoss:"+WriteVal(tsl)+" ","")+
EncodeColor(colorTurquoise)+
WriteIf(Long AND NOT Buy, "Trade: Long - Entry Price: "+WriteVal((BuyPrice))+" - Profit: "+WriteVal((C-BuyPrice))+" "+EncodeColor(colorLime)+"Let your profit runs!","")+
EncodeColor(colorLightOrange)+
WriteIf(shrt AND NOT Sell, "Trade: Short - Entry Price: "+WriteVal((SellPrice))+" - Profit: "+WriteVal((SellPrice-C))+" - "+EncodeColor(colorLime)+"Let your profit runs!","")


);
_SECTION_END();


if (messageboard == 0 )
{
if( Status("action") == actionIndicator )
(

Title = EncodeColor(55)+ Title = Name() +
" " + EncodeColor(5) + "{{INTERVAL}} " + EncodeColor(colorSkyblue) +
" " + Date() +" "+"\n" +EncodeColor(55) +"Open-"+EncodeColor(52)+O+EncodeColor(55)+" High-"+EncodeColor(5)+H+" "+EncodeColor(55)+"Low-"+EncodeColor(32)+L+" "+EncodeColor(55)+"Close-"+EncodeColor(52)+C+" "+EncodeColor(55)+ "Volume= "+EncodeColor(52)+ WriteVal(V)+"\n"+"\n"+

EncodeColor(colorLime)+
WriteIf (Buy, "Action: Go Long At "+C+" - SL " +DTSL,"")+
WriteIf (Short, "Action: Go Short At "+C+" - SL " +DTSL,"")+
WriteIf(Long AND NOT Buy, "Action : Long Taken At "+(BuyPrice)+" - Trail SL @ " + DTSL + "","")+
WriteIf(shrt AND NOT Sell, "Action : Short Taken At "+(SellPrice)+" - Trail SL @ " + DTSL + "","")+
WriteIf (Sell AND NOT Short, "Exit Long At "+C,"")+
WriteIf (Cover AND NOT Buy, "Exit Short At "+C,"")+
WriteIf(NOT Long AND NOT Buy AND NOT shrt AND NOT Sell, "Action: Not In A Trade - RELAX!!!","")+"\n"+
WriteIf(Long AND NOT Buy, "Profit/Loss: "+(C-BuyPrice)+" Points","")+
WriteIf(shrt AND NOT Sell, "Profit/Loss: "+(SellPrice-C)+" Points","")+"\n"+
WriteIf(Long OR Buy OR Shrt OR Short, "Target 1: "+tar1,"")+"\n"+
WriteIf(Long OR Buy OR Shrt OR Short, "Target 2: "+tar2,"")+"\n"+
WriteIf(Long OR Buy OR Shrt OR Short, "Target 3: "+tar3,"")+"\n"+
WriteIf(buyach1, "Target 1 Done: "+tar1,"")+
WriteIf(sellach1, "Target 1 Done: "+tar1,"")+"\n"+
WriteIf(buyach2, "Target 2 Done: "+tar2,"")+
WriteIf(sellach2, "Target 2 Done: "+tar2,"")+"\n"+
WriteIf(buyach3, "Target 3 Done: "+tar3,"")+
WriteIf(sellach3, "Target 3 Done: "+tar3,""));
}
for( i = 0; i < BarCount; i++ )
{
if( Buy )
{

OUTcolor = ParamColor("Outer Panel Color",colorTeal);
INUPcolor = ParamColor("Inner Panel Upper",colorDarkGrey);
INDNcolor = ParamColor("Inner Panel Lower",colorDarkOliveGreen);
TitleColor = ParamColor("Title Color ",colorBlack);
SetChartBkColor(OUTcolor); // color of outer border
SetChartBkGradientFill(INUPcolor,INDNcolor,TitleColor); // color of inner panel
}
if( Sell )
{
OUTcolor = ParamColor("Outer Panel Color",colorTeal);
INUPcolor = ParamColor("Inner Panel Upper2",colorDarkTeal);
INDNcolor = ParamColor("Inner Panel Lower2",colorPlum);
TitleColor = ParamColor("Title Color ",colorBlack);
SetChartBkColor(OUTcolor); // color of outer border
SetChartBkGradientFill(INUPcolor,INDNcolor,TitleColor); // color of inner panel
}
}
 
Last edited:

XRAY27

Well-Known Member
#2
Dear traderami
Only problem with nakshatra is buy trigger is @ opening of candle...so it is useless in many ways.... you shared the afl that is very good for the forum keep sharing....
 

Similar threads