Stock Portfolio Organizer

The ultimate porfolio management solution.

Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
For Portfolio Manager Click Here

WiseTrader Toolbox

#1 Selling Amibroker Plugin featuring:

Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Find Out More Here

Kavach Of Karna v2 for Amibroker (AFL)

Rating:
3 / 5 (Votes 11)
Tags:
amibroker

never stay shot after yellow stop loss line is crossed.
Buy on crossing of yellow stop loss lineā€¦
12 min time Frame is best

This version has ability to predict trend
the lighblue line predicts trend in advance….

i just happened to put all the good
things in 1 glass and here it is
Good luck

Screenshots

Similar Indicators / Formulas

Trend Magic Modified-DR BHOIR GB
Submitted by bhoirGB over 9 years ago
Advanced Elliott Waves
Submitted by MarcosEn over 12 years ago
3_6Day GuaiLiLv
Submitted by motorfly over 12 years ago
Williams Alligator System
Submitted by durgesh1712 over 12 years ago
*Level Breakout system*
Submitted by Tinych over 12 years ago
Horizontal Live Priceline Tool
Submitted by northstar over 12 years ago

Indicator / Formula

Copy & Paste Friendly
KeltnerBands = ParamToggle("Keltner Bands","Show|Hide",1);
fibs = ParamToggle("Plot Fibs","Off|On",0);
ICHIMOKU = ParamToggle("Plot ICHIMOKU ","Off|On",0);
BBand = ParamToggle("BolliBand", "Show|Hide", 0);
aama = ParamToggle("Plot Ema ","Off|On",1);
ahl = ParamToggle("Plot YHiLo ","Off|On",0);
text = ParamToggle("Fib Text","Off|On",1);

_SECTION_BEGIN("Small Triggers");
p1 = Param("TL 1 Periods", 20, 5, 50, 1);
p2 = Param("TL 2 Periods", 5, 3, 25, 1);
TL1 = LinearReg(C, p1);
TL2 = EMA(TL1, p2);
Col1 = IIf(TL1 > TL2, ParamColor("TL Up Colour", colorBrightGreen), ParamColor("TL Dn Colour", colorCustom12));
Plot(TL1, "TriggerLine 1", Col1, styleLine|styleThick|styleNoLabel);
_SECTION_END();


XNAME = Name();
VAL_EXISTS = 0;
T2= "";
Prd1=Param("ATR Period",4,1,20,1);
Prd2=Param("Look Back",8,1,20,1);
green = HHV(LLV(L,Prd1)+ATR(Prd1),Prd2);
red = LLV(HHV(H,Prd1)-ATR(Prd1),Prd2);

HighClosePercent = (H - C)*100/H;
HighLowPercent = MA((H - L)*100/H,25);

barColor=IIf(C>Green ,colorBlue,IIf(C < RED,colorRed,IIf(HighClosePercent>5,colorYellow,IIf(HighLowPercent>5  AND ROC(C,1,True)<-3,colorRed,colorWhite))));
( IIf(C>Green AND ROC(C,1,True)<-4.5,colorBlue,colorBlack));

flowerOpen = O;
flowerClose = C;
flowerHigh= H;
flowerLow = L;

_SECTION_BEGIN("Price");
PlotOHLC( IIf(flowerOpen<flowerClose, flowerOpen, flowerClose),flowerHigh,flowerLow,IIf(flowerOpen<flowerClose, flowerClose, flowerOpen), "Close", barColor, styleNoTitle | styleCandle);
SetChartOptions(0,chartShowArrows|chartShowDates);
_SECTION_END();




if(aama==1){
_SECTION_BEGIN("ema");
P = ParamField("Field");
Type = ParamList("Type", "Weighted,Simple,Exponential,Double Exponential,Tripple Exponential,Wilders");

Periods89 = Param("Periods180", 180, 2, 300 );
Displacement2 = Param("Displacement2", 2, -50, 50 );
Plot( EMA( P, Periods89 ),
_DEFAULT_NAME(), colorWhite, styleDots, 0, 0, Displacement2 );
_SECTION_END();
}
///////////////////////////ZERO//////////////////////


if(KeltnerBands==1) {

Smooth = Param("Smoothness",14,2,100,1);
Length = 20; Num_ATRs = 2;
// 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",colorOrange,styleDashed);
Plot (MA(Mov_Avg,smooth),"Mov_Avg",colorGrey40, styleLine);

}



ppl = ParamToggle("Levels","Off|On",0);
numbars = LastValue(Cum(Status("barvisible")));
fraction= IIf(StrRight(Name(),3) == "", 3.2, 3.2);
hts = -33.5;


_SECTION_BEGIN("Price");
pds = 20;
MAFAST = EMA( Close, 20 );
MASLOW = EMA( Close, 40 );
 
DonchianUpper = HHV( Ref( H, -1 ), pds ); // Highest high value of highs in last 20 periods
DonchianLower = LLV( Ref( L, -1 ), pds ); // Lowest low value of low in last 20 periods
DonchianMiddle = ( DonchianUpper + DonchianLower ) / 2;

UpTrend = C > ( LLV( L, 20 ) + 2 * ATR( 10 ) ) AND EMA( Close, 20 ) > EMA( Close, 40 );
DnTrend = C < ( HHV( H, 20 ) - 2 * ATR( 10 ) ) AND EMA( Close, 20 ) < EMA( Close, 40 );
Color = IIf( UpTrend, colorBlue, IIf( DnTrend, colorRed, colorOrange) );
 
// Plots a 20 period Donchian channel
Plot( C, "Price", Color, styleCandle | styleThick );
NewDay = IIf(Day() != Ref(Day(), -1) OR BarIndex() == LastValue(BarIndex()), 1, 0);
//Plot(NewDay, "", 47, 2 + 32768 + 4096, Minvalue = 0, Maxvalue = 1);
_SECTION_END();


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

_SECTION_BEGIN("PIVOT POINTS");

/* This code calculates the previous days high, low and close */
Hi1 = IIf(Day()!=Ref(Day(),-1),Ref(HighestSince(Day()!=Ref(Day(),-1),H,1),-1),0);
Hi = ValueWhen(Day()!=Ref(Day(),-1),Hi1,1);
Lo1 = IIf(Day()!=Ref(Day(),-1),Ref(LowestSince(Day()!=Ref(Day(),-1),L,1),-1),0);
Lo = ValueWhen(Day()!=Ref(Day(),-1),Lo1,1);
Cl1 = IIf(Day()!=Ref(Day(),-1),Ref(C,-1),0);
C1 = ValueWhen(Day()!=Ref(Day(),-1),Cl1,1);
wHi=TimeFrameGetPrice("H",inWeekly,-1);
wLo=TimeFrameGetPrice("L",inWeekly,-1);
wCl=TimeFrameGetPrice("C",inWeekly,-1);
mHi=TimeFrameGetPrice("H",inMonthly,-1);
mLo=TimeFrameGetPrice("L",inMonthly,-1);
mCl=TimeFrameGetPrice("C",inMonthly,-1);

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

/* This code calculates Daily Piovts */

rg = (Hi - Lo);
bp = (Hi + Lo + C1)/3; bpI = LastValue (bp,1);
r1 = (bp*2)-Lo; r1I = LastValue (r1,1);
s1 = (bp*2)-Hi; s1I = LastValue (s1,1);
r2 = bp + r1 - s1; r2I = LastValue (r2,1);
s2 = bp - r1 + s1; s2I = LastValue (s2,1);
r3 = bp + r2 - s1; r3I = LastValue (r3,1);
s3 = bp - r2 + s1; s3I = LastValue (s3,1);
r4 = bp + r2 - s2; r4I = LastValue (r4,1);
s4 = bp - r2 + s2; s4I = LastValue (s4,1);
wrg = (wHi - wLo);
wbp = (wHi + wLo + wCl)/3; wbpI = LastValue (wbp,1);
wr1 = (wbp*2)-wLo; wr1I = LastValue (wr1,1);
ws1 = (wbp*2)-wHi; ws1I = LastValue (ws1,1);
wr2 = wbp + wr1 - ws1; wr2I = LastValue (wr2,1);
ws2 = wbp - wr1 + ws1; ws2I = LastValue (ws2,1);
wr3 = wbp + wr2 - ws1; wr3I = LastValue (wr3,1);
ws3 = wbp - wr2 + ws1; ws3I = LastValue (ws3,1);
wr4 = wbp + wr2 - ws2; wr4I = LastValue (wr4,1);
ws4 = wbp - wr2 + ws2; ws4I = LastValue (ws4,1);
mrg = (mHi - mLo);
mobp = (mHi + mLo + mCl)/3; mobpI = LastValue (mobp,1);
mr1 = (mobp*2)-mLo; mr1I = LastValue (mr1,1);
ms1 = (mobp*2)-mHi; ms1I = LastValue (ms1,1);
mr2 = mobp + mr1 - ms1; mr2I = LastValue (mr2,1);
ms2 = mobp - mr1 + ms1; ms2I = LastValue (ms2,1);

if(ppl==1) {
Plot(bp,"",colorWhite,styleLine|styleLine|styleNoRescale);
Plot(s1,"",colorBrightGreen,styleDashed|styleNoRescale);
Plot(s2,"",colorBrightGreen,styleDashed|styleNoRescale);
Plot(s3,"",colorBrightGreen,styleDashed|styleNoRescale);
Plot(s4,"",colorBrightGreen,styleDashed|styleNoRescale);
Plot(r1,"",colorRed,styleDashed|styleNoRescale);
Plot(r2,"",colorRed,styleDashed|styleNoRescale);
Plot(r3,"",colorRed,styleDashed|styleNoRescale);
Plot(r4,"",colorRed,styleDashed|styleNoRescale);
Plot(wbp,"",colorTan,styleDashed|styleLine|styleNoRescale);
Plot(ws1,"",colorBlue,styleDashed|styleNoRescale);
Plot(ws2,"",colorBlue,styleDashed|styleNoRescale);
//Plot(ws3,"",colorPaleGreen,styleDashed|styleNoRescale);
//Plot(ws4,"",colorPaleGreen,styleDashed|styleNoRescale);
Plot(wr1,"",colorYellow,styleDashed|styleNoRescale);
Plot(wr2,"",colorYellow,styleDashed|styleNoRescale);
//Plot(wr3,"",colorPaleBlue,styleDashed|styleNoRescale);
//Plot(wr4,"",colorPaleBlue,styleDashed|styleNoRescale);
Plot(mobp,"",colorTan,styleDashed|styleLine|styleNoRescale);
Plot(ms1,"",colorPaleGreen,styleDashed|styleNoRescale);
Plot(mr1,"",colorDarkRed,styleDashed|styleNoRescale);
PlotText(" Pivot = " + WriteVal(bp,fraction), LastValue(BarIndex())-(numbars/Hts), bpI +0.05, colorWhite);
PlotText(" Resistance 1 = " + WriteVal(r1,fraction), LastValue(BarIndex())-(numbars/Hts), r1I +0.05, colorRed);
PlotText(" Support 1 = " + WriteVal(s1,fraction), LastValue(BarIndex())-(numbars/Hts), s1I +0.05, colorGreen);
PlotText(" Resistance 2 = " + WriteVal(r2,fraction), LastValue(BarIndex())-(numbars/Hts), r2I +0.05, colorRed);
PlotText(" Support 2 = " + WriteVal(s2,fraction), LastValue(BarIndex())-(numbars/Hts), s2I +0.05, colorBrightGreen);
PlotText(" Resistance 3 = " + WriteVal(r3,fraction), LastValue(BarIndex())-(numbars/Hts), r3I +0.05, colorRed);
PlotText(" Support 3 = " + WriteVal(s3,fraction), LastValue(BarIndex())-(numbars/Hts), s3I +0.05, colorBrightGreen);
PlotText(" Resistance 4 = " + WriteVal(r4,fraction), LastValue(BarIndex())-(numbars/Hts), r4I +0.05, colorRed);
PlotText(" Support 4 = " + WriteVal(s4,fraction), LastValue(BarIndex())-(numbars/Hts), s4I +0.05, colorBrightGreen);
PlotText(" W Pivot = " + WriteVal(wbp,fraction), LastValue(BarIndex())-(numbars/Hts), wbpI +0.05, colorTan);
PlotText(" W Resistance 1 = " + WriteVal(wr1,fraction), LastValue(BarIndex())-(numbars/Hts), wr1I +0.05, colorYellow);
PlotText(" W Support 1 = " + WriteVal(ws1,fraction), LastValue(BarIndex())-(numbars/Hts), ws1I +0.05, colorBlue);
PlotText(" W Resistance 2 = " + WriteVal(wr2,fraction), LastValue(BarIndex())-(numbars/Hts), wr2I +0.05, colorYellow);
PlotText(" W Support 2 = " + WriteVal(ws2,fraction), LastValue(BarIndex())-(numbars/Hts), ws2I +0.05, colorBlue);
//PlotText(" W Resistance 3 = " + WriteVal(wr3,fraction), LastValue(BarIndex())-(numbars/Hts), wr3I +0.05, colorPaleBlue);
//PlotText(" W Support 3 = " + WriteVal(ws3,fraction), LastValue(BarIndex())-(numbars/Hts), ws3I +0.05, colorPaleGreen);
//PlotText(" W Resistance 4 = " + WriteVal(wr4,fraction), LastValue(BarIndex())-(numbars/Hts), wr4I +0.05, colorPaleBlue);
//PlotText(" W Support 4 = " + WriteVal(ws4,fraction), LastValue(BarIndex())-(numbars/Hts), ws4I +0.05, colorPaleGreen);
PlotText(" M Pivot = " + WriteVal(mobp,fraction), LastValue(BarIndex())-(numbars/Hts), mobpI+0.05, colorTan);
PlotText(" M Resistance 1 = " + WriteVal(mr1,fraction), LastValue(BarIndex())-(numbars/Hts), mr1I+0.05, colorPaleBlue);
PlotText(" M Support 1 = " + WriteVal(ms1,fraction), LastValue(BarIndex())-(numbars/Hts), ms1I+0.05, colorPaleGreen);
}


_SECTION_END();

Pivot = ParamToggle("Pivot", "weekly|monthly", 1);

if(Pivot)
{
H1 = TimeFrameGetPrice("H", inMonthly, -1); // yesterdays high
L1 = TimeFrameGetPrice("L", inMonthly, -1); // low
C1= TimeFrameGetPrice("C", inMonthly, -1); // close


}
else
{
H1 = TimeFrameGetPrice("H", inWeekly, -1); // yesterdays high
L1 = TimeFrameGetPrice("L", inWeekly, -1); // low
C1= TimeFrameGetPrice("C", inWeekly, -1); // close
}



_SECTION_BEGIN("Stupid Functions");

function HAI_F1(no)
{
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);
return (IIf(avn==1,sup,res));
}

function HAI_F2(no)
{
return (Cross(C,HAI_F1(no)));
}

function HAI_F3(no)
{
return (Cross(HAI_F1(no),C));
}

function HAI_F4(no)
{
prev=AMA2(C,1,0);
d=IIf(C>Ref(Max(Max(H,Ref(H,-20)),Max(Ref(H,-10),Ref(H,-15))),-1),Min(Min(L,Ref(L,-20)),Min(Ref(L,-10),Ref(L,-15))),
IIf(C<Ref(Min(Min(L,Ref(L,-20)),Min(Ref(L,-10),Ref(L,-15))),-1),Max(Max(H,Ref(H,-20)),Max(Ref(H,-10),Ref(H,-15))),PREV));
a=Cross(Close,d);
b=Cross(d,Close);
return (IIf(BarsSince(a)<BarsSince(b),1,0));
}

function HAI_F5(no)
{
state = HAI_F4(no);
s=state>Ref(state,-1);
ss=state<Ref(state,-1);
return (state==Ref(state,-1));
}


function HAI_F6(p,n,s,m)
{
return (PDI(p)>MDI(n)AND Signal(s)<MACD(m));
}

function HAI_F7(p,n,s,m)
{
return (MDI(n)>PDI(p)AND Signal(s)>MACD(m));
}


_SECTION_END();

///////////////rahul

prev=AMA2(C,1,0);
d=IIf(C>Ref(Max(Max(H,Ref(H,-20)),Max(Ref(H,-10),Ref(H,-15))),-1),Min(Min(L,Ref(L,-20)),Min(Ref(L,-10),Ref(L,-15))),
IIf(C<Ref(Min(Min(L,Ref(L,-20)),Min(Ref(L,-10),Ref(L,-15))),-1),Max(Max(H,Ref(H,-20)),Max(Ref(H,-10),Ref(H,-15))),PREV));
a=Cross(Close,d);
b=Cross(d,Close);
state=IIf(BarsSince(a)<BarsSince(b),1,0);
s=state>Ref(state,-1);
ss=state<Ref(state,-1);
sss=state==Ref(state,-1);
col=IIf(state == 1 ,51,IIf(state ==0,4,1));
Plot(C,"",Col,64);
Buy = s;
Sell = ss;
 
 
 
_SECTION_BEGIN("swing");
no=22;
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);
supres=IIf(avn==1,sup,res);
a=Cross(C,supres);
b=Cross(supres,C);
style = a * styleStaircase + b * styleStaircase;
PlotShapes(a,style, IIf(a,colorGreen,colorRed), 0, IIf(a,Low,High));
 Plot(SUPRES,"Stop Loss",colorCustom8,styleDots);


 
 
_SECTION_BEGIN("");
Buy = a;
Sell = b;



Buy = MACD()>0; 
Sell = MACD()<0;
Buy =ExRem(Buy,Sell); Sell =ExRem(Sell,Buy);
shape = Buy * shapeUpTriangle + Sell * shapeDownTriangle;
PlotShapes( shape, IIf( Buy, colorAqua, colorCustom12 ), 0, IIf( Buy, Low, High ) );


 

 
WriteIf(s,"EXIT all Short positions\nif trading long positions, enter long Now-\nOR at the market price on tomorrow's Open with stop="+EncodeColor(4)+WriteVal(L+.75*ATR(5),1.4)+" ,","");
WriteIf(ss,"exit all long positions today with a Market On Close (MOC) order\nOR at the market price on tomorrow's Open with stop="+EncodeColor(4)+WriteVal(Ref(H+.75*ATR(5), -1),1.4)+",","");
WriteIf( sss ,"No trading signals today.","") ;
dist = ATR(21);
for (i=0; i<BarCount; i++) { 
  if ( Buy[i] )
    PlotText("Buy:" + O[ i ], i, L[ i ]-3*dist[i], colorGreen);
  if ( Sell[i] )
    PlotText("Sell:" + O[ i ], i, H[ i ]+3*dist[i], colorRed); 
 
 
 
  
  
}
 
 
Filter = s OR sss OR sss ;
AddColumn(C,"close",1.2);
AddColumn( IIf( s, 66,1 ), "buy", formatChar, 1, bkcolor =IIf (s,colorYellow, colorPink ));
AddColumn( IIf( Ss, 83,1 ), "sell", formatChar, 1, bkcolor =IIf (Ss,colorPink, colorWhite ));
AddColumn( IIf( sss, 87,1 ), "wait", formatChar, 1, bkcolor =IIf (sss,colorYellow, colorRed ));
 
 

 
_SECTION_BEGIN("trend");
uptrend=PDI(20)>MDI(10)AND Signal(29)<MACD(13);
downtrend=MDI(10)>PDI(20)AND Signal(29)>MACD(13);
//Plot( 2, /* defines the height of the ribbon in percent of pane width */"ribbon",
//IIf( uptrend, colorGreen, IIf( downtrend, colorRed, 0 )), /* choose color */
 
//styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
_SECTION_END();
 
Buy = s AND a AND uptrend ;
Short = ss AND b AND downtrend ;
Sell = ss AND b AND downtrend ;
Cover = s AND a AND uptrend ;
 
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Cover=ExRem(Cover,Short);
Short=ExRem(Short,Cover);
 
Filter=Buy OR Sell;
Filter= Cover OR Short;
 
AddColumn( Buy, "buy", 1);
AddColumn(Sell, "Sell", 1);
AddColumn(Close,"Close",1.2);
AddColumn(Volume,"Volume",1.0);
 
 
// Plot the Buy and Sell arrows.
shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-10);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-20);                      
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-15); 
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=20);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=30);                      
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-25);
 
 
 
 
 
 
// set background gradient colours
SetChartBkGradientFill( ParamColor("BgTop", ColorRGB( 0,0,0 )),ParamColor("BgBottom", ColorRGB( 102,136,187 )),ParamColor("titleblock",ColorRGB( 255,255,255 ))); 
 
GraphXSpace = 5; 
 
 
 
 
 
/* -------------------------------------------------------------------------------------- */
 
////////////////////////////////////////////////////////////////////////////////////////////////
intraday = ParamToggle("Message Board","Show|Hide",1);
showsl = ParamToggle("Stop Loss Line", "Show|Hide", 0);
  
 
 
style = a * styleStaircase + b * styleStaircase;
 
PlotShapes(a,style, IIf(a,colorGreen,colorRed), 0, IIf(a,Low,High));
if (showsl == 0) 
Plot(supres,"Stop Loss",colorCustom14,styleDots);
exitlong = Cross(supres, H);
PlotShapes(exitlong * shapeNone, colorBlack,0,H,-10);
exitshort = Cross(L, supres);
PlotShapes(exitshort * shapeNone, colorBlack,0,L,-15);
 
Buy = exitshort;
Sell = exitlong;
//Short = Sell;
//Cover = Buy;
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
//Short = ExRem(Short, Cover);
//Cover = ExRem(Cover, Short);
AlertIf( Buy, "", "BUY @ " + C, 1 );
AlertIf( Sell, "", "SELL @ " + C, 2 );
 
for (i=BarCount-1; i>1; i--) {
  if (Buy[i] == 1) {
    entry  = O[i];
    sig = " INTRADAY BUY ";
    sl = supres[1];
    tar1 = entry + (entry * .0040);
    tar2 = entry + (entry * .0080);
    tar3 = entry + (entry * .0120);
    tar4 = entry + (entry * .0160);
    tar5 = entry + (entry * .0200);
    tar6 = entry + (entry * .0240);
    tar7= entry + (entry * .0280);
    tar8 = entry + (entry * .0320);
 tar9 = entry + (entry * .0360);
tar10 = entry + (entry * .0400);
    tar11 = entry + (entry * .0440);
    tar12 = entry + (entry * .0480);
    tar13= entry + (entry * .0520);
    tar14= entry + (entry * .0560);
    tar15= entry + (entry * .0600);
 
    tar16= entry + (entry * .0640);
 
 
 
 
    bars = i;
    i = 0;
  }
  if (Sell[i] == 1) {
    sig = " INTRADAY SELL";
    entry = O[i];
    sl = supres[i];
    tar1 = entry - (entry * .0040);
    tar2 = entry - (entry * .0080);
    tar3 = entry - (entry * .0120);
    tar4 = entry - (entry * .0160);
    tar5 = entry - (entry * .0200);
    tar6 = entry - (entry * .0240);
    tar7= entry - (entry * .0280);
    tar8= entry - (entry * .0320);
    tar9= entry - (entry * .0360);
    tar10 = entry - (entry * .0400);
    tar11 = entry - (entry * .0440);
    tar12 = entry - (entry * .0480);
    tar13= entry - (entry * .0520);
    tar14= entry - (entry * .0560);
    tar15= entry - (entry * .0600);
 
    tar16= entry - (entry * .0640);
 
 
 
 
 
 
 
 
 
    
    bars = i;
    i = 0;
  }
}
 
Offset = 20;
Clr = IIf(sig == "BUY", colorLime, colorRed);
ssl = IIf(bars == BarCount-1, supres[BarCount-1], Ref(supres, -1));
sl = ssl[BarCount-1];
 
printf("Last " + sig + " Signal came " + (BarCount-bars) + " bars ago");
printf("\n" + sig + " @ : " + entry + "\nStop Loss : " + sl + " (" + WriteVal(IIf(sig == "SELL",entry-sl,sl-entry), 2.2) + ")"+ "\nTarget_1 : " + tar1 + "\nTarget_2 : " + tar2 + "\nTarget_3 : " + tar3);
printf("\nCurrent P/L : " + WriteVal(IIf(sig == "BUY",(C-entry),(entry-C)),2.2));
 
if (intraday == 0) {
  GfxSelectFont( "Tahoma", 13, 500 );
  GfxSetBkMode( 1 );
  GfxSetTextColor( colorWhite );
 
  if (sig =="BUY")
    GfxSelectSolidBrush( colorGreen ); // this is the box background color
  else
    GfxSelectSolidBrush( colorOrange ); // this is the box background color
 
  pxHeight = Status( "pxchartheight" ) ;
  xx = Status( "pxchartwidth");
  Left = 800;
  width =310;
  x = 10;
  x2 = 160;
 
  y = Status( "pxchartheight" );
 
  GfxSelectPen( colorDarkRed, 1); // broader color
  GfxRoundRect( x, y - 600, x2, y , 5, 5 ) ;
  
   
  GfxTextOut( ("" + WriteIf(sig =="Buy",sig + " @ ",sig + " @") + " : " + entry) ,13, y-460);
  GfxTextOut( ("Trailing SL : " + sl + " "), 13, y-440);
  GfxTextOut( ("TGT:1 : " + tar1), 13, y -420);
  GfxTextOut( ("TGT:2 : " + tar2), 13,y-400);
GfxTextOut( ("TGT:3 : " + tar3), 13,y-380);
GfxTextOut( ("TGT:4 : " + tar4), 13,y-340);

 
}
 
 
 
 
 
 
 
/* -------------------------------------------------------------------------------------- */
 
////////////////////////////////////////////////////////////////////////////////////////////////
 
 
 
m=IIf(ParamList("select type","Message Board|Message Board1")=="Message Board",-1,0);
 
 
messageboard = ParamToggle("Message Board1","Show|Hide",1);
showsl = ParamToggle("Stop Loss Line", "Show|Hide", 0);
m1 = ParamToggle("Message Board1","Show|Hide",1); 
 
style = a * styleStaircase + b * styleStaircase;
 
PlotShapes(a,style, IIf(a,colorGreen,colorRed), 0, IIf(a,Low,High));
if (showsl == 0) Plot(supres,"Stop Loss",colorCustom14,styleDots);
exitlong = Cross(supres, H);
PlotShapes(exitlong * shapeNone, colorBlack,0,H,-10);
exitshort = Cross(L, supres);
PlotShapes(exitshort * shapeNone, colorBlack,0,L,-15);
 
Buy = exitshort;
Sell = exitlong;
//Short = Sell;
//Cover = Buy;
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
//Short = ExRem(Short, Cover);
//Cover = ExRem(Cover, Short);
AlertIf( Buy, "", "BUY @ " + C, 1 );
AlertIf( Sell, "", "SELL @ " + C, 2 );
 
for (i=BarCount-1; i>1; i--) {
  if (Buy[i] == 1) {
    entry = O[i];
    sig = "BUY";
    sl = supres[1];
    tar1 = entry + (entry * .0090);
    tar2 = entry + (entry * .0150);
    tar3 = entry + (entry * .0250);
    tar4 = entry + (entry * .0350);
    tar5 = entry + (entry * .0450);
    tar6 = entry + (entry * .0550);
tar7 = entry + (entry * .0650);
    tar8 = entry + (entry * .0750);
 tar9 = entry + (entry * .1000);
 
    bars = i;
    i = 0;
  }
  if (Sell[i] == 1) {
    sig = "SELL";
    entry = O[i];
    sl = supres[i];
    tar1 = entry - (entry * .0090);
    tar2 = entry - (entry * .0150);
    tar3 = entry - (entry * .0250);
 
 tar4 = entry - (entry * .0325);
    tar5 = entry - (entry * .0500);
    tar6 = entry - (entry * .0750);
tar7 = entry - (entry * .0850);
    tar8 = entry - (entry * .0950);
    tar9 = entry - (entry * .1000);
 
 
 
    bars = i;
    i = 0;
  }
}
 
Offset = 20;
Clr = IIf(sig == "BUY", colorLime, colorRed);
ssl = IIf(bars == BarCount-1, supres[BarCount-1], Ref(supres, -1));
sl = ssl[BarCount-1];
 
printf("Last " + sig + " Signal came " + (BarCount-bars) + " bars ago");
printf("\n" + sig + " @ : " + entry + "\nStop Loss : " + sl + " (" + WriteVal(IIf(sig == "SELL",entry-sl,sl-entry), 2.2) + ")"+ "\nTarget_1 : " + tar1 + "\nTarget_2 : " + tar2 + "\nTarget_3 : " + tar3);
printf("\nCurrent P/L : " + WriteVal(IIf(sig == "BUY",(C-entry),(entry-C)),2.2));
 
if (messageboard == 0) {
  GfxSelectFont( "Tahoma", 13, 100 );
  GfxSetBkMode( 1 );
  GfxSetTextColor( colorWhite );
 
  if (sig =="BUY")
    GfxSelectSolidBrush( colorDarkRed ); // this is the box background color
  else
    GfxSelectSolidBrush( colorRed ); // this is the box background color
 
  pxHeight = Status( "pxchartheight" ) ;
  xx = Status( "pxchartwidth");
  CENTER = 20;
  width =31;
  x = 2;
  x20 = 180;
 
  y = Status( "pxchartheight" );
 
  GfxSelectPen( colorDarkRed, 1); // broader color
  GfxRoundRect( x, y - 400, x20, y , 7, 7 ) ;
   
  GfxTextOut( Name(),13,y-398);
 
  GfxTextOut( ("" + WriteIf(sig =="BUY",sig + " @ ",sig + " @") + " : " + entry), 13, y-380);
  GfxTextOut( ("Trailing SL : " + sl + " "), 13, y-360);
 
  GfxTextOut( ("TGT:1 : " + tar1), 13, y -340);
  GfxTextOut( ("TGT:2 : " + tar2), 13,y-320);
 
GfxTextOut( ("TGT:3 : " + tar3), 13, y -300);
  GfxTextOut( ("TGT:4 : " + tar4), 13,y-280);
 
  GfxTextOut( ("Current P/L : " + WriteVal(IIf(sig == "BUY",(C-entry),(entry-C)),2.2)), 13, y-0);;
}
/* -------------------------------------------------------------------------------------- */
 
////////////////////////////////////////////////////////////////////////////////////////////////
 
 
 
m=IIf(ParamList("select type","Message Board|Message Board1|Message Board2")=="Message Board",-1,0);
 
 
messageboard = ParamToggle("Message Board2","Show|Hide",1);
showsl = ParamToggle("Stop Loss Line", "Show|Hide", 0);
m2 = ParamToggle("Message Board2","Show|Hide",0);
 
style = a * styleStaircase + b * styleStaircase;
 
PlotShapes(a,style, IIf(a,colorGreen,colorRed), 0, IIf(a,Low,High));
if (showsl == 0) Plot(supres,"Stop Loss",colorCustom14,styleDots);
exitlong = Cross(supres, H);
PlotShapes(exitlong * shapeNone, colorBlack,0,H,-10);
exitshort = Cross(L, supres);
PlotShapes(exitshort * shapeNone, colorBlack,0,L,-15);
 
Buy = exitshort;
Sell = exitlong;
//Short = Sell;
//Cover = Buy;
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
//Short = ExRem(Short, Cover);
//Cover = ExRem(Cover, Short);
AlertIf( Buy, "", "BUY @ " + C, 1 );
AlertIf( Sell, "", "SELL @ " + C, 2 );
 
for (i=BarCount-1; i>1; i--) {
  if (Buy[i] == 1) {
    entry = O[i];
    sig = "BUY LONG TERM";
    sl = supres[1];
    tar1 = entry + (entry * .0125);
    tar2 = entry + (entry * .0250);
    tar3 = entry + (entry * .0375);
    tar4 = entry + (entry * .0500);
    tar5 = entry + (entry * .0625);
    tar6 = entry + (entry * .0800);
tar7 = entry + (entry * .0925);
    tar8 = entry + (entry * .1050);
 tar9 = entry + (entry * .1175);
 
    bars = i;
    i = 0;
  }
  if (Sell[i] == 1) {
    sig = "SELL LONG TERM";
    entry = O[i];
    sl = supres[i];
     
    tar1 = entry - (entry * .0125);
    tar2 = entry - (entry * .0250);
    tar3 = entry -(entry * .0375);
    tar4 = entry - (entry * .0500);
    tar5 = entry - (entry * .0625);
    tar6 = entry - (entry * .0800);
tar7 = entry - (entry * .0925);
    tar8 = entry - (entry * .1050);
 tar9 = entry - (entry * .1175);
 
 
 
    bars = i;
    i = 0;
  }
}
 
Offset = 20;
Clr = IIf(sig == "BUY", colorLime, colorRed);
ssl = IIf(bars == BarCount-1, supres[BarCount-1], Ref(supres, -1));
sl = ssl[BarCount-1];
 
printf("Last " + sig + " Signal came " + (BarCount-bars) + " bars ago");
printf("\n" + sig + " @ : " + entry + "\nStop Loss : " + sl + " (" + WriteVal(IIf(sig == "SELL",entry-sl,sl-entry), 2.2) + ")"+ "\nTarget_1 : " + tar1 + "\nTarget_2 : " + tar2 + "\nTarget_3 : " + tar3);
printf("\nCurrent P/L : " + WriteVal(IIf(sig == "BUY",(C-entry),(entry-C)),2.2));
 
if (messageboard == 0) {
  GfxSelectFont( "Tahoma", 13, 100 );
  GfxSetBkMode( 1 );
  GfxSetTextColor( colorWhite );
 
 if (sig =="BUY ")
  GfxSelectSolidBrush( colorBlue ); // this is the box background color
else
    GfxSelectSolidBrush( colorBlack ); // this is the box background color
 
  pxHeight = Status( "pxchartheight" ) ;
  xx = Status( "pxchartwidth");
  CENTER = 20;
  width =31;
  x = 2;
  x20 = 180;
 
  y = Status( "pxchartheight" );
 
  GfxSelectPen( colorDarkRed, 1); // broader color
  GfxRoundRect( x, y - 300, x20, y , 7, 7 ) ;
   
  GfxTextOut( Name(),13,y-298);
 
  GfxTextOut( ("" + WriteIf(sig =="BUY",sig + " @ ",sig + " @") + " : " + entry), 13, y-280);
  GfxTextOut( ("Trailing SL : " + sl + " "), 13, y-260);
 
  GfxTextOut( ("TGT:1 : " + tar1), 13, y -240);
  GfxTextOut( ("TGT:2 : " + tar2), 13,y-220);
 
GfxTextOut( ("TGT:3 : " + tar3), 13, y -200);
  GfxTextOut( ("TGT:4 : " + tar4), 13,y-180);
 

}
 
 
//rahul






_SECTION_BEGIN("Swing2");

no = 22;
sloss = HAI_F1(no);
a = HAI_F2(no);
b = HAI_F3(no);
state = HAI_F4(no);
sss = HAI_F5(no);
uptrend = HAI_F6(20,10,29,22);
downtrend = HAI_F7(20,10,29,13);

style = a * styleStaircase + b * styleStaircase;
PlotShapes(a,style, IIf(a,colorGreen,colorRed), 0, IIf(a,Low,High));
_SECTION_END();

col=IIf(state == 1 ,51,IIf(state ==0,4,1));
Plot(C,"",Col,64);
PlotShapes( shapeUpArrow * a, colorGreen,0,L);
PlotShapes( shapeDownArrow * b, colorRed,0,H);

Filter = a OR b OR sss ;
AddColumn(C,"close",1.2);
AddColumn( IIf( a, 66,1 ), "buy", formatChar, 1, bkcolor =IIf (a,colorYellow, colorPink ));
AddColumn( IIf( b, 83,1 ), "sell", formatChar, 1, bkcolor =IIf (b,colorPink, colorYellow ));
AddColumn( IIf( sss, 87,1 ), "wait", formatChar, 1, bkcolor =IIf (sss,colorYellow, colorRed ));



_SECTION_BEGIN("Intraday AFL System");
Buy = a;
Sell = b;
/*
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-30);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-35);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=30);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=40);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-35);

dist = ATR(20);
for (i=0; i<BarCount; i++) {
if ( Buy[i] )
PlotText("Buy:" + O[ i ], i, L[ i ]-3*dist[i], colorGreen);
if ( Sell[i] )
PlotText("Sell:" + O[ i ], i, H[ i ]+3*dist[i], colorRed);
}
_SECTION_END();*/


//d = Close > Ref( ChandelierHL(ATR(3),20), -1);
//e =Close < Ref( ChandelierHL(ATR(3),20), -1);
//f = Close < Ref( ChandelierHL(ATR(3),20), -1);
//g = Close > Ref( ChandelierHL(ATR(3),20), -1);

Buy = a AND uptrend ;
Short = b AND downtrend ;
Sell = b AND downtrend ;
Cover = a AND uptrend;

Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Cover=ExRem(Cover,Short);
Short=ExRem(Short,Cover);

Filter=Buy OR Sell;
Filter= Cover OR Short;

AddColumn( Buy, "Buy", 1);
AddColumn(Sell, "Sell", 1);
AddColumn(Close,"Close",1.2);
AddColumn(Volume,"Volume",1.0);

// Plot the Buy and Sell arrows.
shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes(shape, IIf(Buy,colorGreen,colorRed), 0, IIf(Buy,Low,High));
//attack
Plot(sloss,"Swing",colorCustom8,styleDots);

 


//SetChartBkGradientFill( ParamColor("BgTop", ColorRGB( 172,172,172 )),

//ParamColor("BgBottom", ColorRGB( 172,172,172 )),ParamColor("titleblock",ColorRGB( 172,172,172 )));
//Alerts
AlertIf( Buy, "SOUND C:\\Windows\\Media\\tada.wav", "Buy",1,1+2+4+8);
AlertIf( Short, "SOUND C:\\Windows\\Media\\notify.wav", "Short",2,1+2+4+8);

GraphXSpace = 5;

/* -------------------------------------------------------------------------------------- */

//SetChartBkColor(colorDarkOliveGreen = 46);
SetChartOptions(0,chartShowArrows|chartShowDates);

/* -------------------------------------------------------------------------------------- */
//do not touch
////////////////////////////////////////////////////////////////////////////////////////////////
messageboard = ParamToggle("Message Board","Show|Hide",0);
showsl = ParamToggle("Stop Loss Line", "Show|Hide", 0);

style = a * styleStaircase + b * styleStaircase;

PlotShapes(a,style, IIf(a,colorGreen,colorRed), 0, IIf(a,Low,High));
if (showsl == 0) Plot(sloss,"Stop Loss",colorCustom8,styleDots);
exitlong = Cross(sloss, H);
PlotShapes(exitlong * shapeNone, colorBlack,0,H,-10);
exitshort = Cross(L, sloss);
PlotShapes(exitshort * shapeNone, colorBlack,0,L,-15);

Buy = exitshort;
Sell = exitlong;
//Short = Sell;
//Cover = Buy;
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
//Short = ExRem(Short, Cover);
//Cover = ExRem(Cover, Short);
AlertIf( Buy, "", "BUY @ " + C, 1 );
AlertIf( Sell, "", "SELL @ " + C, 2 );

for (i=BarCount-1; i>1; i--) {
if (Buy[i] == 1) {
entry = O[i];
sig = "BUY";
sl = sloss[i];
tar1 = entry + (entry * .0040);
tar2 = entry + (entry * .0085);
tar3 = entry + (entry * .0179);
bars = i;
i = 0;
}
if (Sell[i] == 1) {
sig = "SELL";
entry = O[i];
sl = sloss[i];
tar1 = entry - (entry * .0040);
tar2 = entry - (entry * .0085);
tar3 = entry - (entry * .0212);
bars = i;
i = 0;
}
}

Offset = 20;
Clr = IIf(sig == "BUY", colorLime, colorRed);
ssl = IIf(bars == BarCount-1, sloss[BarCount-1], Ref(sloss, -1));
sl = ssl[BarCount-1];

printf("Last " + sig + " Signal came " + (BarCount-bars) + " bars ago");
printf("\n" + sig + " @ : " + entry + "\nStop Loss : " + sl + " (" + WriteVal(IIf(sig == "SELL",entry-sl,sl-entry), 2.2) + ")"+ "\nTarget_1 : " + tar1 + "\nTarget_2 : " + tar2 + "\nTarget_3 : " + tar3);
printf("\nCurrent P/L : " + WriteVal(IIf(sig == "BUY",(C-entry),(entry-C)),2.2));

if (messageboard == 0) {
GfxSelectFont( "Tahoma", 13, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );

if (sig =="BUY")
GfxSelectSolidBrush( colorGreen ); // this is the box background color
else
GfxSelectSolidBrush( colorRed ); // this is the box background color

pxHeight = Status( "pxchartheight" ) ;
xx = Status( "pxchartwidth");
Left = 1100;
width = 310;
x = 05;
x2 = 200;

y = Status( "pxchartheight" );

GfxSelectPen( colorGreen, 1); // broader color
GfxRoundRect( x, y - 143, x2, y , 7, 7 ) ;
GfxTextOut( ( " AFLIntraday "), 10, y-140) ;
GfxTextOut( Name(),13,y-120);

GfxTextOut( ("" + WriteIf(sig =="BUY",sig + " @ ",sig + " @") + " : " + entry), 13, y-100);
GfxTextOut( ("Trailing SL : " + sl + " "), 13, y-80);
GfxTextOut( ("TGT:1 : " + tar1), 13, y -60);
GfxTextOut( ("TGT:2 : " + tar2), 13,y-40);
GfxTextOut( ("Current P/L : " + WriteVal(IIf(sig == "BUY",(C-entry),(entry-C)),2.2)), 13, y-20);;
}





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

// Supertrend - Translated from Kolier MQ4
// see: http://kolier.li/indicator/kolier-supertrend-indi
// translation in Amibroker AFL code by E.M.Pottasch, 2011

procedure calcTrend_proc(ATR_Period,tr,ATR_Multiplier,TrendMode,CalcPrice)
{
global buffer_line_down;
global buffer_line_up;
buffer_line_down = Null;
buffer_line_up = Null;
 
PHASE_NONE = 0;
PHASE_BUY = 1;
PHASE_SELL = -1;
 
phase=PHASE_NONE;
band_upper = 0;band_lower = 0;
   
for(i = ATR_Period + 1; i < BarCount; i++)
{
    band_upper = CalcPrice[i] + ATR_Multiplier * tr[i];
    band_lower = CalcPrice[i] - ATR_Multiplier * tr[i];
     
    if(phase==PHASE_NONE)
    {
        buffer_line_up[i] = CalcPrice[i];
        buffer_line_down[i] = CalcPrice[i];
    }
    if(phase!=PHASE_BUY && Close[i]>buffer_line_down[i-1] && !IsEmpty(buffer_line_down[i-1])) 
    {
        phase = PHASE_BUY;
        buffer_line_up[i] = band_lower;
        buffer_line_up[i-1] = buffer_line_down[i-1];
    }
    if(phase!=PHASE_SELL && Close[i]<buffer_line_up[i-1] && !IsEmpty(buffer_line_up[i-1]))
    {
        phase = PHASE_SELL;
        buffer_line_down[i] = band_upper;
        buffer_line_down[i-1] = buffer_line_up[i-1];
    }   
    if(phase==PHASE_BUY && ((TrendMode==0 && !IsEmpty(buffer_line_up[i-2])) || TrendMode==1) )
    {
        if(band_lower>buffer_line_up[i-1]) 
        {
            buffer_line_up[i] = band_lower;
        }
        else
        {
            buffer_line_up[i] = buffer_line_up[i-1];
        }
    }
    if(phase==PHASE_SELL && ((TrendMode==0 && !IsEmpty(buffer_line_down[i-2])) || TrendMode==1) )
    {
        if(band_upper<buffer_line_down[i-1])
        {
            buffer_line_down[i] = band_upper;
        }
        else
        {
            buffer_line_down[i] = buffer_line_down[i-1];
        }
    }
}
}
 
SetBarsRequired(sbrAll,sbrAll);

TrendMode = ParamToggle("TrendMode","Off|On",1);
ATR_Multiplier = Param("ATR_Multiplier",2,0.1,10,0.1);
ATR_Period = Param( "ATR_Period",5,1,20,1);
tr = ATR(ATR_Period);
 
CalcPrice = (H+L)/2;
calcTrend_proc(ATR_Period,tr,ATR_Multiplier,TrendMode,CalcPrice);
 
SetChartOptions(0,chartShowDates);
//Plot(C,"C",colorWhite,64);

Plot(buffer_line_up,"\ntu",ColorRGB(28,134,238),styleThick);
Plot(buffer_line_down,"\ntd",ColorRGB(205,51,51),styleThick);

 
Plot( 4,"",IIf(buffer_line_up,colorBrightGreen,colorBlack),styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
Plot( 6,"",IIf(buffer_line_down,colorRed,colorBlack),styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
_SECTION_BEGIN("Advanced Elliot Wave ");
//Elliot Wave Metastock to AFL
//-- Script Start -------
//_N(Title = "{{NAME}} - {{INTERVAL}} {{DATE}}: "+_DEFAULT_NAME()+" : {{VALUES}} "
//);
 
Option = ParamToggle("Insert To", "Price Chart|Indicator");
pr=Param("Elliot Wave minimum % move",0.5, 0.25,5,0.25);
//{ Beginner Elliot Wave stuff }
EWpk=PeakBars(H,pr)==0;
EWtr=TroughBars(L,pr)==0;
//{ Intermediate Elliot Wave stuff }
zz=Zig(C,pr);
zzHi=Zig(H,pr);
zzLo=Zig(L,pr);
Avg=(zzHi+zzLo)/2;
//{ Advanced Elliot Wave stuff }
RetroSuccessSecret=IIf(EWpk,zzHi,
IIf(EWtr,zzLo,IIf(Avg>Ref(Avg,-1),H,L)));
EW=Zig(RetroSuccessSecret,pr);
//{ Plot on price chart }
if (Option==0){ //  will on  elliot lines
//Plot(EW, "EW", ParamColor("Color", colorBrown), ParamStyle("Style", styleNoLabel|styleThick));
}
else
{
//{ Plot on own window }
Plot(EWbuy-EWsell, "EW2", ParamColor("Color", colorRed), ParamStyle("Style", styleNoLabel|styleThick));
}
//{ Buy/Sell Elliot Wave stuff }
EWbuy=TroughBars(EW,pr)==1;
EWsell=PeakBars(EW,pr)==1;
Plot(C,"",47,128+4);
PlotShapes(EWbuy*shapeUpArrow,5,0,L,-5);
PlotShapes(EWsell*shapeDownArrow,4,0,H,-5);
//-- Script End -------
_SECTION_END();
Option = ParamToggle("Insert To", "Price Chart|Indicator");
pr=Param("Elliot Wave minimum % move",0.5, 0.25,5,0.25);
//{ Beginner Elliot Wave stuff }
EWpk=PeakBars(H,pr)==0;
EWtr=TroughBars(L,pr)==0;
//{ Intermediate Elliot Wave stuff }
zz=Zig(C,pr);
zzHi=Zig(H,pr);
zzLo=Zig(L,pr);
Avg=(zzHi+zzLo)/2;



Pivot = ParamToggle("Pivot", "weekly|monthly", 1);

if(Pivot)
{
H1 = TimeFrameGetPrice("H", inMonthly, -1); // yesterdays high
L1 = TimeFrameGetPrice("L", inMonthly, -1); // low
C1= TimeFrameGetPrice("C", inMonthly, -1); // close


}
else
{
H1 = TimeFrameGetPrice("H", inWeekly, -1); // yesterdays high
L1 = TimeFrameGetPrice("L", inWeekly, -1); // low
C1= TimeFrameGetPrice("C", inWeekly, -1); // close
}

// PIVOT Calculation
P = ( H1+ L1+ C1 )/3;
R1 = P+(H1-L1)/2-(P-C1)/2;
R2 = H1-L1+P;
R3 = H1-L1+R1;
R4 = H1-L1+R2;
R5 = H1-L1+R3;
R6 = H1-L1+R4;
R7 = H1-L1+R5;
R8 = H1-L1+R6;
R9 = H1-L1+R7;
R10 = H1-L1+R8;



S1 = P -(H1-L1)/2-(P-C1)/2;
S2 = P -(H1-L1);
S3 = S1 -(H1-L1);
S4 = S2 -(H1-L1);
S5 = S3 -(H1-L1);
S6 = S4 -(H1-L1);
S7 = S5 -(H1-L1);
S8 = S6 -(H1-L1);
S9 = S7 -(H1-L1);
S10 =S8 -(H1-L1);













// PIVOT mid points
MIDR1 = (P+R1)/2;
MIDR2 = (R1+R2)/2;
MIDR3 = (R2+R3)/2;
MIDR4 = (R3+R4)/2;
MIDR5 = (R4+R5)/2;
MIDR6 = (R5+R6)/2;
MIDR7 = (R6+R7)/2;
MIDR8 = (R7+R8)/2;
MIDR9 = (R8+R9)/2;
MIDR10 = (R9+R10)/2;




MIDS1 = (P+S1)/2;
MIDS2 = (S1+S2)/2;
MIDS3 = (S2+S3)/2;
MIDS4 = (S3+S4)/2;
MIDS5 = (S4+S5)/2;
MIDS6 = (S5+S6)/2;
MIDS7 = (S6+S7)/2;
MIDS8 = (S7+S8)/2;
MIDS9 = (S8+S9)/2;
MIDS10 = (S9+S10)/2;













n=130;
per =11.5;
x = Cum(1);
s1=IIf(RSIa(L,n)>Min(RSIa(C,n),RSIa(O,n)),Min(RSIa (C,n),RSIa(O,n)),RSIa(L,n));
s11=IIf(RSIa(H,n)<Max(RSIa(C,n),RSIa(O,n)),Max(RSIa(C,n),RSIa(O,n)),RSIa(H,n));
pS = TroughBars( s1, per, 1 ) == 0;
endt= LastValue(ValueWhen( pS, x, 1 ));
startt=LastValue(ValueWhen( pS, x, 2 ));
dtS =endt-startt;
endS = LastValue(ValueWhen( pS, s1, 1 ) );
startS = LastValue( ValueWhen( pS, s1, 2 ));
aS = (endS-startS)/dtS;bS = endS;
trendlineS = aS * ( x -endt ) + bS;
pR = PeakBars( s11, per, 1 ) == 0;
endt1= LastValue(ValueWhen( pR, x, 1 ));
startt1=LastValue(ValueWhen( pR, x, 2 ));
dtR =endt1-startt1;
endR = LastValue(ValueWhen( pR, s11, 1 ) );
startR = LastValue( ValueWhen( pR, s11, 2 ));
aR = (endR-startR)/dtR;
bR = endR;
trendlineR = aR * ( x -endt1 ) + bR;
//Plot(ValueWhen( (S1==trendlineS ), L),"", colorGreen, styleDashed|styleNoRescale|styleThick);
//Plot(ValueWhen((S11==trendlineR ), H),"", colorRed, styleDashed|styleNoRescale|styleThick);
Buy = Ref(Ref(Ref(Ref(Ref(Ref(Ref(Ref(Ref(Ref(Ref(S1==trendlineS,-1),-1),-1),-1),-1),-1),-1),-1),-1),-1),-1);
Sell = Ref(Ref(Ref(Ref(Ref(Ref(Ref(Ref(Ref(Ref(Ref(Ref(Ref(Ref(Ref(Ref(Ref(S11==trendlineR,-1 ),-1),-1),-1),-1),-1),-1),-1),-1),-1),-1),-1),-1 ),-1 ),-1 ),-1 ),-1 );
Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );
AlertIf( Buy, "", "BUY @ " + C, 1 );
AlertIf( Sell, "", "SELL @ " + C, 2 );
//PlotShapes( Buy * shapeUpArrow + Sell * shapeDownArrow, IIf( Buy, colorGold, colorPink) );
dist = 2.5*ATR(10);
dist1 = 0.7*ATR(10);
for( i = 0; i < BarCount; i++ ) 
{ 
 if( Buy[i] ) 
 {
  PlotText( "\n     Heavy Fire Up Ahead     "  , i, L[ i ]-dist[i], colorBlack, colorGreen );
  //Say("Heavy Fire Up Ahead");
 }
 if( Sell[i] )
 {
  PlotText( "     Heavy Down Fall Ahead     "  , i, H[ i ]+dist1[i], colorBlack, colorRed ); 
  //Say("Heavy Down Fall Ahead");
 }
}
n=45;
per =20;
x = Cum(1);
s1=IIf(RSIa(L,n)>Min(RSIa(C,n),RSIa(O,n)),Min(RSIa (C,n),RSIa(O,n)),RSIa(L,n));
s11=IIf(RSIa(H,n)<Max(RSIa(C,n),RSIa(O,n)),Max(RSIa(C,n),RSIa(O,n)),RSIa(H,n));
pS = TroughBars( s1, per, 1 ) == 0;
endt= LastValue(ValueWhen( pS, x, 1 ));
startt=LastValue(ValueWhen( pS, x, 2 ));
dtS =endt-startt;
endS = LastValue(ValueWhen( pS, s1, 1 ) );
startS = LastValue( ValueWhen( pS, s1, 2 ));
aS = (endS-startS)/dtS;bS = endS;
trendlineS = aS * ( x -endt ) + bS;
pR = PeakBars( s11, per, 1 ) == 0;
endt1= LastValue(ValueWhen( pR, x, 1 ));
startt1=LastValue(ValueWhen( pR, x, 2 ));
dtR =endt1-startt1;
endR = LastValue(ValueWhen( pR, s11, 1 ) );
startR = LastValue( ValueWhen( pR, s11, 2 ));
aR = (endR-startR)/dtR;
bR = endR;
trendlineR = aR * ( x -endt1 ) + bR;
//Plot(trendlineR , "trendlineR" ,colorRed , styleLine);
//Plot(ValueWhen( (S1==trendlineS ), L),"", colorGreen, styleDashed|styleNoRescale|styleThick);
//Plot(ValueWhen((S11==trendlineR ), H),"", colorRed, styleDashed|styleNoRescale|styleThick);
Buy = Ref(Ref(Ref(Ref(Ref(Ref(Ref(Ref(Ref(Ref(Ref(S1==trendlineS,-1),-1),-1),-1),-1),-1),-1),-1),-1),-1),-1);
Sell = Ref(Ref(Ref(Ref(Ref(Ref(Ref(Ref(Ref(Ref(Ref(Ref(Ref(Ref(Ref(Ref(Ref(S11==trendlineR,-1 ),-1),-1),-1),-1),-1),-1),-1),-1),-1),-1),-1),-1 ),-1 ),-1 ),-1 ),-1 );
Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );

 //Plot the ribbon
ribboncol= IIf( BarsSince(Buy)<BarsSince(Sell), colorGreen, colorRed );
//Plot( 3, "", ribboncol, styleArea | styleOwnScale | styleNoLabel, 0, 100 );
PlotShapes(IIf(Buy, shapeSquare,shapeNone) ,colorBlue,0, Close, Offset=-10) ; 
PlotShapes(IIf(Buy, shapeSmallUpTriangle,shapeNone) ,colorLime,0, Close, Offset=-10) ;
PlotShapes(IIf(Sell, shapeSquare,shapeNone),colorRed,0, Close, Offset=-1) ;
PlotShapes(IIf(Sell, shapeSmallDownTriangle,shapeNone),colorLime,0, Close, Offset=-1) ;
PlotShapes( Buy * shapeNone + Sell * shapeNone, IIf( Buy, colorBlue, colorPink) );
dist = 0.8*ATR(10);
dist1 = 2*ATR(10);
for( i = 0; i < BarCount; i++ ) 
{ 
 if( Buy[i] ) 
 {
// PlotText( "\nHNI Buy 10 Lots @" + C[ i ] + "\nTGT= " + (C[i]*1.0045) + "\nSL= " + (C[i]*0.9970), i, L[ i ]-dist[i], colorGreen, colorBlack );
 }
 if( Sell[i] )
 {
 //PlotText( "HNI Sell 10 Lots @" + C[ i ] + "\nT= " + (C[i]*0.995) + "\nSL= " + (C[i]*1.0025), i, H[ i ]+dist1[i], colorRed, colorBlack ); 
 }
}




_SECTION_END();

_SECTION_BEGIN("TREND");
SetBarsRequired(100000,0);
GraphXSpace = 15;

ea = EMA (C,10);
eb = EMA (C,20);
SetBarFillColor( IIf( ea > eb, colorGreen, colorRed ) ); 
Buy = ea > eb AND TimeNum() > 092000 AND TimeNum() < 150000;
Sell = eb > ea OR TimeNum() > 150000;
Short = 0;
Cover = 0;
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
Short = ExRem(Short,Cover);
Cover = ExRem(Cover,Short);


SetTradeDelays(1,1,1,1);
Factor=Param("Factor",6,1,10,1);
Pd=Param("ATR Periods",6,1,100,1);
Up=(H+L)/2+(Factor*ATR(Pd));
Dn=(H+L)/2-(Factor*ATR(Pd));
iATR=ATR(Pd);
TrendUp=TrendDown=Null;
trend[0]=1;
changeOfTrend=0;
flag=flagh=0;

for (i = 1; i <BarCount; i++) {
TrendUp[i] = Null;
TrendDown[i] = Null;

trend[i]=1;


if (Close[i]>Up[i-1]) {
trend[i]=1;
if (trend[i-1] == -1) changeOfTrend = 1;

}
else if (Close[i]<Dn[i-1]) {
trend[i]=-1;
if (trend[i-1] == 1) changeOfTrend = 1;
}
else if (trend[i-1]==1) {
trend[i]=1;
changeOfTrend = 0; 
}
else if (trend[i-1]==-1) {
trend[i]=-1;
changeOfTrend = 0;
}

if (trend[i]<0 && trend[i-1]>0) {
flag=1;
}
else {
flag=0;
}

if (trend[i]>0 && trend[i-1]<0) {
flagh=1;
}
else {
flagh=0;
}

if (trend[i]>0 && Dn[i]<Dn[i-1]){
Dn[i]=Dn[i-1];
}

if (trend[i]<0 && Up[i]>Up[i-1])
{ Up[i]=Up[i-1];
}

if (flag==1)
{ Up[i]=(H[i]+L[i])/2+(Factor*iATR[i]);;
} 
if (flagh==1)
{ Dn[i]=(H[i]+L[i])/2-(Factor*iATR[i]);;
}
if (trend[i]==1) {
TrendUp[i]=Dn[i];
if (changeOfTrend == 1) {
TrendUp[i-1] = TrendDown[i-1];
changeOfTrend = 0;
}
}
else if (trend[i]==-1) {
TrendDown[i]=Up[i];
if (changeOfTrend == 1) {
TrendDown[i-1] = TrendUp[i-1];
changeOfTrend = 0;
}
}
} 

Plot(TrendUp,"Trend",colorGreen);
Plot(TrendDown,"Down",colorRed);

Buy = trend==1;
Sell=trend==-1;

Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Short=Sell;
Cover=Buy;


BuyPrice=ValueWhen(Buy,C);
SellPrice=ValueWhen(Sell,C);
ShortPrice=ValueWhen(Short,C);
CoverPrice=ValueWhen(Cover,C);


Title = EncodeColor(colorWhite)+ "Simple Trading" + " - " + Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +
" - " + Date() +" - "+"\n" +EncodeColor(colorYellow) +"Op-"+O+" "+"Hi-"+H+" "+"Lo-"+L+" "+
"Cl-"+C+" "+ "Vol= "+ WriteVal(V)+"\n"+ 
EncodeColor(colorLime)+
WriteIf (Buy , " GO LONG / Reverse Signal at "+C+" ","")+
WriteIf (Sell , " EXIT LONG / Reverse Signal at "+C+" ","")+"\n"+EncodeColor(colorYellow)+
WriteIf(Sell , "Total Profit/Loss for the Last Trade Rs."+(C-BuyPrice)+"","")+
WriteIf(Buy , "Total Profit/Loss for the Last trade 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(Short, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50); 
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);

TrendSL=IIf(trend==1,TrendUp,TrendDown);

for(i=BarCount-1;i>1;i--)
{
if(Buy[i] == 1)
{
entry = C[i];
sig = "BUY";
sl = TrendSL[i];
tar1 = entry + (entry * .0050);
tar2 = entry + (entry * .0092);
tar3 = entry + (entry * .0179);

bars = i;
i = 0;
}
if(Sell[i] == 1)
{
sig = "SELL";
entry = C[i];
sl = TrendSL[i];
tar1 = entry - (entry * .0050);
tar2 = entry - (entry * .0112);
tar3 = entry - (entry * .0212);


bars = i;
i = 0;
}
}
Offset = 20;
Clr = IIf(sig == "BUY", colorLime, colorRed);
ssl = IIf(bars == BarCount-1, TrendSL[BarCount-1], Ref(TrendSL, -1));
sl = ssl[BarCount-1];


//Plot(LineArray(bars-Offset, tar1, BarCount, tar1,1), "", Clr, styleLine|styleDots|styleNoRescale, Null, Null, Offset);
//Plot(LineArray(bars-Offset, tar2, BarCount, tar2,1), "", Clr, styleLine|styleDots, Null, Null, Offset);
//Plot(LineArray(bars-Offset, tar3, BarCount, tar3,1), "", Clr, styleLine|styleDots, Null, Null, Offset);

//Plot(LineArray(bars-Offset, sl, BarCount, sl,1), "", colorDarkRed, styleLine|styleLine, Null, Null, Offset);
//Plot(LineArray(bars-Offset, entry, BarCount, entry,1), "", colorGreen, styleLine|styleLine, Null, Null, Offset);

for (i=bars; i <BarCount;i++)
{
PlotText(""+sig+"@"+entry, BarCount+1,entry,Null,colorBlue);
PlotText("T1@"+tar1,BarCount+3,tar1,Null,Clr);//PlotText("T2@"+tar2,BarCount+3,tar2,Null,Clr);//Plot Text ("T3@"+tar3,BarCount+3,tar3,Null,Clr);

}

messageboard = ParamToggle("Message Board","Show|Hide",0);
if (messageboard == 1 )
{
GfxSelectFont( "Book Antiqua bold", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );

if ( sig =="BUY")
{
GfxSelectSolidBrush( colorBlue ); // this is the box background color
}
else
{
GfxSelectSolidBrush( colorRed ); // this is the box background color
}
pxHeight = Status( "pxchartheight" ) ;
xx = Status( "pxchartwidth");
Left = 1100;
width = 310;
x = 5;
x2 = 290;

y = pxHeight;

GfxSelectPen( colorGreen, 1); // broader color
GfxRoundRect( x, y - 98, x2, y , 7, 7 ) ;
GfxTextOut( ( "TREND"),13,y-100);
GfxTextOut( (" "),27,y-100);
GfxTextOut( ("Last " + sig + " Signal came " + (BarCount-bars-1) * Interval()/60 + " mins ago"), 13, y-80) ; // The text format location
GfxTextOut( ("" + WriteIf(sig =="BUY",sig + " @ ",sig + " @") + " : " + entry), 13, y-60);
GfxTextOut( ("Trailing SL : " + TrendSL + " (" + WriteVal(IIf(sig == "SELL",entry-sl,sl-entry), 2.2) + ")"), 13, y-40);
/*GfxTextOut( ("TGT:1 : " + tar1), 13, y -80);
GfxTextOut( ("TGT:2 : " + tar2), 13,y-60);
GfxTextOut( ("TGT:3 : " + tar3), 13,y-40);*/
//GfxTextOut( ("Current P/L : " + WriteVal(IIf(sig == "BUY",(C-entry),(entry-C)),2.2)), 13, y-22);;

}


_SECTION_BEGIN("Fibo Retrace and Extensions");
//fibs = ParamToggle("Plot Fibs","Off|On",1);
pctH = Param ("Pivot Hi %", 0.325,0.001,2.0,0.002);
HiLB = Param ("Hi LookBack",1,1,BarCount-1,1);
pctL = Param ("Pivot Lo %", 0.325,0.001,2.0,0.002);
LoLB = Param ("Lo LookBack",1,1,BarCount-1,1);
Back = Param ("Extend Left = 2",1,1,500,1);
Fwd = Param("Plot Forward", 0, 0, 500, 1);
//text = ParamToggle("Plot Text","Off|On",1);
hts = Param ("Text Shift", -33.5,-50,50,0.10);
style =ParamStyle("Line Style",styleLine,styleNoLabel);
x = BarIndex();
pRp = PeakBars( H, pctH, 1) == 0;
yRp0 = SelectedValue(ValueWhen( pRp, H, HiLB));
xRp0 = SelectedValue(ValueWhen( pRp, x, HiLB));
pSp = TroughBars( L, pctL, 1) == 0;
ySp0 = SelectedValue(ValueWhen( pSp, L, LoLB));
xSp0 = SelectedValue(ValueWhen( pSp, x, LoLB));
Delta = yRp0 - ySp0;

function fib(ret)
{
retval = (Delta * ret);
Fibval = IIf(ret < 1.0
AND xSp0 < xRp0, yRp0 - retval, IIf(ret < 1.0
AND xSp0 > xRp0, ySp0 + retval,IIf(ret > 1.0
AND xSp0 < xRp0, yRp0 - retval, IIf(ret > 1.0
AND xSp0 > xRp0, ySp0 + retval, Null))));
return FibVal;
}

x0 = Min(xSp0,xRp0)-Back;
x1 = (BarCount -1);

r236 = fib(0.236); r236I = LastValue (r236,1);
r382 = fib(0.382); r382I = LastValue (r382,1);
r050 = fib(0.50); r050I = LastValue (r050,1);
r618 = fib(0.618); r618I = LastValue (r618,1);
r786 = fib(0.786); r786I = LastValue (r786,1);
e127 = fib(1.27); e127I = LastValue (e127,1);
e162 = fib(1.62); e162I = LastValue (e162,1);
e200 = fib(2.00); e200I = LastValue (e200,1);
e262 = fib(2.62); e262I = LastValue (e262,1);
e424 = fib(4.24); e424I = LastValue (e424,1);

p00 = IIf(xSp0 > xRp0,ySp0,yRp0); p00I = LastValue (p00,1);
p100 = IIf(xSp0 < xRp0,ySp0,yRp0); p100I = LastValue (p100,1);
color00 =IIf(xSp0 > xRp0,colorLime,colorRed);
color100 =IIf(xSp0 < xRp0,colorLime,colorRed);

numbars = LastValue(Cum(Status("barvisible")));
fraction= IIf(StrRight(Name(),3) == "", 3.2, 3.2);

if(fibs==1)
{
Plot(LineArray(xRp0-Fwd,yRp0,x1,yRp0,Back),"PR",32,8|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(xSp0-Fwd,ySp0,x1,ySp0,Back),"PS",27,8|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,r236,x1,r236,Back),"",45,style|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,r382,x1,r382,Back),"",44,style|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,r050,x1,r050,Back),"",41,style|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,r618,x1,r618,Back),"",43,style|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,r786,x1,r786,Back),"",42,style|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,e127,x1,e127,Back),"e127",47,style|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,e162,x1,e162,Back),"e162",47,style|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,e200,x1,e200,Back),"p200",47,style|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,e262,x1,e262,Back),"p262",47,style|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,e424,x1,e424,Back),"p424",25,style|styleNoRescale,Null, Null,Fwd);
}

if(text==1)
{
PlotText(" 0% = " + WriteVal(p00,fraction), LastValue(BarIndex())-(numbars/hts), p00I + 0.05, color00);
PlotText("23% = " + WriteVal(r236,fraction), LastValue(BarIndex())-(numbars/hts), r236I + 0.05, 45);
PlotText("38% = " + WriteVal(r382,fraction), LastValue(BarIndex())-(numbars/hts), r382I + 0.05, 44);
PlotText("50% = " + WriteVal(r050,fraction), LastValue(BarIndex())-(numbars/hts), r050I + 0.05, 41);
PlotText("62% = " + WriteVal(r618,fraction), LastValue(BarIndex())-(numbars/hts), r618I + 0.05, 43);
PlotText("78% = " + WriteVal(r786,fraction), LastValue(BarIndex())-(numbars/hts), r786I + 0.05, 42);
PlotText("100% = " + WriteVal(p100,fraction), LastValue(BarIndex())-(numbars/hts),p100I + 0.05, color100);
PlotText("127% = " + WriteVal(e127,fraction), LastValue(BarIndex())-(numbars/hts),e127I + 0.05, 47);
PlotText("162% = " + WriteVal(e162,fraction), LastValue(BarIndex())-(numbars/hts),e162I + 0.05, 47);
PlotText("200% = " + WriteVal(e200,fraction), LastValue(BarIndex())-(numbars/hts),e200I + 0.05, 47);
PlotText("262% = " + WriteVal(e262,fraction), LastValue(BarIndex())-(numbars/hts),e262I + 0.05, 47);
PlotText("424% = " + WriteVal(e424,fraction), LastValue(BarIndex())-(numbars/hts),e424I + 0.05, 25);
}



_SECTION_BEGIN("swing1");

messageboard = ParamToggle("Message Board","Show|Hide",0);
showsl = ParamToggle("Stop Loss Line", "Show|Hide", 1);


no=20;
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);
supres=IIf(avn==1,sup,res);
//s5d=IIf(avn==1,sup,res);
a=Cross(C,supres);
b=Cross(supres,C);

if (showsl == 0)
{
Plot(supres,"Stop Loss",colorCustom8,styleDots);
}


//Plot(supres,"Swing",colorYellow,styleStaircase); 
//Plot(supres,"Swing",colorLightBlue,styleDots);

//SetChartBkGradientFill( ParamColor("BgTop", ColorRGB( 172,172,172 )),ParamColor("BgBottom", ColorRGB( 172,172,172 )),ParamColor("titleblock",ColorRGB( 172,172,172 ))); 



prev=AMA2(C,1,0);
//d=IIf(C>( Ref(Max(Max(H,Ref(H,-20)),Max(Ref(H,-10),Ref(H,-15))),-1) ),Min(Min(L,Ref(L,-20)),Min(Ref(L,-10),Ref(L,-15))), IIf(C<Ref(Min(Min(L,Ref(L,-20)),Min(Ref(L,-10),Ref(L,-15))),-1),Max(Max(H,Ref(H,-20)),Max(Ref(H,-10),Ref(H,-15))),PREV));

  d=IIf(C>( Ref(Max(Max(H,Ref(H,-20)),Max(Ref(H,-10),Ref(H,-15))),-1) ),Min(Min(L,Ref(L,-20)),Min(Ref(L,-10),Ref(L,-15))), IIf(C<Ref(Min(Min(L,Ref(L,-20)),Min(Ref(L,-10),Ref(L,-15))),-1),Max(Max(H,Ref(H,-20)),Max(Ref(H,-10),Ref(H,-15))),PREV));

Buy=Cross(Close,d);
//a = Cross)Close,d);

Sell=Cross(d,Close);
//b=Cross(d,Close);
//state=IIf(BarsSince(a)<BarsSince(b),1,0);


Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
//Short = ExRem(Short, Cover);
//Cover = ExRem(Cover, Short);
AlertIf( Buy, "", "BUY @ " + C, 1 );
AlertIf( Sell, "", "SELL @ " + C, 2);



for(i=BarCount-1;i>1;i--)
{
	if(Buy[i] == 1)
		{
			entry = C[i];
			sig = "BUY";
			sl = supres[i];
			tar1 = entry + (entry * .0050);
			tar2 = entry + (entry * .0092);
			tar3 = entry + (entry * .0125);
			tar4 = entry + (entry * .0192);

			bars = i;
			i = 0;
		}
			if(Sell[i] == 1)
			{
				sig = "SELL";
				entry = C[i];
				sl = supres[i];

tar1 = entry - (entry * .0050);
tar2 = entry - (entry * .0112);
tar3 = entry - (entry * .0152);
tar4 = entry - (entry * .0212);

				/*tar1 = entry - 22;
				tar2 = entry - 38;
				tar3 = entry - 55;*/

				bars = i;
				i = 0;
			}
}

Offset = 3;
Clr = IIf(sig == "BUY", colorLime, colorRed);
ssl = IIf(bars == BarCount-1, supres[BarCount-1], Ref(supres, -1));
sl = ssl[BarCount-1];

//Plot(LineArray(bars-Offset, tar1, BarCount, tar1,1), "", Clr, styleLine|styleDots, Null, Null, Offset);
//Plot(LineArray(bars-Offset, tar2, BarCount, tar2,1), "", Clr, styleLine|styleDots, Null, Null, Offset);
//Plot(LineArray(bars-Offset, tar3, BarCount, tar3,1), "", Clr, styleLine|styleDots, Null, Null, Offset);


//Plot(LineArray(bars-Offset, sl, BarCount, sl,1), "", colorDarkRed, styleLine|styleLine, Null, Null, Offset);
//Plot(LineArray(bars-Offset, entry, BarCount, entry,1), "", colorGreen, styleLine|styleLine, Null, Null, Offset);

for (i=bars; i <BarCount;i++)
{
PlotText(""+sig+"@"+entry, BarCount+1,entry,Null,colorBlue);
//PlotText("T1@"+tar1,BarCount+3,tar1,Null,Clr);PlotText("T2@"+tar2,BarCount+3,tar2,Null,Clr);PlotText ("T3@"+tar3,BarCount+3,tar3,Null,Clr);
}



state=IIf(BarsSince(Buy)<BarsSince(Sell),1,0);
s=state>Ref(state,-1);
ss=state<Ref(state,-1);
sss=state==Ref(state,-1);
col=IIf(state == 1 ,51,IIf(state ==0,4,1));

//Plot(C,"",Col,64);
PlotShapes( shapeUpArrow * s ,colorWhite,0,L, Offset=s);
PlotShapes( shapeHollowCircle * s ,colorPink,0,L, Offset=s-12);


PlotShapes( shapeHollowCircle *ss ,colorPink,0,H, Offset=s);
PlotShapes( shapeDownArrow *ss ,colorWhite,0,H, Offset=s+12);


_SECTION_END();

_SECTION_BEGIN("Name and Price");
FS=Param("Font Size",12,12,100,1);
GfxSelectFont("Times New Roman", FS, 700, True ); 
GfxSetBkMode( colorBlack );  
GfxSetTextColor( ParamColor("Color",colorYellow) ); 
Hor=Param("Horizontal Position",547,1,1200,1);
Ver=Param("Vertical Position",1,1,830,1); 
GfxTextOut(""+Name(), Hor+30 , 40 );
GfxTextOut(""+C, Hor+90 , 60);
_SECTION_END();

_SECTION_BEGIN("Line");


a = Param("Average Pds", 5, 1, 10, 1 );
n = Param("Short Pds", 8, 5, 21, 1 );
m = Param("Long Pds", 60, 0, 90, 1 );

Var4 =(Low+High+2*Close)/4; 
OP = EMA(Var4,a);
res1 = HHV(OP,n);

res2 =HHV(OP,m); 
sup2 =LLV(OP,m); 
sup1 =LLV(OP,n);

Linecolor = IIf(Op==sup1,colorCustom12,IIf(Op==res1,10,7));




_SECTION_BEGIN("Rays1");

HaClose =EMA((O+H+L+C)/4,3);  // Woodie 
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );  
HaHigh = Max( H, Max( HaClose, HaOpen ) ); 
HaLow = Min( L, Min( HaClose, HaOpen ) ); 
Temp = Max(High, HaOpen);
Temp = Min(Low,HaOpen);

line=ParamToggle("Line","No|Yes",0);
if(line)
{

Pp1=Param("Ray_Period1",3,1,20,1);
Pp2=Param("ATR_Period1",4,1,20,1);
Cal=HHV(LLV(HaHigh,Pp1)-ATR(Pp2),5);

Plot(Cal,"",Linecolor ,ParamStyle("styleLine 1",styleLine|styleThick,maskAll)); 
positive= Cross(HaClose,Cal);
negative=Cross(Cal,HaClose);

PlotShapes( IIf( positive, shapeHollowSmallCircle, shapeNone ), colorBrightGreen, layer = 0, yposition = HaLow, offset = -4);
PlotShapes( IIf( negative, shapeHollowSmallCircle, shapeNone ), colorRed, layer = 0, yposition = HaHigh, offset = 4);
}

_SECTION_END();




_SECTION_BEGIN("OsSetting");

Ovos = ParamToggle("Display_OVOS", "No|Yes", 0);
OBSetting=Param("Setting",40,1,500,1);
Bline = StochD(OBSetting);
Oversold=Bline<=30;
Overbought=Bline>=85;

if(Ovos)
{
PlotShapes (IIf(Oversold, shapeHollowSmallCircle, shapeNone) ,38, layer = 0, yposition = haLow, offset = -8 );
PlotShapes (IIf(Overbought, shapeHollowSmallCircle, shapeNone) ,colorBrown, layer = 0, yposition = haHigh, offset = 7 );
}

_SECTION_END();


_SECTION_BEGIN("TSKPPIVOT");
CHiPr = 0;
CLoPr = 9999999;
blsLong = 0;
PrevCOBar = 0;
NumBars = 0;
PrePP = 0;
PrevLowVal = 9999999;
BuySig = 0;
blsShort = 0;
PrevHiVal = 0;
blsNewCO = 0;
BarDif   = 0;

KPA900Val = E_TSKPA900(Close);
KPAutoStopVal = E_TSKPAUTOSTOP(High,Low,Close);

// -- Create 0-initialized arrays the size of barcount
aHPivs = haHigh - haHigh;
aLPivs = haLow - haLow;
aHiVal = haHigh - haHigh;
aLoVal = haLow - haLow;


Ctmpl = E_TSKPCOLORTMPL(Open,High,Low,Close,Volume);
sctotal = 0;
sctotal = sctotal  + IIf(tskp_colortmplcnd0 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd1 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd2 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd3 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd4 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd5 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd6 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd7 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd8 > 0, 1, -1); 


for (curBar=0; curBar < BarCount-1; curBar++)
{

	if ( curBar == 0 )
	{
		CHiPr = haHigh[curBar];
		CHiBar = curBar;
		CLoPr = haLow[curBar];
		CLoBar = curBar;
		blsLong = 0;
		blsShort = 0;
		blsNewCO = 0;
		PrePP = 0;
		PrevCOBar = 0;
		PrevHiVal = haHigh[curBar];
		PrevLowVal = haLow[curBar];
		BuySig = 0;
		SellSig = 0;
		blsLL  = 0;
	}

	if (haHigh[CurBar] >= CHiPr) {
		CHiPr = haHigh[CurBar];
		ChiBar = CurBar;
	}

	if (haLow[CurBar] <= CLoPr) {
		CLoPr = haLow[CurBar];
		CLoBar = CurBar;
	}

	if ( (KPA900Val[curBar] >= KPAutoStopVal[curbar]) AND (PrePP != -1) AND (blsLong != 1) ){
		BarDif = CurBar - PrevCOBar;
		if (BarDif >= NumBars) {
			blsLong = 1;
			blsShort = 0;
			blsNewCO = 1;
			PrevCOBar = CurBar;
		}
	}

	if ( (KPA900Val[curBar] <= KPAutoStopVal[curbar]) AND (PrePP != 1) AND (blsShort != 1) ){
		BarDif = CurBar - PrevCOBar;
		if (BarDif >= NumBars) {
			blsLong = 0;
			blsShort = 1;
			blsNewCO = 1;
			PrevCOBar = CurBar;
		}
	}

	if ( (blsNewCO == 1) AND (sctotal[CurBar] >= 5) AND (blsLong == 1) ) {
		LVal = CurBar - CLoBar;
		for (j= CLoBar-1; j <= CLoBar+1; j++)
		{
			if (j >=0) {
				aLPivs[j] = 1;
				aLoVal[j] = CLoPr;
			}
		}
		PrePP = -1;
		blsNewCO = 0;
		CHiPr = haHigh[CurBar];
		CHiBar = CurBar;
		CLoPr = haLow[Curbar];
		CLoBar = CurBar;
		} 
		else if ((blsNewCO == 1) AND (sctotal[CurBar] <= -5) AND (blsShort == 1) ) {
		HVal = CurBar - CHiBar;
		for (j= CHiBar-1; j <= CHiBar+1; j++)
		{		
			if (j >=0) {
				aHPivs[j] = 1;
				aHiVal[j] = CHiPr;
			}
		}
		PrePP = 1;
		blsNewCO = 0;
		CHiPr = haHigh[CurBar];
		CHiBar = CurBar;
		CLoPr = haLow[Curbar];
		CLoBar = CurBar;
		} 
}
//southwind
PlotShapes(IIf(aHPivs == 1, shapeHollowSmallSquare,shapeNone), 25,0,   aHiVal+0.05,Offset = 6);
PlotShapes(IIf(aLPivs == 1, shapeHollowSmallSquare,shapeNone), colorCustom11,0, aLoVal-0.05, Offset = -6);

_SECTION_END();



_SECTION_BEGIN("TSKPMoMo");


blsLong = 0;



KPStopLine = E_TSKPSTOPLINE(High,Low,Close);
// tskp_upsell, tskp_triggerline, tskp_triggerlinevma
sw = E_TSKPUPSELL(Open,High,Low,Close,Volume);
KPTriggerLine = tskp_triggerline;
KPFast3Val = IIf((E_TSKPFAST3(Open,High,Low,Close,Volume)> 0),1, -1);
//tskp_fast2val1, tskp_fast2val2
dummy = E_TSKPFAST2(Open,High,Low,Close,Volume);
KPFast2Val = IIf ((tskp_fast2val1 > 0),1,-1); 



Ctmpl = E_TSKPCOLORTMPL(Open,High,Low,Close,Volume);
sctotal = 0;
sctotal = sctotal  + IIf(tskp_colortmplcnd0 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd1 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd2 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd3 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd4 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd5 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd6 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd7 > 0, 1, -1); 
sctotal = sctotal  + IIf(tskp_colortmplcnd8 > 0, 1, -1); 

// tskp_mediumma,tskp_mediumup,tskp_mediumdown
dummy = E_TSKPMEDIUM(Close);
KPMediumUP = tskp_mediumup;
KPMediumDwn = tskp_mediumdown;
KPMediumMA = tskp_mediumma;

// -- Create 0-initialized arrays the size of barcount
aHPivs = H - H;
aLPivs = L - L;
aHiVal = H - H;
aLoVal = L - L;


for (curBar=5; curBar < BarCount-1; curBar++)
{


	if( (blsLong == -1) OR (blsLong == 0))
	  {
       if ((sctotal[CurBar]  >= 5) AND (KPMediumUP[CurBar]  > KPMediumMA[CurBar] ) AND (KPFast3Val[CurBar]  == 1) AND 
        (KPFast2Val[CurBar]  == 1) AND (KPTriggerLine[CurBar]  >= KPStopLine[CurBar] ))
       {
         blsLong = 1;
		  aLPivs[CurBar] = 1;
		  aLoVal[CurBar] = Low[CurBar];
       }
    }

	if( (blsLong == 1) OR (blsLong == 0))
	  {
       if ((sctotal[CurBar]  <= -5) AND (KPMediumDwn[CurBar]  < KPMediumMA[CurBar] ) AND (KPFast3Val[CurBar]  == -1) AND 
       (KPFast2Val[CurBar]  == -1) AND (KPTriggerLine[CurBar]  <= KPStopLine[CurBar] ))
       {
         blsLong = -1;
         aHPivs[Curbar] = 1;
		  aHiVal[Curbar] = High[Curbar];
       }
    }

    if ((blsLong == 1) AND ((sctotal[CurBar]  < 5) OR (KPMediumUP[CurBar]  < KPMediumMA[CurBar] )  OR  
       (KPFast2Val[CurBar]  < 1)  OR  (KPFast3Val[CurBar]  < 1) OR (KPTriggerLine[CurBar]  < KPStopLine[CurBar] )) )
       {
           blsLong= 0;
        }
          
      if ((blsLong == -1) AND ((sctotal[CurBar]  > -5)  OR  (KPMediumDwn[CurBar] > KPMediumMA[CurBar] )  OR  
         (KPFast2Val[CurBar]  > -1)  OR (KPFast3Val[CurBar]  > -1)  OR 
         (KPTriggerLine[CurBar]  > KPStopLine[CurBar] )) )
         {
            blsLong = 0;
         }
}


PlotShapes (IIf(aHPivs == 1, shapeSmallCircle, shapeNone) ,colorOrange, layer = 0, yposition = haHigh, offset = 7 );
PlotShapes (IIf(aLPivs == 1, shapeSmallCircle, shapeNone) ,10, layer = 0, yposition = haLow, offset = -8 );
 
_SECTION_END();
if (BBand == 1)
{
_SECTION_BEGIN("Bollinger Bands");
P = ParamField("Price field",3);
Periods = Param("Periods", 15, 2, 300, 1 );
Width = Param("Width", 2, 0, 10, 0.05 );
Color = ParamColor("Color", colorGrey40 );
Style = ParamStyle("style");
Plot( BBandTop( P, Periods, Width ), "BBTop" + _PARAM_VALUES(), Color, Style ); 
Plot( BBandBot( P, Periods, Width ), "BBBot" + _PARAM_VALUES(), Color, Style ); 
_SECTION_END();

}
_SECTION_BEGIN("HA");


tchoice=Param("Title Selection ",2,1,2,1);

Q=Param("% Change",2.1,1,10,1);
Z= Ref(Zig(C ,q ),-1) ;
HH=Ref(((Z<Ref(Z,-1) AND Ref(Z,-1) > Ref(Z,-2)) AND (Peak(z,q,1 ) >Peak(Z,q,2))),-1);
LH=Ref(((Z<Ref(Z,-1) AND Ref(Z,-1) > Ref(Z,-2)) AND (Peak(Z,q,1 ) <Peak(Z,q,2))),-1);
HL=Ref(((Z>Ref(Z,-1) AND Ref(Z,-1) < Ref(Z,-2)) AND (Trough(Z,q,1 ) >Trough(Z,q,2))),-1);
LL=Ref(((Z>Ref(Z,-1) AND Ref(Z,-1) < Ref(Z,-2)) AND (Trough(Z,q,1 ) <Trough(Z,q,2))),-1);
GraphXSpace = 5;
dist = 0.5*ATR(20);

for( i = 0; i < BarCount; i++ )
{
if( HH[i] ) PlotText( "HH", i, H[ i ]+dist[i], colorCustom12 );
if( LH[i] ) PlotText( "LH", i, H[ i ]+dist[i], colorCustom12 );
if( HL[i] ) PlotText( "HL", i, L[ i ]-dist[i], colorBlack );
if( LL[i] ) PlotText( "LL", i, L[ i ]-dist[i], colorBlack );

}

//calculates floor pivots from previous days data & plots it on the present intraday chart.
//RED LINE = RESISTANCE
//RED DASHED LINE = MINI RESISTANCE
//BLUE LINE = SUPPORT
//BLUE DASHED LINE = MINI SUPPORT
//YELLOW DOTTED LINE = PIVOT
//RED DOTTED LINE = PREVIOUS Day High
//BLUE DOTTED LINE = PREVIOUS Day Low
//BLACK DOTTED LINE = PREVIOUS Day Close


//2 - IN - 1 PRICE CHART
Pstyle = ParamToggle("Heikin Ashi","On|Off",1);
if(Pstyle==0){
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,"",IIf(HaClose > HaOpen,colorGreen,colorBrown),styleCandle);

//Sell = (abs(HaOpen -HaClose )<= ((HaHigh -HaLow )*0.1));
//Buy = (abs(HaOpen -HaClose )<= ((HaHigh -HaLow )*0.1)) ;

Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );

//PlotShapes( IIf( Sell, shapeDownArrow+ shapePositionAbove, shapeNone), colorCustom12 );
//Plot(EMA(HaClose,20), "", colorBlue , styleLine|styleThick );
//Plot(Wilders(H,260.6), "",colorCustom12 , styleDashed|styleThick );
//Plot(EMA(HaClose,10), "",colorTan, styleLine|styleThick );



TimeFrameSet(inHourly);
Hh=HHV (L,24);
Ll =LLV (H,24);
TimeFrameRestore();
Hh1=(TimeFrameExpand( Hh, inHourly));
Ll1=(TimeFrameExpand( Ll, inHourly));

Plot(Hh1 , "27dayssellbelclose",colorRed, 4+8+2048);
Plot(Ll1 , "27daysbuyabvclose",colorGreen, 4+8+2048);

Buy=Cross(C,LL);
Sell=Cross(HH,C);
Filter=Buy OR Sell;



_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", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
}


Pivot = ParamToggle("Pivot", "weekly|monthly", 1);

if(Pivot)
{
H1 = TimeFrameGetPrice("H", inMonthly, -1); // yesterdays high
L1 = TimeFrameGetPrice("L", inMonthly, -1); // low
C1= TimeFrameGetPrice("C", inMonthly, -1); // close


}
else
{
H1 = TimeFrameGetPrice("H", inWeekly, -1); // yesterdays high
L1 = TimeFrameGetPrice("L", inWeekly, -1); // low
C1= TimeFrameGetPrice("C", inWeekly, -1); // close
}



_SECTION_BEGIN("BACK COLOR");
SetChartBkGradientFill( ParamColor("BgTop", colorPlum),

ParamColor("BgBottom", colorBlack),ParamColor("titleblock",colorPlum));

Title = (EncodeColor(colorGold)+Day() + EncodeColor(colorWhite) + Name()+"  " + Date() +"  "+Interval(2) +"  "+ EncodeColor(colorWhite)+",Open "+Open +" , High "+H+" , Low "+L+" , Close "+C+" "+"{{VALUES}}");

BuyPrice = Open;
SellPrice = Open;

Derived=WMA(WMA(WMA(((H+L)/2)+(O-C),92),1),1); 
i=WMA(Derived,3); 
Upper=(Derived+StDev(Derived,7))+ATR(2)/1.5; 
Lower=(Derived-StDev(Derived,7))-ATR(2)/1; 

color=IIf(BarsSince(Cross(Lower,Low))> 
BarsSince(Cross(C,Upper)), colorBrightGreen,colorRed); 
Plot(C,"",color,64); 



//WriteIf(s,"EXIT all Short positions\nif trading long positions, enter long Now-\nOR at the market price on tomorrow's Open with stop="+EncodeColor(4)+WriteVal(L+.75*ATR(5),1.4)+" ,","");
//WriteIf(ss,"exit all long positions today with a Market On Close (MOC) order\nOR at the market price on tomorrow's Open with stop="+EncodeColor(4)+WriteVal(Ref(H+.75*ATR(5), -1),1.4)+",","");
//WriteIf( sss ,"No trading signals today.","") ;



SetBarsRequired( 600, 0 );
 
GraphXSpace = 8;
SetChartOptions( 0, chartShowArrows | chartShowDates );
 
 
//============== TITLE ==============

_SECTION_BEGIN("Magnified Market Price");
FS=Param("Font Size",30,11,100,1);
GfxSelectFont("Times New Roman", FS, 700, True ); 
GfxSetBkMode( colorWhite );  
GfxSetTextColor( ParamColor("Color",colorGold) ); 
Hor=Param("Horizontal Position",970,1,1200,1);
Ver=Param("Vertical Position",50,1,830,1); 
GfxTextOut(""+C, Hor , Ver );
YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);
GfxSelectFont("Times New Roman", 11, 700, True ); 
GfxSetBkMode( colorWhite );  
GfxSetTextColor(ParamColor("Color",colorBlack) ); 
GfxTextOut(""+DD+"  ("+xx+"%)", Hor , Ver+45 );

_SECTION_END();




_SECTION_BEGIN("Price Line");
dp= Param("dps",3,0,1000,1);
PriceLineColor=ParamColor("PriceLineColor",colorOrange);
PriceLevel = ParamField("PriceField", field = 3 ); 
PriceLeve2 = ParamField("PriceField", field = dp );
Daysback    = Param("Bars Back",1,10,500,1); 
FirstBar    = BarCount - DaysBack; 
 YY        = IIf(BarIndex() >= Firstbar,EndValue(PriceLevel),Null); 

Plot(YY,"Current Price",PriceLineColor,ParamStyle("LineStyle",styleLine|styleDashed|styleNoTitle|styleNoLabel|styleThick,maskAll)); 

side = Param("side",1,0,1000,1);

dist = 0; 

for( i = 0; i < BarCount; i++ ) 
{ 
 if(i+side== BarCount) PlotText( "\n    " + PriceLevel[ i ], i, YY[ i ]-dist[i], colorGold );

} 

_SECTION_END();





































       /****************/
        /*              */
        /* ALERT OUTPUT */
        /*              */
        /****************/

        TxtX = Param("Text Left", 600, 0, 1000, 10);
        TxtY = Param("Text Top", 60, 1, 650, 10);
 
        GfxSelectFont("Tahoma", 14, 700 ); 
        GfxSetBkMode(1); 

        if(LastValue(Buy) OR SelectedValue(Buy))
            {
                GfxSetTextColor(colorGold); 
               
                Say(""); 
            }

        else if(LastValue(Sell) OR SelectedValue(Sell))
            {
                GfxSetTextColor(colorGold); 
               
                Say("");
            }

        else
            {
                GfxSetTextColor(colorGold);
              
                GfxTextOut("", TxtX, TxtY); 
            }
_SECTION_BEGIN("sys");

x=Param("xposn",315,0,1000,1);
y=Param("yposn",576,0,1000,1);



_SECTION_END();




_SECTION_BEGIN("Background text");
C11=ParamColor("up panel",colorBlack );
C12=ParamColor("dn panel",colorBlack );
C13=Param("fonts",20,10,30,1 );
C14=Param("left-right",2.1,1.0,5.0,0.1 );
C15=Param("up-down",8,1,30,1 );
Miny = Status("axisminy");
Maxy = Status("axismaxy");
lvb = Status("lastvisiblebar");
fvb = Status("firstvisiblebar");
pxwidth = Status("pxwidth");
pxheight = Status("pxheight");
GfxSetBkMode( 0 ); 
GfxSelectFont("Tahoma", 12, 500, False, False, 0);
GfxSetTextColor(colorCustom12); 
GfxSetTextAlign( 6 );
GfxSelectFont("Tahoma", 15, 600, False, False, 0);
GfxSetTextColor(colorWhite); 
GfxSetTextAlign( 6 );

GfxSelectFont("Tahoma", 12, 400, False, False, 0);
GfxSetTextColor(colorBrightGreen);

GfxSelectFont("Tahoma", 12, 400, False, False, 0);
GfxSetTextColor(colorRed);




pricechange=(C-Ref(C,-1))*100/Ref(C,-1);
changeponit=C-Ref(C,-1);
Vlp=Param("Volume lookback period",15,10,300,10);
Vrg=MA(V,Vlp);
St = StDev(Vrg,Vlp); 
Vp3 = Vrg + 3*st; 
Vp2 = Vrg + 2*st;;
Vp1 = Vrg + 1*st;;
Vn1 = Vrg -1*st; 
Vn2 = Vrg -2*st; 

x=Param("xposn",1,0,1000,1);
y=Param("yposn",1,0,1000,1);

GfxGradientRect( 1, 1, 1400, 40, colorViolet, colorBlack);
GfxSetBkMode(0);
GfxSelectFont( "Georgia", 18, 800, False );
GfxSetTextColor( colorGold );
GfxTextOut( "Simple ", x+600, y+10 );
GfxSelectFont( "Tahoma", 16, 800, False );
GfxSetTextColor( colorGold );
GfxTextOut( Name(), x+100, y+10 );
GfxSelectFont( "Century Gothic", 15, 100, False );
GfxSetTextColor( colorGold );
GfxTextOut( Date(), x+1000, y+10 );
GfxSelectFont( "Comic Sans MS", 15, 500, False );
GfxSetTextColor( colorYellow );
GfxTextOut( Interval(2), x+275, y+10 );
//------------------------------------------------------------ H, L, O, C----------------------
GfxGradientRect( 1, 40, 1400, 55, colorViolet, colorBlack );
GfxSetBkMode(0);
GfxSelectFont( "Areal", 9, 200, False );
GfxSetTextColor( colorWhite );
GfxTextOut( "High:"+WriteVal(H,1.2), x+100, y+40 );
GfxSelectFont( "Areal", 9, 200, False );
GfxSetTextColor( colorWhite );
GfxTextOut( "Low:"+WriteVal(L,1.2), x+200, y+40 );
GfxSelectFont( "Areal", 9, 200, False );
GfxSetTextColor( colorWhite );
GfxTextOut( "Open:"+WriteVal(O,1.2), x+300, y+40 );
GfxSelectFont( "Areal", 9, 200, False );
GfxSetTextColor( colorWhite );
GfxTextOut( "Close:"+WriteVal(C,1.2), x+400, y+40 );
GfxSelectFont( "comic sans ms", 12, 100, False );
//-----------------------------------------------------------Valume-------------------------------


// set criteria to scan for big stock only;
BigStock = MA( V, 10 ) * MA( C, 10 ) > 100;
 
//---------------Color------------------------
per1 = 6;
per2 = 2;
Om = MA( O, per1 );
hm = MA( H, per1 );
lm = MA( L, per1 );
Cm = MA( C, per1 );
 
// 1. Heiken Ashi
HACLOSE = ( Om + Hm + Lm + Cm ) / 4;
HaOpen = AMA( Ref( HaClose,  -1 ),  0.5 );
HaHigh = Max( Hm,  Max( HaClose,  HaOpen ) );
HaLow = Min( Lm,  Min( HaClose,  HaOpen ) );
 
 
Of = MA( Haopen, per2 );
Cf = MA( Haclose, per2 );
Lf = IIf( haOpen < haClose, MA( Halow, per2 ), MA( Hahigh, per2 ) );
Hf = IIf( haOpen < haClose, MA( Hahigh, per2 ), MA( Halow, per2 ) );
//Color = IIf( Cf > Of, colorGreen, colorRed );
 
 
//----------------------------------------------------
 
TrailStop = HHV( C - 2 * ATR( 10 ), 15 );
ProfitTaker = EMA( H, 13 ) + 2 * ATR( 10 );
 
/* **********************************
Code to automatically identify pivots
********************************** */
 
// -- what will be our lookback range for the hh and ll?
farback = 140; //How Far back to go
nBars = 12; //Number of bars
 
// -- Create 0-initialized arrays the size of barcount
aHPivs = H - H;
aLPivs = L - L;
 
// -- More for future use, not necessary for basic plotting
aHPivHighs = H - H;
aLPivLows = L - L;
aHPivIdxs = H - H;
aLPivIdxs = L - L;
nHPivs = 0;
nLPivs = 0;
lastHPIdx = 0;
lastLPIdx = 0;
lastHPH = 0;
lastLPL = 0;
curPivBarIdx = 0;
 
// -- looking back from the current bar, how many bars
// back were the hhv and llv values of the previous
// n bars, etc.?
aHHVBars = HHVBars( O, nBars );
aLLVBars = LLVBars( O, nBars );
aHHV = HHV( O, nBars );
aLLV = LLV( O, nBars );
 
// -- Would like to set this up so pivots are calculated back from
// last visible bar to make it easy to "go back" and see the pivots
// this code would find. However, the first instance of
// _Trace output will show a value of 0
aVisBars = Status( "barvisible" );
nLastVisBar = LastValue( Highest( IIf( aVisBars, BarIndex(), 0 ) ) );
_TRACE( "Last visible bar: " + nLastVisBar );
 
// -- Initialize value of curTrend
curBar = ( BarCount - 1 );
curTrend = "";
 
if ( aLLVBars[curBar] < aHHVBars[curBar] )
{
    curTrend = "D";
}
else
{
    curTrend = "U";
}
 
// -- Loop through bars. Search for
// entirely array-based approach
// in future version
for ( i = 0; i < BarCount; i++ )
{
    curBar = ( BarCount - 1 ) - i;
// -- Have we identified a pivot? If trend is down...
 
    if ( aLLVBars[curBar] < aHHVBars[curBar] )
    {
// ... and had been up, this is a trend change
        if ( curTrend == "U" )
        {
            curTrend = "D";
// -- Capture pivot information
            curPivBarIdx = curBar - aLLVBars[curBar];
            aLPivs[curPivBarIdx] = 1;
            aLPivLows[nLPivs] = L[curPivBarIdx];
            aLPivIdxs[nLPivs] = curPivBarIdx;
            nLPivs++;
        }
 
// -- or current trend is up
    }
    else
    {
        if ( curTrend == "D" )
        {
            curTrend = "U";
            curPivBarIdx = curBar - aHHVBars[curBar];
            aHPivs[curPivBarIdx] = 1;
            aHPivHighs[nHPivs] = H[curPivBarIdx];
            aHPivIdxs[nHPivs] = curPivBarIdx;
            nHPivs++;
        }
 
// -- If curTrend is up...else...
    }
 
// -- loop through bars
}
 
// -- Basic attempt to add a pivot this logic may have missed
// -- OK, now I want to look at last two pivots. If the most
// recent low pivot is after the last high, I could
// still have a high pivot that I didn't catch
// -- Start at last bar
curBar = ( BarCount - 1 );
 
candIdx = 0;
 
candPrc = 0;
 
lastLPIdx = aLPivIdxs[0];
 
lastLPL = aLPivLows[0];
 
lastHPIdx = aHPivIdxs[0];
 
lastHPH = aHPivHighs[0];
 
if ( lastLPIdx > lastHPIdx )
{
// -- Bar and price info for candidate pivot
    candIdx = curBar - aHHVBars[curBar];
    candPrc = aHHV[curBar];
 
    if (
        lastHPH < candPrc AND
        candIdx > lastLPIdx AND
        candIdx < curBar )
    {
// -- OK, we'll add this as a pivot...
        aHPivs[candIdx] = 1;
// ...and then rearrange elements in the
// pivot information arrays
 
        for ( j = 0; j < nHPivs; j++ )
        {
            aHPivHighs[nHPivs-j] = aHPivHighs[nHPivs- ( j+1 )];
            aHPivIdxs[nHPivs-j] = aHPivIdxs[nHPivs-( j+1 )];
        }
 
        aHPivHighs[0] = candPrc ;
 
        aHPivIdxs[0] = candIdx;
        nHPivs++;
    }
}
else
{
// -- Bar and price info for candidate pivot
    candIdx = curBar - aLLVBars[curBar];
    candPrc = aLLV[curBar];
 
    if (
        lastLPL > candPrc AND
        candIdx > lastHPIdx AND
        candIdx < curBar )
    {
// -- OK, we'll add this as a pivot...
        aLPivs[candIdx] = 1;
// ...and then rearrange elements in the
// pivot information arrays
 
        for ( j = 0; j < nLPivs; j++ )
        {
            aLPivLows[nLPivs-j] = aLPivLows[nLPivs-( j+1 )];
            aLPivIdxs[nLPivs-j] = aLPivIdxs[nLPivs-( j+1 )];
        }
 
        aLPivLows[0] = candPrc;
 
        aLPivIdxs[0] = candIdx;
        nLPivs++;
    }
}
 
//============== EXPLORATION ==============
Buy = Cover = BigStock AND aLPivs == 1;
 
Sell = Short = BigStock AND aHPivs == 1;
 
SellPrice = ValueWhen( Sell, C, 1 );
 
BuyPrice = ValueWhen( Buy, C, 1 );
 
Long = Flip( Buy, Sell );
 
Shrt = Flip( Sell, Buy );
 
//============== Plot price ==============
n = 15;
 
a =  C > ( MA( H, n ) + MA( L, n ) ) / 2;// then Buy next bar at market;
 
b = C < ( MA( H, n ) + MA( L, n ) ) / 2;// then Sell Short next bar at market;
 
state = IIf( BarsSince( a ) < BarsSince( b ), 1, 0 );
 
Longs = state == 1;
 
shorts = state == 0;  




 
 
_SECTION_BEGIN("swing2");
no=22;
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);
supres=IIf(avn==1,sup,res);
a=Cross(C,supres);
b=Cross(supres,C);
style = a * styleStaircase + b * styleStaircase;
PlotShapes(a,style, IIf(a,colorGreen,colorRed), 0, IIf(a,Low,High));
Plot(SUPRES,"Stop Loss",colorCustom1,styleDots);


//intra////////////////////////////////////////////////////




    _SECTION_END();

// TO ADD//

//Previous Days HI LO //

DayH = TimeFrameGetPrice("H", inDaily, -1);    DayHI = LastValue (DayH,1);// yesterdays high
DayL = TimeFrameGetPrice("L", inDaily, -1);    DayLI = LastValue (DayL,1);   // yesterdays low
DayC = TimeFrameGetPrice("C", inDaily, -1);    // yesterdays close
DayO = TimeFrameGetPrice("O", inDaily);    // current day open
DayH2= TimeFrameGetPrice("H", inDaily, -2); DayH2I = LastValue (DayH2,1); // Two days before high
DayL2= TimeFrameGetPrice("L", inDaily, -2); DayL2I = LastValue (DayL2,1); // Two days before low
DayH3= TimeFrameGetPrice("H", inDaily, -3); DayH3I = LastValue (DayH3,1); // Three days before high
DayL3= TimeFrameGetPrice("L", inDaily, -3); DayL3I = LastValue (DayL3,1); // Three days before low

numbars = LastValue(Cum(Status("barvisible")));
hts = -33.5;
if(ahl ==1)
{
YHL = ParamToggle("Yesterday HI LO","Show|Hide",1);
if(YHL==1) {
Plot(DayL,"YL",colorTurquoise,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(DayH,"YH",colorTurquoise,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
PlotText(" YH " , LastValue(BarIndex())-(numbars/Hts), DayHI, colorTurquoise);
PlotText(" YL " , LastValue(BarIndex())-(numbars/Hts), DayLI, colorTurquoise);
}
}
TDBHL = ParamToggle("2/3Days before HI LO","Show|Hide",0);
if(TDBHL==1) {
Plot(DayL2,"2DBL",colorTurquoise,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(DayH2,"2DBH",colorTurquoise,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(DayL3,"3DBL",colorTurquoise,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(DayH3,"3DBH",colorTurquoise,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
PlotText(" 2DBH " , LastValue(BarIndex())-(numbars/Hts), DayH2I, colorTurquoise);
PlotText(" 2DBL " , LastValue(BarIndex())-(numbars/Hts), DayL2I, colorTurquoise);
PlotText(" 3DBH " , LastValue(BarIndex())-(numbars/Hts), DayH3I, colorTurquoise);
PlotText(" 3DBL " , LastValue(BarIndex())-(numbars/Hts), DayL3I, colorTurquoise);
}


PP = (DayL + DayH + DayC)/3; PPI = LastValue (PP,1); // Pivot
R1 = (PP * 2) - DayL; R1I = LastValue (R1,1); // Resistance 1
S1 = (PP * 2) - DayH; S1I = LastValue (S1,1); // Support 1
R2 = PP + R1 - S1; R2I = LastValue (R2,1); // Resistance 2
S2 = PP - R1 + S1; S2I = LastValue (S2,1); // Support 2
R3 = PP + R2 - S1; R3I = LastValue (R3,1); // Resistance 3
S3 = PP - R2 + S1; S3I = LastValue (S3,1); // Support 3

ppl = ParamToggle("Pivot Levels","Show|Hide",0);
if(ppl==1) {
Plot(PP, "PP",colorYellow,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(R1, "R1",colorViolet,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(S1, "S1",colorViolet,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(R2, "R2",colorViolet,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(S2, "S2",colorViolet,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(R3, "R3",colorViolet,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(S3, "S3",colorViolet,styleDots|styleNoLine|styleNoRescale|styleNoTitle);

PlotText(" Pivot ", LastValue(BarIndex())-(numbars/Hts), PPI, colorYellow);
PlotText(" R1 " , LastValue(BarIndex())-(numbars/Hts), R1I, colorViolet);
PlotText(" S1 " , LastValue(BarIndex())-(numbars/Hts), S1I, colorViolet);
PlotText(" R2 " , LastValue(BarIndex())-(numbars/Hts), R2I, colorViolet);
PlotText(" S2 " , LastValue(BarIndex())-(numbars/Hts), S2I, colorViolet);
PlotText(" R3 " , LastValue(BarIndex())-(numbars/Hts), R3I, colorViolet);
PlotText(" S3 " , LastValue(BarIndex())-(numbars/Hts), S3I, colorViolet);
}


rg = (DayH - DayL);

H5=DayC+1.1*rg; H5I = LastValue (H5,1);
H4=DayC+1.1*rg/2; H4I = LastValue (H4,1);
H3=DayC+1.1*rg/4; H3I = LastValue (H3,1);
H2=DayC+1.1*rg/6; H2I = LastValue (H2,1);
H1=DayC+1.1*rg/12; H1I = LastValue (H1,1);
L1=DayC-1.1*rg/12; L1I = LastValue (L1,1);
L2=DayC-1.1*rg/6; L2I = LastValue (L2,1);
L3=DayC-1.1*rg/4; L3I = LastValue (L3,1);
L4=DayC-1.1*rg/2; L4I = LastValue (L4,1);
L5=DayC-1.1*rg; L5I = LastValue (L5,1);

pcl = ParamToggle("Camerilla Levels","Show|Hide",0);
if(pcl==1) {
Plot(H5,"",colorRose,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(H4,"",colorRose,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(H3,"",colorRose,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(H2,"",colorRose,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(H1,"",colorRose,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(L1,"",colorRose,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(L2,"",colorRose,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(L3,"",colorRose,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(L4,"",colorRose,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(L5,"",colorRose,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
PlotText(" H5 = " , LastValue(BarIndex())-(numbars/Hts), H5I +0.05, colorRose);
PlotText(" H4 = " , LastValue(BarIndex())-(numbars/Hts), H4I +0.05, colorRose);
PlotText(" H3 = " , LastValue(BarIndex())-(numbars/Hts), H3I +0.05, colorRose);
PlotText(" H2 = " , LastValue(BarIndex())-(numbars/Hts), H2I +0.05, colorRose);
PlotText(" H1 = " , LastValue(BarIndex())-(numbars/Hts), H1I +0.05, colorRose);
PlotText(" L1 = " , LastValue(BarIndex())-(numbars/Hts), L1I +0.05, colorRose);
PlotText(" L2 = " , LastValue(BarIndex())-(numbars/Hts), L2I +0.05, colorRose);
PlotText(" L3 = " , LastValue(BarIndex())-(numbars/Hts), L3I +0.05, colorRose);
PlotText(" L4 = " , LastValue(BarIndex())-(numbars/Hts), L4I +0.05, colorRose);
PlotText(" L5 = " , LastValue(BarIndex())-(numbars/Hts), L5I +0.05, colorRose);
}


THL = ParamToggle("Todays Hi Lo","Show|Hide",1);
if(THL==1) {
isRth = TimeNum() >= 084500 & TimeNum() <= 085959;
isdRth = TimeNum() >= 084500 & TimeNum() <= 160000;
aRthL = IIf(isRth, L, 1000000);
aRthH = IIf(isdRth, H, Null);
aRthLd = IIf(isdRth, L, 1000000);
DayH = TimeFrameCompress( aRthH, inDaily, compressHigh );
DayH = TimeFrameExpand( DayH, inDaily, expandFirst );
DayL = TimeFrameCompress( aRthLd, inDaily, compressLow );
DayL = TimeFrameExpand( DayL, inDaily, expandFirst );
Bars = BarsSince(TimeNum() >= 94500 AND TimeNum() < 095959);//,BarIndex(),1); // AND DateNum()==LastValue(DateNum());
x0 = BarCount-LastValue(Bars);
x1 = BarCount-1;
DayHline=LineArray(x0,LastValue(DayH),x1,LastValue (DayH),0); 
DayLline=LineArray(x0,LastValue(DayL),x1,LastValue (DayL),0); 
DayHlineI = LastValue (DayHline,1);
DayLlineI = LastValue (DayLline,1);
Plot(DayHline,"DayH",colorYellow,styleBar|styleNoRescale|styleNoTitle);
Plot(DayLline,"DayL",colorYellow,styleBar|styleNoRescale|styleNoTitle);
PlotText(" Day Hi " , LastValue(BarIndex())-(numbars/Hts), DayHlineI +0.05, colorYellow);
PlotText(" Day Lo " , LastValue(BarIndex())-(numbars/Hts), DayLlineI +0.05, colorYellow);
}
////////////add hi comp



SL = ( HHV( H, 26 ) + LLV( L, 26) )/2;
TL = ( HHV( H, 9 ) + LLV( L, 9 ) )/2;
DL = Ref( C, 26 );
Span1 = (( SL + TL )/2);
Span2 = (HHV( H, 52) + LLV(L, 52))/2;
Sp1=Ref((SL+TL)/2,-25);
Sp2=Ref((HHV(H,52)+LLV(L,52))/2,-25);
Plot(DL,"",colorLightBlue,styleThick); // delayed, lagging, or chikou span

if(ICHIMOKU==1){
Plot (SL,"Standard",colorGreen);
Plot (TL,"Turning",colorRed);
PlotOHLC (Sp1,Sp1,Sp2,Sp2,"Cloud",IIf
(Sp1>Sp2,colorSeaGreen,colorDarkRed),styleCloud);
}
//==========================================================

14 comments

1. czar1403

gives error please check

2. sutharnehal

This code requires necessary .dll files because it seems that this code is taken from any paid service provider. It gives error for the following lines and this is not free source at all. So, either provide .dll files or delete this code from here. Thanks!

KPA900Val = E_TSKPA900(Close);
KPAutoStopVal = E_TSKPAUTOSTOP(High,Low,Close);

Ctmpl = E_TSKPCOLORTMPL(Open,High,Low,Close,Volume);

sctotal = sctotal + IIf(tskp_colortmplcnd0 > 0, 1, -1);
sctotal = sctotal + IIf(tskp_colortmplcnd1 > 0, 1, -1);
sctotal = sctotal + IIf(tskp_colortmplcnd2 > 0, 1, -1);
sctotal = sctotal + IIf(tskp_colortmplcnd3 > 0, 1, -1);
sctotal = sctotal + IIf(tskp_colortmplcnd4 > 0, 1, -1);
sctotal = sctotal + IIf(tskp_colortmplcnd5 > 0, 1, -1);
sctotal = sctotal + IIf(tskp_colortmplcnd6 > 0, 1, -1);
sctotal = sctotal + IIf(tskp_colortmplcnd7 > 0, 1, -1);
sctotal = sctotal + IIf(tskp_colortmplcnd8 > 0, 1, -1);

if ( (KPA900Val[curBar] >= KPAutoStopVal[curbar]) AND (PrePP != -1) AND (blsLong != 1) ){

if ( (KPA900Val[curBar] <= KPAutoStopVal[curbar]) AND (PrePP != 1) AND (blsShort != 1) ){

KPStopLine = E_TSKPSTOPLINE(High,Low,Close);

sw = E_TSKPUPSELL(Open,High,Low,Close,Volume);

KPTriggerLine = tskp_triggerline;

KPFast3Val = IIf((E_TSKPFAST3(Open,High,Low,Close,Volume)> 0),1, -1);

dummy = E_TSKPFAST2(Open,High,Low,Close,Volume);

KPFast2Val = IIf ((tskp_fast2val1 > 0),1,-1);

Ctmpl = E_TSKPCOLORTMPL(Open,High,Low,Close,Volume);

sctotal = sctotal + IIf(tskp_colortmplcnd0 > 0, 1, -1);
sctotal = sctotal + IIf(tskp_colortmplcnd1 > 0, 1, -1);
sctotal = sctotal + IIf(tskp_colortmplcnd2 > 0, 1, -1);
sctotal = sctotal + IIf(tskp_colortmplcnd3 > 0, 1, -1);
sctotal = sctotal + IIf(tskp_colortmplcnd4 > 0, 1, -1);
sctotal = sctotal + IIf(tskp_colortmplcnd5 > 0, 1, -1);
sctotal = sctotal + IIf(tskp_colortmplcnd6 > 0, 1, -1);
sctotal = sctotal + IIf(tskp_colortmplcnd7 > 0, 1, -1);
sctotal = sctotal + IIf(tskp_colortmplcnd8 > 0, 1, -1);

dummy = E_TSKPMEDIUM(Close);
KPMediumUP = tskp_mediumup;
KPMediumDwn = tskp_mediumdown;
KPMediumMA = tskp_mediumma;

3. pareshJ

before published at least " please check AFL "

thx

4. administrator

This formula uses a common plugin.

You can get it here…

5. hotaro3

thanks for valuable indicator- version 1 and 2 works perfectly without any error- but in version 2 advanced elliot waves has no action – in version 1 no problem. I think It has worth to check it for making it better
thanks a lot

6. eldertop

Beware backtesting unfortunaly is not real, look in to the future,beware because signal disappears only in backtesting,results of normal intraday system is not exceptional are like a simple atr. BEWARE of this version and version 1.0

7. SPASHA

WORLDS BIGGEST FORMULA

8. vsl
ROC(Mov((C / P),13,S),1,%)

Sir,
You had drawn such complicated formula. Hence one thing is sure that you are expert in AFL. Above given simple formula is in meta-stock language. Can you convert it into AFL.
I provide brief interpretation of said formula is as under.
" In very basic terms, sector analysis is a top down stock selection method. Market sectors expected to outperform the rest of the market are identified, and then stocks from these sectors are selected. The belief is that if you can select securities in superior sectors, these securities will perform along with their respective sectors. This follows the truth that money flows from under performing areas of the market, to more profitable areas."
For more interpretation I am available at 5laeeque@gmail.com (5LAEEQUE)

9. jai1147

good indicator. worked for me without any errors…because i already had installed the south-wind formula with the required plugins

10. ildarmux

Does the system at short time intervals of 1 min or 5 min?
How to optimize a trading system?
Please describe in more detail the conditions Buy-Sell Short-Cover

11. jai1147

if you already have installed The Foundation by Southwind v-13.00 this AFl will absolutely work fine.

12. viraldalal

Even if you see back testing report is showing wrong results or actual trading is not matching buy sell signal.

Even buy sell signal vanishes and it repaints …Can you please resolve this formula or find any goo working solution for AFL ?

13. SPASHA

waste of time , start reading it ,your trading ady will end in counting lines or what to do??????

14. qurman

repainting buy-sell arrows.

Leave Comment

Please login here to leave a comment.

Back