Simple Coding Help - No Promise.

jallanankit

Well-Known Member
I am thinking of building a option trading afl.

What i m looking for is..
If system gets a BUY/SHORT/SELL/COVER condition on any logic..
For ex: a MA crossover system, the same time it shall be generated on the CE/PE..

The difference between the SPOT price and CE/PE Strike price can be set in a variable..??

For example.. If nifty is considered..
If MA crossover gets a buy on say 8000 as Nifty Fut price.. The system should generate a buy at 7900 CE (100 points lower Strike Price) and conversely, if a Short trade is generated on 8000, it should go for buying a PE of 8100 strike price.

This 100 points can be manually edited and let it be selected after rounding off nifty value if required...

Can anyone guide me how to do so?
 

amitrandive

Well-Known Member
Hi!

I have a small request.Is there any way Wednesdays can be shown by afl. A simple arrow pointing to wednesday in a given chart would be enough.
Try this :thumb:

Code:
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();

buy = dayofweek() == 3;
PlotShapes(Buy*shapeUpArrow,colorblue);
 
I have 2 tools for entering a trade, (eg ema 10 cross ema 20) on confirmation of only 1st tool, only 1 lot is to be traded, but if the second tool (Eg macd positive) also confirms buy when the 1st tool is confirming buy, than 2 lots is to be entered. Can anybody help me with AFL of lots as per number of confirmation?
 
please add buy sell arrows for crossover
Code:
SetChartOptions(0,chartShowArrows|chartShowDates);
GraphXSpace=Param("GraphXSpace",0,0,100,1);
    dec = (Param("Decimals",2,0,7,1)/10)+1;
SetChartBkColor(ParamColor("Outer Panel", colorBlack));
SetChartBkGradientFill(ParamColor("Upper Chart", colorDarkGrey), ParamColor("Lower Chart", colorDarkGrey));

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(7)+ WriteVal(C,dec)+
    EncodeColor(55)+ "    Volume = "+ EncodeColor(11)+ WriteVal(V,1);
///////////////////////
colorHighliter = IIf(C >= O, ColorRGB(0, 128, 0), ColorRGB(128, 0, 0));
DemandPoint = (Ref(L, -1) < Ref(L, -2)) & (L < Ref(L, -1)) & (L < Ref(L, 1)) & (Ref(L, 1) < Ref(L, 2));

//Supply Point
//colorSupplyPoint = ParamColor("Supply Line", ColorRGB(255, 128, 0));
SupplyPoint = (Ref(H, -1) > Ref(H, -2)) & (H > Ref(H, -1)) & (H > Ref(H, 1)) & (Ref(H, 1) > Ref(H, 2));

CountTrendBars = 0;
CurrentBar = BarCount - 1;
dx0 = dx1 = dy0 = dy1 = 0;
sx0 = sx1 = sy0 = sy1 = 0;
//Price
SetBarFillColor(colorHighliter);
Plot(C, "Close", IIf(colorHighliter == ColorRGB(128, 0, 128), ColorRGB(255, 0, 255), IIf(colorHighliter == ColorRGB(128, 128, 0), ColorRGB(255, 255, 0), IIf(C > O, ColorRGB(0, 255, 0), IIf(C < O, ColorRGB(255, 0, 0), ColorRGB(255, 255, 255))))), styleCandle, Null, Null, 0, 0, 1);


side = 1;

From = Param("Start" , 3, 1, 120, 1 );
To   = Param("End" , 120, 1, 120, 1 );
incr = Param("Step" ,2, 1, 10, 1 );

WhichMA = ParamList("Which MA ?" , "SMA|EMA|WMA|WILDERS",1);
WhichStyle = ParamToggle("Cloud Style", "No|Yes",1);
Effect3D = ParamToggle( "3D effect?", "No|Yes", 1 );
Saturation = Param("Saturation" , 199, 0, 255 );
Brightness = Param("Brightness" , 255, 0, 255 ) ;


if (WhichStyle)
   iStyle = styleCloud;
else
   iStyle = styleLine;

for( i = From; i <To; i += incr)
{
 
  switch (WhichMA)
  {
    case "SMA":
      up = MA( C, i );
      down = MA( C, i + incr );
      break;

    case "WMA":
      up = WMA( C, i );
      down = WMA( C, i + incr );
      break;

     case "WILDERS":
      up = Wilders( C, i );
      down = Wilders( C, i + incr );
      break;

    default:
      up = EMA( C, i );
      down = EMA( C, i + incr );
      break;


  }

  if( Effect3D )
   side = IIf(up<=down AND Ref( up<=down, 1 ), 1, 0.6 );

   PlotOHLC( up,up,down,down, "", ColorHSB( 3*(i - 10),Saturation,side * Brightness), iStyle|styleNoLabel );

}
 
Please help me, I want Buy/sell exit signal on Target 3 level.

a=20; //DEFAULT 20//CHANGED BY MOMIN//

_SECTION_BEGIN("HeikenAshiSmoothed");
GraphXSpace=5;
p=40; //DEFAULT 5 final40
Om=DEMA(O,p);
hm=DEMA(H,p);
lm=DEMA(L,p);
Cm=DEMA(C,p);
HACLOSE=(Om+Hm+Lm+Cm)/4;
HaOpen = AMA( Ref( HaClose, 1), 1);
HaHigh = Max( Hm, Max( HaClose, HaOpen ) );
HaLow = Min( Lm, Min( HaClose, HaOpen ) );

slope = Param("slope",2,2,100,1);
Color20= IIf(LinRegSlope(MA(HaClose,a),slope)<0,colorRed,colorGreen);

//Plot(MA(HaClose,a),"", color20,styleThick);

Color=IIf(Haclose>MA(HaClose,a),colorGreen, colorRed);
PlotOHLC( Open, Open, Close, Close, "" + Name(), Color, styleCandle);

//PlotOHLC( Open, Open, Close, Close, "" + Name(), Color,styleCandle);
_SECTION_END();


Buy=Color==colorGreen;
Sell=Color==colorRed;

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

//PlotShapes(IIf(Buy , shapeUpArrow, shapeNone),colorGreen);
//PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorRed);

//MOMIN//////////////////
_SECTION_BEGIN("Magfied Market Price");
FS=Param("Font Size",30,11,100,1);
GfxSelectFont("Times New Roman", FS, 700, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorYellow) );
Hor=Param("Horizontal Position",1480,1,1800,1);
Ver=Param("Vertical Position",12,1,830,1);
GfxTextOut(""+C, Hor-790 , 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( colorBlack );
GfxSetTextColor(ParamColor("Color",colorYellow) );
GfxTextOut(""+DD+" ("+xx+"%)", Hor-790 , Ver+45 );



/////MOMIN///////

_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
_SECTION_END();

//////MOMIN////////////

_SECTION_END();

CY1 = Param("Short Cycle Length?" ,80, 1 ,1000 ,1 )/2;//DEFAULT 10 FINAL 20 AND 2
CY2 = Param("Medium Cycle Length?" ,80, 1 ,1000 ,1 )/2;
M1 = Param("Short Cycle Multiplyer?" ,1, 0.01 ,10 ,10 );//DEFAULT 10
M2 = Param("Medium Cycle Multiplyer?" ,3, 0.01 ,10 ,1 );
T1 = Ref(MA(Close ,CY1 ),CY1/2) -0+M1*ATR(CY1 );//T1 = Ref(MA(Close ,CY1 ),CY1/2)-2 + M1*ATR(CY1 );
B1 = Ref(MA( Close ,CY1 ),CY1/2)-0-M1*ATR(CY1 );//B1 = Ref(MA( Close ,CY1 ),CY1/2)-2 -M1*ATR(CY1 );
T2 = Ref(MA(Close ,CY2 ),CY2/2)+ M2*ATR(CY2 );
B2 = Ref(MA( Close ,CY2 ),CY2/2)- M2*ATR(CY2 );

//Plot(T1, "", colorLime);
//Plot(B1, "", colorLime);
//Plot(T2, "", colorRed);
//Plot(B2, "", colorRed);

GraphXSpace = 5;












//////NEW INDICATOR INSERTED BY MOMIN//////

/* Done by Rajandran R */
/* Author of www.marketcalls.in */
/* Code Completion Date : 15th Apr 2013 */


_SECTION_BEGIN("BBand TSL");

SetBarsRequired(100000,0);

GraphXSpace = 15;

SetChartOptions(0,chartShowArrows|chartShowDates);

SetChartBkColor(ParamColor("bkcolor",ColorRGB(0,0, 0)));

GfxSetBkMode(0);

GfxSetOverlayMode(1);

SetBarFillColor(IIf(C>O,ParamColor("Candle UP Color", colorGreen),IIf(C<=O,ParamColor("Candle Down Color", colorRed),colorLightGrey)));

//Plot(C,"\nPrice",IIf(C>O,ParamColor("Wick UP Color", colorDarkGreen),IIf(C<=O,ParamColor("Wick Down Color", colorDarkRed),colorLightGrey)),64,0,0,0,0);



SetTradeDelays(1,1,1,1);


_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

per=Optimize("Period",30, 5,50,1);//per=Optimize("Period",30, 5,50,1);


se = StdErr(C,per);

Bbup = BBandTop(C,per)+se;
Bbdown =BBandBot(C,per)-se;

MoneyRisk = 1;//1.0
iSignal = 1;//1
Line = 1;
Trend=0;//0
TrendUp=Null;
TrendDown=Null;
sig=Null;

g_ibuf_108 = 0;
g_ibuf_112 = 0;
g_ibuf_116 = 0;
g_ibuf_120 = 0;
iUp = Null;
iDown = Null;



for(i=1;i<BarCount-1;i++) {

if (Close > Bbup[i - 1]) Trend = 1;
if (Close < Bbdown[i - 1]) Trend = -1;
if (Trend > 0 && Bbdown < Bbdown[i - 1]) Bbdown = Bbdown[i - 1];
if (Trend < 0 && Bbup > Bbup[i - 1]) Bbup = Bbup[i - 1];
TrendUp = Bbup + (MoneyRisk - 1.0) / 2.0 * (Bbup - Bbdown);
TrendDown = Bbdown - (MoneyRisk - 1.0) / 2.0 * (Bbup - Bbdown);
if (Trend > 0 && TrendDown < TrendDown[i - 1]) TrendDown = TrendDown[i - 1];
if (Trend < 0 && TrendUp > TrendUp[i - 1]) TrendUp = TrendUp[i - 1];
if (Trend > 0) {
if (sig > 0 && g_ibuf_108[i - 1] == -1.0) {
g_ibuf_116 = TrendDown;
g_ibuf_108 = TrendDown;
if (Line > 0) iUp = TrendDown;
} else {
g_ibuf_108 = TrendDown;
if (Line > 0) iUp = TrendDown;
g_ibuf_116 = -1;
}
if (sig == 2) g_ibuf_108 = 0;
g_ibuf_120 = -1;
g_ibuf_112 = -1.0;
iDown = Null;
}
if (Trend < 0) {
if (sig > 0 && g_ibuf_112[i - 1] == -1.0) {
g_ibuf_120 = TrendUp;
g_ibuf_112 = TrendUp;
if (Line > 0) iDown = TrendUp;
} else {
g_ibuf_112 = TrendUp;
if (Line > 0) iDown = TrendUp;
g_ibuf_120 = -1;
}
if (sig == 2) g_ibuf_112 = 0;
g_ibuf_116 = -1;
g_ibuf_108 = -1.0;
iUp = Null;
}
}




Plot(iUp,"iUP",colorGreen,ParamStyle("Style", styleDots | styleNoLine, maskDefault | styleDots | styleNoLine ));

Plot(iDown,"iDown",colorRed,ParamStyle("Style", styleDots | styleNoLine, maskDefault | styleDots | styleNoLine ));


Buy = iUp>0;
Sell= iDown>0;

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);


BuyPrice=ValueWhen(Buy,C);

SellPrice=ValueWhen(Sell,C);

ShortPrice=ValueWhen(Short,C);

CoverPrice=ValueWhen(Cover,C);


Title = EncodeColor(colorWhite)+ "BBand TSL AFL code from www.marketcalls.in" + " - " + Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +

" - " + Date() +" - "+"\n" +EncodeColor(colorRed) +"Op-"+O+" "+"Hi-"+H+" "+"Lo-"+L+" "+

"Cl-"+C+" "+ "Vol= "+ WriteVal(V)+"\n"+

EncodeColor(colorLime)+

WriteIf (Buy , " GO LONG / Reverse sig at "+C+" ","")+

WriteIf (Sell , " EXIT LONG / Reverse sig 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(C>iUp,iUp,iDown);


for(i=BarCount-1;i>1;i--)

{

if(Buy == 1)

{

entry = C;

sig = "BUY";

sl = TrendSL;

STP = C-0.004*BuyPrice;

tar1 = entry + (entry * .0050);

tar2 = entry + (entry * .0078);

tar3 = entry + (entry * .01);



bars = i;

i = 0;

}

if(Sell == 1)

{

sig = "SELL";

entry = C;

sl = TrendSL;

STP = C+0.004*SellPrice;

tar1 = entry - (entry * .0050);

tar2 = entry - (entry * .0078);

tar3 = entry - (entry * .01);


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, 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, STP, BarCount, STP,1), "", colorYellow, styleLine|styleDots, Null, Null, Offset);



//STOPLOSS LINE or trail stop line/////
Plot(LineArray(bars-Offset, sl, BarCount, sl,1), "", colorDarkRed, styleLine|styleLine, Null, Null, Offset);
PlotText(""+sig+"SL Exit@"+sl, BarCount-30, sl,2,Null);


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





for (i=bars; i <BarCount;i++)

{

PlotText(""+sig+"@"+entry, BarCount-5,entry,Null,colorBlue);

//PlotText("T1@"+tar1,BarCount-5,tar1,Null,Clr);PlotText("T2@"+tar2,BarCount-5,tar2,Null,Clr);PlotText ("T3@"+tar3,BarCount-5,tar3,Null,Clr);

}
 
Hi,
KIndly give your suggestion
http://www.traderji.com/software/101822-need-your-help-multitimeframe-5.html#post1161039

values are coming under candle..




Code:
for(i=1; i<=3; i++) {

   TimeframeSet(i * in1Minute);

   bar = C > O ;

  TimeframeRestore();
m = TimeFrameExpand(bar,in1Minute*i);

for(b=1; b<BarCount;, b++)
{
 if(bar[b] == True)
 PlotText(""+(i), b, L[b]-2-(i), colorAqua);

}
}
//PlotShapes(up[i]*shapeCircle,colorRed);
Plot(C, "",colorblack, styleCandle); //For seeing chart

_N(Title = StrFormat("{{NAME}} -"+ EncodeColor(colorBlue)+""+
EncodeColor(colorBlue)+" {{INTERVAL}} "+
EncodeColor(colorWhite)+"{{DATE}} \n Op=> %g, \n Hi=> %g, \n Lo=> %g,
\n Cl=> %g,
 {{V
 

Nehal_s143

Well-Known Member
Please use [ CODE ] afl coding here [ /CODE ] without space for posting afl codes



Please help me, I want Buy/sell exit signal on Target 3 level.

Code:
a=20; //DEFAULT 20//CHANGED BY MOMIN//

_SECTION_BEGIN("HeikenAshiSmoothed");
GraphXSpace=5;
p=40; //DEFAULT 5 final40
Om=DEMA(O,p);
hm=DEMA(H,p);
lm=DEMA(L,p);
Cm=DEMA(C,p);
HACLOSE=(Om+Hm+Lm+Cm)/4;
HaOpen = AMA( Ref( HaClose, 1), 1);
HaHigh = Max( Hm, Max( HaClose, HaOpen ) );
HaLow = Min( Lm, Min( HaClose, HaOpen ) );

slope = Param("slope",2,2,100,1);
Color20= IIf(LinRegSlope(MA(HaClose,a),slope)<0,colorRed,colorGreen);

//Plot(MA(HaClose,a),"", color20,styleThick);

Color=IIf(Haclose>MA(HaClose,a),colorGreen, colorRed);
PlotOHLC( Open, Open, Close, Close, "" + Name(), Color, styleCandle);

//PlotOHLC( Open, Open, Close, Close, "" + Name(), Color,styleCandle);
_SECTION_END();


Buy=Color==colorGreen;
Sell=Color==colorRed;

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

//PlotShapes(IIf(Buy , shapeUpArrow, shapeNone),colorGreen); 
//PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorRed);

//MOMIN//////////////////
_SECTION_BEGIN("Magfied Market Price");
FS=Param("Font Size",30,11,100,1);
GfxSelectFont("Times New Roman", FS, 700, True ); 
GfxSetBkMode( colorWhite );  
GfxSetTextColor( ParamColor("Color",colorYellow) ); 
Hor=Param("Horizontal Position",1480,1,1800,1);
Ver=Param("Vertical Position",12,1,830,1); 
GfxTextOut(""+C, Hor-790 , 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( colorBlack );  
GfxSetTextColor(ParamColor("Color",colorYellow) ); 
GfxTextOut(""+DD+"  ("+xx+"%)", Hor-790 , Ver+45 );
 


/////MOMIN///////

_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
_SECTION_END();

//////MOMIN////////////

_SECTION_END();

CY1 =  Param("Short Cycle Length?" ,80, 1 ,1000 ,1 )/2;//DEFAULT 10 FINAL 20 AND 2
CY2 =  Param("Medium Cycle Length?" ,80, 1 ,1000 ,1 )/2;
M1 =  Param("Short Cycle Multiplyer?" ,1, 0.01 ,10 ,10 );//DEFAULT 10
M2 =  Param("Medium Cycle Multiplyer?" ,3, 0.01 ,10 ,1 );
T1 =  Ref(MA(Close ,CY1 ),CY1/2) -0+M1*ATR(CY1 );//T1 =  Ref(MA(Close ,CY1 ),CY1/2)-2 + M1*ATR(CY1 );
B1 =  Ref(MA( Close ,CY1 ),CY1/2)-0-M1*ATR(CY1 );//B1 =  Ref(MA( Close ,CY1 ),CY1/2)-2 -M1*ATR(CY1 );
T2 =  Ref(MA(Close ,CY2 ),CY2/2)+ M2*ATR(CY2 );
B2 =  Ref(MA( Close ,CY2 ),CY2/2)- M2*ATR(CY2 );

//Plot(T1, "", colorLime);
//Plot(B1, "", colorLime);
//Plot(T2, "", colorRed);
//Plot(B2, "", colorRed);

GraphXSpace = 5;












//////NEW INDICATOR INSERTED BY MOMIN//////

/* Done      by    Rajandran R */
/* Author of [url]www.marketcalls.in[/url]  */
/* Code Completion Date : 15th Apr 2013 */


_SECTION_BEGIN("BBand TSL");

SetBarsRequired(100000,0);

GraphXSpace = 15;

SetChartOptions(0,chartShowArrows|chartShowDates);

SetChartBkColor(ParamColor("bkcolor",ColorRGB(0,0, 0)));

GfxSetBkMode(0); 

GfxSetOverlayMode(1);

SetBarFillColor(IIf(C>O,ParamColor("Candle UP Color", colorGreen),IIf(C<=O,ParamColor("Candle Down Color", colorRed),colorLightGrey)));

//Plot(C,"\nPrice",IIf(C>O,ParamColor("Wick UP Color", colorDarkGreen),IIf(C<=O,ParamColor("Wick Down Color", colorDarkRed),colorLightGrey)),64,0,0,0,0);



SetTradeDelays(1,1,1,1);


_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

per=Optimize("Period",30, 5,50,1);//per=Optimize("Period",30, 5,50,1);


se = StdErr(C,per);

Bbup = BBandTop(C,per)+se;
Bbdown =BBandBot(C,per)-se;

MoneyRisk = 1;//1.0
iSignal = 1;//1
Line = 1;
Trend=0;//0
TrendUp=Null;
TrendDown=Null;
sig=Null;

g_ibuf_108 = 0;
g_ibuf_112 = 0;
g_ibuf_116 = 0;
g_ibuf_120 = 0;
iUp = Null;
iDown = Null;



   for(i=1;i<BarCount-1;i++) {

      if (Close[i] > Bbup[i - 1]) Trend = 1;
      if (Close[i] < Bbdown[i - 1]) Trend = -1;
      if (Trend > 0 && Bbdown[i] < Bbdown[i - 1]) Bbdown[i] = Bbdown[i - 1];
      if (Trend < 0 && Bbup[i] > Bbup[i - 1]) Bbup[i] = Bbup[i - 1];
      TrendUp[i] = Bbup[i] + (MoneyRisk - 1.0) / 2.0 * (Bbup[i] - Bbdown[i]);
      TrendDown[i] = Bbdown[i] - (MoneyRisk - 1.0) / 2.0 * (Bbup[i] - Bbdown[i]);
      if (Trend > 0 && TrendDown[i] < TrendDown[i - 1]) TrendDown[i] = TrendDown[i - 1];
      if (Trend < 0 && TrendUp[i] > TrendUp[i - 1]) TrendUp[i] = TrendUp[i - 1];
      if (Trend > 0) {
         if (sig > 0 && g_ibuf_108[i - 1] == -1.0) {
            g_ibuf_116[i] = TrendDown[i];
            g_ibuf_108[i] = TrendDown[i];
            if (Line > 0) iUp[i] = TrendDown[i];
         } else {
            g_ibuf_108[i] = TrendDown[i];
            if (Line > 0) iUp[i] = TrendDown[i];
            g_ibuf_116[i] = -1;
         }
         if (sig == 2) g_ibuf_108[i] = 0;
         g_ibuf_120[i] = -1;
         g_ibuf_112[i] = -1.0;
         iDown[i] = Null;
      }
      if (Trend < 0) {
         if (sig > 0 && g_ibuf_112[i - 1] == -1.0) {
            g_ibuf_120[i] = TrendUp[i];
            g_ibuf_112[i] = TrendUp[i];
            if (Line > 0) iDown[i] = TrendUp[i];
         } else {
            g_ibuf_112[i] = TrendUp[i];
            if (Line > 0) iDown[i] = TrendUp[i];
            g_ibuf_120[i] = -1;
         }
         if (sig == 2) g_ibuf_112[i] = 0;
         g_ibuf_116[i] = -1;
         g_ibuf_108[i] = -1.0;
         iUp[i] = Null;
      }
   }




Plot(iUp,"iUP",colorGreen,ParamStyle("Style", styleDots | styleNoLine, maskDefault | styleDots | styleNoLine ));

Plot(iDown,"iDown",colorRed,ParamStyle("Style", styleDots | styleNoLine, maskDefault | styleDots | styleNoLine ));


Buy = iUp>0;
Sell= iDown>0;

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);


BuyPrice=ValueWhen(Buy,C);

SellPrice=ValueWhen(Sell,C);

ShortPrice=ValueWhen(Short,C);

CoverPrice=ValueWhen(Cover,C);


Title = EncodeColor(colorWhite)+ "BBand TSL AFL code from www.marketcalls.in" + " - " +  Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +

 "  - " + Date() +" - "+"\n" +EncodeColor(colorRed) +"Op-"+O+"  "+"Hi-"+H+"  "+"Lo-"+L+"  "+

"Cl-"+C+"  "+ "Vol= "+ WriteVal(V)+"\n"+ 

EncodeColor(colorLime)+

WriteIf (Buy , " GO LONG / Reverse sig at "+C+"  ","")+

WriteIf (Sell , " EXIT LONG / Reverse sig 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(C>iUp,iUp,iDown);


for(i=BarCount-1;i>1;i--)

{

if(Buy[i] == 1)

{

entry = C[i];

sig = "BUY";

sl = TrendSL[i];

STP = C[i]-0.004*BuyPrice[i];

tar1 = entry + (entry * .0050);

tar2 = entry + (entry * .0078);

tar3 = entry + (entry * .01);

 

bars = i;

i = 0;

}

if(Sell[i] == 1)

{

sig = "SELL";

entry = C[i];

sl = TrendSL[i];

STP = C[i]+0.004*SellPrice[i];

tar1 = entry - (entry * .0050);

tar2 = entry - (entry * .0078);

tar3 = entry - (entry * .01);


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, 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, STP, BarCount, STP,1), "", colorYellow, styleLine|styleDots, Null, Null, Offset);



//STOPLOSS LINE or trail stop line/////
Plot(LineArray(bars-Offset, sl, BarCount, sl,1), "", colorDarkRed, styleLine|styleLine, Null, Null, Offset);
PlotText(""+sig+"SL Exit@"+sl, BarCount-30, sl,2,Null); 


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



 

for (i=bars; i <BarCount;i++)

{

PlotText(""+sig+"@"+entry, BarCount-5,entry,Null,colorBlue);

//PlotText("T1@"+tar1,BarCount-5,tar1,Null,Clr);PlotText("T2@"+tar2,BarCount-5,tar2,Null,Clr);PlotText ("T3@"+tar3,BarCount-5,tar3,Null,Clr);

}
 

hmp

Well-Known Member
Code:
_SECTION_BEGIN("Trend Identifire"); 
Show_color = ParamToggle("Display CandleColor", "No|Yes", 1); 
r1 = Param( "ColorFast avg", 5, 2, 200, 1 ); 
r2 = Param( "ColorSlow avg", 10, 2, 200, 1 ); 
r3 = Param( "ColorSignal avg", 5, 2, 200, 1 ); 

Prd1=Param("ATR Period",4,1,20,1); 
Prd2=Param("Look Back",7,1,20,1); 
green = HHV(LLV(L,Prd1)+ATR(Prd1),Prd2); 
red = LLV(HHV(H,Prd1)-ATR(Prd1),Prd2); 
flowerClose = EMA((Open+High+Low+Close)/4,3) ; 
flowerOpen = EMA((Ref(Open,-1) + Ref(flowerClose,-1))/2,3); 
Temp = Max(High, flowerOpen); 
flowerHigh = EMA(Max(Temp, flowerClose),3); 
Temp = Min(Low,flowerOpen); 
flowerLow = EMA(Min(Temp, flowerClose),3); 

SetPositionSize (1, spsShares);

m1=MACD(r1,r2); 
s1=Signal(r1,r2,r3); 
mycolor=IIf(m1<0 AND m1>s1, colorBlue,IIf(m1>0 AND 

m1>s1,colorGreen,IIf(m1>0 AND m1<s1,colorPink,colorRed))); 
if(Show_color) 
{ 
ColorHighliter = myColor; 
SetBarFillColor( ColorHighliter ); 
} 

barColor=IIf(C>Green ,colorWhite,IIf(C < RED,colorRed,colorWhite)); 


PlotOHLC( IIf(flowerOpen<flowerClose, flowerOpen, 

flowerClose),flowerHigh,flowerLow,IIf(flowerOpen<flowerClose, flowerClose, 

flowerOpen), "Close", barColor, styleNoTitle | styleCandle); 

_SECTION_END(); 







_SECTION_BEGIN("Bands"); 

SupResB =Param("Sup-Res Short",6,0,100,1); 
nn=SupResB; 



Bandlinecol=ParamColor("SupResLineColor",ColorRGB( 82,82,82)); 
ParmCloud = ParamToggle("Cloud", "No|Yes", 0); 
BoxCloudColor=ParamColor("BoxCloudColor",ColorRGB( 27,27,27)); 


Line2=Param("ResLineLength",100,2,500,0.1); 
Daysback1 = Line2; 
FirstBar1 = BarCount - DaysBack1; 
Hh=HHV(flowerHigh,nn); 
LL=LLV(flowerLow,nn); 

Res2=Hh; 
Sup2=LL; 

BandRes=IIf(BarIndex() >= Firstbar1,EndValue(Res2),Null); 
BandSup=IIf(BarIndex() >= Firstbar1,EndValue(Sup2),Null); 
Plot(BandRes,"",Bandlinecol,ParamStyle("ShortSupBa nd",styleLine|styleDashed|stylehidden|styleNoTitle |styleNoLabel|styleThick,maskAll)); 
Plot(BandSup,"",Bandlinecol,ParamStyle("ShortResBa nd",styleLine|styleDashed|stylehidden|styleNoTitle |styleNoLabel|styleThick,maskAll)); 




CS=BandRes; 
CR=BandSup; 


if(parmCloud == 1) 

PlotOHLC( CS, CS, CR,CR, "Band",BoxCloudColor, styleCloud | styleNoLabel|styleNoTitle); 

_SECTION_END(); 

_SECTION_BEGIN("Breakout"); 
Buyperiods=Param("Breakout periods best is usually 18",5,1,100,1,1); 
Sellperiods=Param("Exit Breakout",5,1,100,1,1); 

HaClose =EMA((O+H+L+C)/4,3); // Woodie 
//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 ) ); 
Buy= C>Ref(HHV(High,Buyperiods),-1) ; 
Sell= C<Ref(LLV(Low,Sellperiods),-1); 

/* exrem is one method to remove surplus strade signals. It removes excessive signals of arrow */ 
Buy = ExRem(Buy, Sell); 
Sell = ExRem(Sell, Buy); 

PlotShapes( IIf( Buy, shapeUpTriangle, shapeNone ), colorGreen, layer = 0,yposition = HaLow, offset = -30); 
//PlotShapes( IIf( Buy, shapeSmallCircle, shapeNone ), colorWhite, layer = 0,yposition = HaLow, offset = -8); 

PlotShapes( IIf( Sell, shapeDownTriangle, shapeNone ), colorRed, layer = 0, yposition = HaHigh, offset = -30); 
//PlotShapes( IIf( Sell, shapeSmallCircle, shapeNone ), colorRed, layer = 0, yposition = HaHigh, offset = -8); 

_SECTION_END(); 


_SECTION_BEGIN("PFE"); 

pds=10; 
x=sqrt((ROC(C,9)*ROC(C,9))+100); 
y=Sum(sqrt((ROC(C,1)* ROC(C,1))+1),pds); 
z=(x/y); 
pfe=EMA(IIf(C>Ref(C,-9),z,-z)*100,5); 

rsidn=pfe <-10 AND pfe<Ref(pfe,-1); 
rsiup=pfe >10 AND pfe>Ref(pfe,-1); 



rsiresult1 = WriteIf( rsiup,"cu", ""); 
rsiresult2 = WriteIf( rsidn,"cd", ""); 




RequestTimedRefresh( 0 ); 
GfxSelectFont( "Tahoma", 12, 120 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorWhite ); 

if ( rsiresult1 =="cu") 
{ 
GfxSelectSolidBrush( ColorRGB(0,90,0) ); 

} 
else 

if ( rsiresult2 =="cd") 

{ 
GfxSelectSolidBrush( ColorRGB(90,0,0)); 

} 

else 

if ( rsiresult2 =="") 

{ 
GfxSelectSolidBrush( colorDarkTeal ); 

} 

GfxSelectFont( "Arial", 10, 100 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorBlue ); 




_SECTION_END(); 





GfxRoundRect( 400,570,210,415, 50, 50 ); 

_SECTION_END(); 




_SECTION_BEGIN("Schaff Trend Cycle"); 
MA1=23; 
MA2=50; 
TCLen=10; 
MA1=Param("ShortMACDLen",23,5,36); 
MA2=Param("LOngMACDLen",50,10,100); 
TCLen=Param("TCLen(StochPeriod)",10,5,20); 
Factor=.5; 

XMac = MACD(MA1,MA2) ; 

Value1 = LLV(XMac, TCLen); 
Value2 = HHV(XMac, TCLen) - Value1; 

frac1=0; 
for (i = 1; i < BarCount; i++) { 
if (Value2[i] > 0) { 
frac1[i] = ((XMac[i] - Value1[i])/Value2[i])*100; 
} 
else { 
frac1[i]= frac1[i-1]; 
} 
} 


PF[0]=frac1[0]; 
PF[1]=frac1[1]; 
for (i = 2; i < BarCount; i++) { 
PF[i]=PF[i-1]+(Factor*(frac1[i]-PF[i-1])); 
} 


Value3 = LLV(PF, TCLen); 
Value4 = HHV(PF, TCLen) - Value3; 

frac2[0]=0; 
for (i = 1; i < BarCount; i++) { 
if (Value4[i] > 0 ) { 
frac2[i]=((PF[i] - Value3[i])/Value4[i])*100; 
} 
else { 
frac2[i]=frac2[i-1]; 
} 
} 

PFF[0]=frac2[0]; 
PFF[1]=frac2[1]; 
for (i = 2; i < BarCount; i++) { 
PFF[i]=PFF[i-1]+(Factor*(frac2[i]-PFF[i-1])); 
} 


rsidn=pff <2; 
rsiup=pff >98; 


rsiresult1 = WriteIf( rsiup,"cu", ""); 
rsiresult2 = WriteIf( rsidn,"cd", ""); 




RequestTimedRefresh( 0 ); 
GfxSelectFont( "Tahoma", 12, 120 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorWhite ); 

if ( rsiresult1 =="cu") 
{ 
GfxSelectSolidBrush( ColorRGB(0,120,0) ); 

} 
else 

if ( rsiresult2 =="cd") 

{ 
GfxSelectSolidBrush( ColorRGB(120,0,0)); 

} 

else 

if ( rsiresult2 =="") 

{ 
GfxSelectSolidBrush( colorDarkTeal ); 

} 

GfxSelectFont( "Arial", 10, 100 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorBlue ); 
GfxRoundRect( 390,560,220,425, 50, 50 ); 

_SECTION_END(); 


_SECTION_BEGIN("rsi"); 

//HT=ParamColor("HT", colorRed ); 

rsidn=RSI(7) <30; 
rsiup=RSI(7) >70; 


rsiresult1 = WriteIf( rsiup,"cu", ""); 
rsiresult2 = WriteIf( rsidn,"cd", ""); 




RequestTimedRefresh( 0 ); 
GfxSelectFont( "Tahoma", 12, 120 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorWhite ); 

if ( rsiresult1 =="cu") 
{ 
GfxSelectSolidBrush( ColorRGB(0,150,0) ); 

} 
else 

if ( rsiresult2 =="cd") 

{ 
GfxSelectSolidBrush( ColorRGB(150,0,0)); 

} 

else 

if ( rsiresult2 =="") 

{ 
GfxSelectSolidBrush( colorDarkTeal ); 

} 

GfxSelectFont( "Arial", 10, 100 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorBlue ); 

GfxRoundRect( 380,550,230,435, 50, 50 ); 

_SECTION_END(); 








_SECTION_BEGIN("Rays"); 


Pp1=3; 
Pp2=2; 

CS33=HHV(LLV(flowerHigh,Pp1)-ATR(Pp2),4); 
CR33=HHV(LLV(flowerHigh,Pp1)-ATR(Pp2),5); 

AtrupTrendCond1 = flowerClose> CS33 ; 
AtrdnTrendCond1 =CS33>flowerClose ; 


ATRup = WriteIf(AtrupTrendCond1,"atrup", ""); 
ATRdown= WriteIf( AtrdnTrendCond1,"atrdn", ""); 

if ( ATRup =="atrup") 
{ 
GfxSelectSolidBrush( ColorRGB(0,180,0) ); 

} 
else 

if (ATRdown =="atrdn") 

{ 
GfxSelectSolidBrush( ColorRGB(180,0,0)); 

} 

else 

if ( ATRdown =="") 

{ 
GfxSelectSolidBrush( colorDarkTeal ); 

} 

GfxSelectFont( "Arial", 10, 100 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorBlue ); 

GfxSelectPen( colorBlue, 1 ); // broader color 
GfxRoundRect( 370,540,240,445, 50, 50 ); 




_SECTION_END(); 


_SECTION_BEGIN("Exit_Beast-3"); 



EntrylookbackPeriod=10; 
EntryATRperiod=1.9; 
EntrySig = C > ( LLV( flowerLow, EntrylookbackPeriod ) + EntryATRperiod * ATR( 10 ) ); 
ExitSig = C < ( HHV( flowerHigh, EntrylookbackPeriod ) -EntryATRperiod * ATR( 10 ) ); 


RequestTimedRefresh( 0 ); 
GfxSelectFont( "Tahoma", 12, 100 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorWhite ); 

EntryB = WriteIf( EntrySig,"eu", ""); 
ExitB = WriteIf( ExitSig,"ed", ""); 

if ( EntryB =="eu") 
{ 
GfxSelectSolidBrush( ColorRGB(0,210,0) ); // 

} 
else 

if ( ExitB =="ed") 

{ 
GfxSelectSolidBrush( ColorRGB(210,0,0)); // 

} 

else 

if ( ExitB =="") 

{ 
GfxSelectSolidBrush( colorDarkTeal ); 

} 

GfxSelectFont( "Arial", 10, 100 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorBlue ); 

GfxSelectPen( colorBlue, 1 ); // broader color 
GfxRoundRect( 360,530,250,455, 50, 50 ); 



_SECTION_END(); 



_SECTION_BEGIN("CCI9-2"); 


ccidn=CCI(8) < 0; 
cciup=CCI(9) > 0; 


ccresult1 = WriteIf( cciup,"cu", ""); 
ccresult2 = WriteIf( ccidn,"cd", ""); 




RequestTimedRefresh( 0 ); 
GfxSelectFont( "Tahoma", 12, 100 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorWhite ); 

if ( ccresult1 =="cu") 
{ 
GfxSelectSolidBrush( ColorRGB(0,240,0) ); 

} 
else 

if ( ccresult2 =="cd") 

{ 
GfxSelectSolidBrush( ColorRGB(240,0,0)); 

} 

else 

if ( ccresult2 =="") 

{ 
GfxSelectSolidBrush( colorDarkTeal ); 

} 

GfxSelectFont( "Arial", 10, 100 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorBlue ); 

GfxSelectPen( colorBlue, 1 ); // broader color 
GfxRoundRect( 350,520,260,465, 50, 50 ); 








_SECTION_END(); 




_SECTION_BEGIN("%BB7-1"); 

p=7; 
x=((C+2*StDev(C,p)-MA(C,p))/(4*StDev(C,p)))*100; 
bbdown= x < 40; 
bbup= x > 40; 

bbresult1 = WriteIf( bbup,"bu", ""); 
bbresult2 = WriteIf( bbdown,"bd", ""); 
bbresult3 = WriteIf( C,"bearishrevers", ""); 



RequestTimedRefresh( 0 ); 
GfxSelectFont( "Tahoma", 12, 100 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorWhite ); 

if ( bbresult1 =="bu") 
{ 
GfxSelectSolidBrush( ColorRGB(62,255,62) ); 

} 
else 

if ( bbresult2 =="bd") 

{ 
GfxSelectSolidBrush( ColorRGB(255,62,62) ); 

} 

else 

if ( bbresult2 =="") 

{ 
GfxSelectSolidBrush( colorDarkTeal ); 

} 

GfxSelectFont( "Arial", 10, 100 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorBlue ); 

GfxSelectPen( colorBlue, 1 ); // broader color 

GfxRoundRect( 340,510,270,475, 50, 50 ); 


_SECTION_END(); 




x = 300; 
x2 = 200; 

y = Status( "pxchartheight" ); 
GfxSelectSolidBrush( colorBlue ); 
GfxSelectPen( colorWhite, 1); // broader color 
GfxRoundRect( 535, y - 80, 430,y ,7 , 7 ) ; 



_SECTION_BEGIN("MACDHIGHBULLISH"); 
r1 = Param( "Fast avg", 12, 2, 200, 1 ); 
r2 = Param( "Slow avg", 26, 2, 200, 1 ); 
r3 = Param( "Signal avg", 9, 2, 200, 1 ); 
r4 = Param( "Wk slow", 17, 2, 200, 1 ); 
r5 = Param( "Wk fast", 8, 2, 200, 1 ); 
m1=MACD(r1,r2); 
s1=Signal(r1,r2,r3); 





rsidn=m1>0 AND m1>s1; 
rsiresult2 = WriteIf( rsidn,"cd", ""); 
if ( rsiresult2 =="cd") 

{ 
GfxSelectSolidBrush( ColorRGB(0,147,0)); 

} 

else 

if ( rsiresult2 =="") 

{ 
GfxSelectSolidBrush( colorDarkTeal ); 

} 
RequestTimedRefresh( 0 ); 
GfxSelectFont( "Arial", 10, 100 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorBlue ); 

GfxSelectPen( colorBlue, 1 ); 
// broader color 
GfxCircle( 445,550,10 ); 

_SECTION_END(); 


rsidn=m1<0 AND m1>s1; 
rsiresult2 = WriteIf( rsidn,"cd", ""); 
if ( rsiresult2 =="cd") 

{ 
GfxSelectSolidBrush( ColorRGB(0,147,0)); 

} 

else 

if ( rsiresult2 =="") 

{ 
GfxSelectSolidBrush( colorDarkTeal ); 

} 
RequestTimedRefresh( 0 ); 
GfxSelectFont( "Arial", 10, 100 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorBlue ); 

GfxSelectPen( colorBlue, 1 ); 
// broader color 

GfxCircle( 470,550,10 ); 

_SECTION_END(); 

_SECTION_BEGIN("MACDLOWHBEARISH"); 
r1 = Param( "Fast avg", 12, 2, 200, 1 ); 
r2 = Param( "Slow avg", 26, 2, 200, 1 ); 
r3 = Param( "Signal avg", 9, 2, 200, 1 ); 
r4 = Param( "Wk slow", 17, 2, 200, 1 ); 
r5 = Param( "Wk fast", 8, 2, 200, 1 ); 
m1=MACD(r1,r2); 
s1=Signal(r1,r2,r3); 





rsidn=m1>0 AND m1<s1; 
rsiresult2 = WriteIf( rsidn,"cd", ""); 
if ( rsiresult2 =="cd") 

{ 
GfxSelectSolidBrush( ColorRGB(225,0,0)); 

} 

else 

if ( rsiresult2 =="") 

{ 
GfxSelectSolidBrush( colorDarkTeal ); 

} 
RequestTimedRefresh( 0 ); 
GfxSelectFont( "Arial", 10, 100 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorBlue ); 

GfxSelectPen( colorBlue, 1 ); 
// broader color 

GfxCircle(495,550,10); 

_SECTION_END(); 

_SECTION_BEGIN("MACDHIGHHBEARISH"); 
r1 = Param( "Fast avg", 12, 2, 200, 1 ); 
r2 = Param( "Slow avg", 26, 2, 200, 1 ); 
r3 = Param( "Signal avg", 9, 2, 200, 1 ); 
r4 = Param( "Wk slow", 17, 2, 200, 1 ); 
r5 = Param( "Wk fast", 8, 2, 200, 1 ); 
m1=MACD(r1,r2); 
s1=Signal(r1,r2,r3); 
rsidn=m1<0 AND m1<s1; 
rsiresult2 = WriteIf( rsidn,"cd", ""); 
if ( rsiresult2 =="cd") 
{ 
GfxSelectSolidBrush( ColorRGB(225,0,0)); 
} 

else 

if ( rsiresult2 =="") 

{ 
GfxSelectSolidBrush( colorDarkTeal ); 

} 
RequestTimedRefresh( 0 ); 
GfxSelectFont( "Arial", 10, 100 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorBlue ); 

GfxSelectPen( colorBlue, 1 ); 
// broader color 

GfxCircle( 520,550,10 ); 

_SECTION_END(); 


_SECTION_BEGIN("Average 0"); 
P = HaClose; 
Type = ParamList("Type", "Weighted,Lagless-21,Hull-26,Linear 
Regression-45,Exponential,Double Exponential,Tripple 
Exponential,Wilders,Simple"); 
Periods = Param("Periods", 20, 2, 200 ); 
Displacement = Param("Displacement", 1, -50, 50 ); 
m = 0; 

if( Type == "Weighted" ) m= WMA( P, Periods ); 
if( Type == "Lagless-21" ) m= 2*EMA(P, Periods)-EMA(EMA(P, Periods), Periods); 
if( Type == "Hull-26" ) m= WMA(2*(WMA(P, Periods/2))-WMA(P, Periods) ,4 ); 
if( Type == "Linear Regression-45" ) m= LinearReg( P, Periods ); 
if( Type == "Exponential" ) m = EMA( P, Periods ); 
if( Type == "Double Exponential" ) m = DEMA( P, Periods ); 
if( Type == "Tripple Exponential" ) m = TEMA( P, Periods ); 
if( Type == "Wilders" ) m = Wilders( P, Periods ); 
if( Type == "Simple" ) m = MA( P, Periods ); 

_SECTION_END(); 


_SECTION_BEGIN("Average 1"); 
//Average_switch = ParamToggle("Candle On/off", "Off|On"); 
P = HaClose; 
Type = ParamList("Type", "Weighted,Lagless-21,Hull-26,Linear 
Regression-45,Exponential,Double Exponential,Tripple 
Exponential,Wilders,Simple"); 
Periods = Param("Periods", 60, 2, 200 ); 
Displacement = Param("Displacement", 1, -50, 50 ); 
m = 0; 

if( Type == "Weighted" ) m= WMA( P, Periods ); 
if( Type == "Lagless-21" ) m= 2*EMA(P, Periods)-EMA(EMA(P, Periods), Periods); 
if( Type == "Hull-26" ) m= WMA(2*(WMA(P, Periods/2))-WMA(P, Periods) ,4 ); 
if( Type == "Linear Regression-45" ) m= LinearReg( P, Periods ); 
if( Type == "Exponential" ) m = EMA( P, Periods ); 
if( Type == "Double Exponential" ) m = DEMA( P, Periods ); 
if( Type == "Tripple Exponential" ) m = TEMA( P, Periods ); 
if( Type == "Wilders" ) m = Wilders( P, Periods ); 
if( Type == "Simple" ) m = MA( P, Periods ); 

_SECTION_END(); 

_SECTION_BEGIN("Average 5"); 
P = HaClose; 
Type = ParamList("Type", "Weighted,Lagless-21,Hull-26,Linear 
Regression-45,Exponential,Double Exponential,Tripple 
Exponential,Wilders,Simple"); 
Periods = Param("Periods", 120 ,2, 200 ); 
Displacement = Param("Displacement", 1, -50, 50 ); 
m = 0; 

if( Type == "Weighted" ) m= WMA( P, Periods ); 
if( Type == "Lagless-21" ) m= 2*EMA(P, Periods)-EMA(EMA(P, Periods), Periods); 
if( Type == "Hull-26" ) m= WMA(2*(WMA(P, Periods/2))-WMA(P, Periods) ,4 ); 
if( Type == "Linear Regression-45" ) m= LinearReg( P, Periods ); 
if( Type == "Exponential" ) m = EMA( P, Periods ); 
if( Type == "Double Exponential" ) m = DEMA( P, Periods ); 
if( Type == "Tripple Exponential" ) m = TEMA( P, Periods ); 
if( Type == "Wilders" ) m = Wilders( P, Periods ); 
if( Type == "Simple" ) m = MA( P, Periods ); 
_SECTION_END(); 


_SECTION_BEGIN("Sell Average 3"); 
P = HaClose; 
Type = ParamList("Type", "Weighted,Lagless-21,Hull-26,Linear 
Regression-45,Exponential,Double Exponential,Tripple 
Exponential,Wilders,Simple"); 
Periods = Param("Periods", 180, 2, 800 ); 
Displacement = Param("Displacement", 1, -50, 50 ); 
m = 0; 

if( Type == "Weighted" ) m= WMA( P, Periods ); 
if( Type == "Lagless-21" ) m= 2*EMA(P, Periods)-EMA(EMA(P, Periods), Periods); 
if( Type == "Hull-26" ) m= WMA(2*(WMA(P, Periods/2))-WMA(P, Periods) ,4 ); 
if( Type == "Linear Regression-45" ) m= LinearReg( P, Periods ); 
if( Type == "Exponential" ) m = EMA( P, Periods ); 
if( Type == "Double Exponential" ) m = DEMA( P, Periods ); 
if( Type == "Tripple Exponential" ) m = TEMA( P, Periods ); 
if( Type == "Wilders" ) m = Wilders( P, Periods ); 
if( Type == "Simple" ) m = MA( P, Periods ); 
_SECTION_END(); 


_SECTION_BEGIN("traing sl"); 

function vstop_func(trBull,trBear) 
{ 
trailArray[ 0 ] = C[ 0 ]; // initialize 
for( i = 1; i < BarCount; i++ ) 
{ 
prev = trailArray[ i - 1 ]; 

if (C[ i ] > prev AND C[ i - 1 ] > prev) 
{ 
trailArray[ i ] = Max(prev,C[ i ] - trBull[ i ]); 
} 
else if (C[ i ] < prev AND C[ i - 1 ] < prev) 
{ 
trailArray[ i ] = Min(prev,C[ i ] + trBear[ i ]); 
} 
else if (C[ i ] > prev) 
{ 
trailArray[ i ] = C[ i ] - trBull[ i ]; 
} 
else 
{ 
trailArray[ i ] = C[ i ] + trBear[ i ];	
} 
} 
return trailArray; 
} 

per = Param("per",20, 1, 150, 1); 
multBull = Param("multBull",2, 1, 4, 0.05); 
multBear = Param("multBear",2, 1, 4, 0.05); 

trBull = multBull * ATR(per); 
trBear = multBear * ATR(per); 

trailArray = vstop_func(trBull,trBear); 
s0=trailArray; 

s1= s0 > C ; 
s2= s0 <C ; 
ccresult1 = WriteIf( s1,"cu", ""); 
ccresult2 = WriteIf( s2,"cd", ""); 

GfxSelectFont("arial", 13, 700 ); GfxSetBkMode( colorRed); 
GfxSetTextColor( ParamColor("Color",colorRed) ); 
Hor=Param("Horizontal Position",30,10,1200,1); 
Ver=Param("Vertical Position",185,100,50,50); 



_SECTION_END(); 

_SECTION_BEGIN("traing s2"); 

s0=trailArray; 

s1= s0 > C ; 
s2= s0 <C ; 
ccresult1 = WriteIf( s1,"cu", ""); 
ccresult2 = WriteIf( s2,"cd", ""); 



_SECTION_END(); 


_SECTION_BEGIN("buycircle"); 
GfxSelectFont( "Arial", 10, 100 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorBlue ); 
GfxSelectPen( colorBlue, 1 ); 
if ( ccresult2 =="cd") 
{ 
GfxSelectSolidBrush( ColorRGB(0,255,0) ); 
} 
else 
{ 
GfxSelectSolidBrush( ColorRGB(0,0,94) ); 
} 

GfxCircle( 455,510,20 ); 

_SECTION_END(); 
_SECTION_BEGIN("sellcircle"); 
GfxSelectFont( "Arial", 10, 100 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorBlue ); 
GfxSelectPen( colorBlue, 1 ); 
if ( ccresult1 =="cu") 
{ 
GfxSelectSolidBrush( ColorRGB(255,0,0) ); 
} 
else 
{ 
GfxSelectSolidBrush( ColorRGB(0,0,94) ); 
} 

GfxCircle( 510,510,20 ); 
_SECTION_END(); 
_SECTION_BEGIN("ema_crossover"); 
Plot(EMA(Close,10),"",colorOrange,styleLine ); 
Plot(EMA(Close,20),"",colorBlueGrey,styleLine); 
Plot(EMA(Close,30),"",colorTeal,styleLine); 
_SECTION_END(); 








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

for ( i = 0; i < BarCount; i++ ) 
{ 
if ( HH[i] ) 
PlotText( "H TOP ", i, H[ i ] + dist[i], colorYellow ); 

if ( LH[i] ) 
PlotText( "L TOP", i, H[ i ] + dist[i], colorYellow ); 

if ( HL[i] ) 
PlotText( "H Bottom", i, L[ i ] - dist[i], colorYellow ); 

if ( LL[i] ) 
PlotText( "L Bottom", i, L[ i ] - dist[i], colorYellow ); 

} 































_SECTION_BEGIN("Magnified Market Price"); 
FS=Param("Font Size",30,30,100,1); 
GfxSelectFont("Arial", FS, 700, italic = False, underline = False, True ); 
GfxSetBkMode( colorWhite ); 
GfxSetTextColor( ParamColor("Color",colorWhite) ); 
Hor=Param("Horizontal Position",350,800,800,800); 
Ver=Param("Vertical Position",50,27,27,27); 
GfxTextOut(""+C,Hor+250 , Ver-53 ); 
YC=TimeFrameGetPrice("C",inDaily,-1); 
DD=Prec(C-YC,2); 
xx=Prec((DD/YC)*100,2); 
GfxSelectFont("Arial", 12, 700, italic = False, underline = False, True ); 
GfxSetBkMode( colorWhite ); 
GfxSetTextColor(ParamColor("Color",colorYellow) ); 
GfxTextOut(""+DD+" ("+xx+"%)", Hor+250, Ver-1 ); 
_SECTION_END(); 

_SECTION_BEGIN("Right 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(); 


_SECTION_BEGIN("trending ribbon"); 
uptrend=PDI()>MDI()AND Signal()<MACD(); 
downtrend=MDI()>PDI()AND Signal()>MACD(); 



_SECTION_END(); 


_SECTION_BEGIN("Swing"); 

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(); 



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



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); 

dist =0.5* ATR(10); 
dist1 = 2*ATR(10); 
for (i=0; i<BarCount; i++) { 
if ( Buy[i] ) 
PlotText("Buy:" + H[ i ], i, H[ i ]-3*dist[i], colorGreen); 

if ( Sell[i] ) 
PlotText("Sell:" + L[ i ], i, L[ i ]+3*dist[i], colorRed); 
} 

AlertIf( Buy, "", "BUY @ " + H, 1 ); 
AlertIf( Sell, "", "SELL @ " + L, 2 ); 
AlertIf( Buy, "EMAIL", "A sample alert on "+FullName(), 1 ); 
AlertIf( Sell, "EMAIL", "A sample alert on "+FullName(), 2 ); 
_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(sloss,"Swing",colorYellow,styleStaircase); 

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

//ParamColor("BgBottom", ColorRGB( 172,172,172 )),ParamColor("titleblock",ColorRGB( 172,172,172 ))); 
//Alerts 


GraphXSpace = 5; 

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

SetChartBkColor(colorBlack); 
SetChartOptions(0,chartShowArrows|chartShowDates); 

/* -------------------------------------------------------------------------------------- */ 
//////////////////////////////////////////////////////////////////////////////////////////////// 
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",colorYellow,styleLine |styleDashed|styleThick); 
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 @ " + H, 1 ); 
AlertIf( Sell, "", "SELL @ " + L, 2 ); 

for (i=BarCount-1; i>1; i--) { 
if (Buy[i] == 1) { 
entry =H[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 = L[i]; 
sl = sloss[i]; 
tar1 = entry - (entry * .0050); 
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)); 





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



_SECTION_END(); 

_SECTION_BEGIN("EMA1"); 
P = ParamField("Price field",-1); 
Periods = Param("Periods", 15, 2, 300, 1, 10 ); 
Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") ); 
_SECTION_END(); 

_SECTION_BEGIN("ATP"); 

B=Volume; 
A=Avg; 
Value=B*A; 
Barsfromtodaybegin = 1 + BarsSince( Day() != Ref(Day(), -1)); 
Totalvalue=Sum(Value,Barsfromtodaybegin); 
Totalvolume=Sum(V,Barsfromtodaybegin); 
ATP=(Totalvalue/Totalvolume); 
ColorATP=IIf(ATP>Ref(ATP,-1),colorBrightGreen,colorRed); 
Plot(ATP,"ATP",colorATP,styleThick); 
_SECTION_END(); 

a=20; 
GraphXSpace=5; 
p=30; 
p = Param("p",30,2,100,1); 

Om=DEMA(O,p); 
hm=DEMA(H,p); 
lm=DEMA(L,p); 
Cm=DEMA(C,p); 
HACLOSE=(Om+Hm+Lm+Cm)/4; 
HaOpen = AMA( Ref( HaClose, -1), 1); 
HaHigh = Max( Hm, Max( HaClose, HaOpen ) ); 
HaLow = Min( Lm, Min( HaClose, HaOpen ) ); 

slope = Param("slope",2,2,100,1); 

Color20= IIf(LinRegSlope(MA(HaClose,a),slope)<0,colorRed,colorGreen); 
Plot(MA(HaClose,a),"", color20,styleThick); 

Color=IIf(Haclose>MA(HaClose,a),colorGreen, colorRed); 
//PlotOHLC( HaOpen, HaOpen, HaClose, HaClose, "" + Name(), Color, styleCandle); 
_SECTION_END(); 

_SECTION_BEGIN("Priyanvada's Price Action"); 
P = ParamField( "Price field" ); 
CandleT=ParamToggle("Candlestick Display","No|Yes",defaultval=1 ); 
BarT=ParamToggle("Bar Display","No|Yes",defaultval=0 ); 
LineT=ParamToggle("Line Display","No|Yes",defaultval=0 ); 
//T3MA toggle 
T3MAT=ParamToggle("Moving Average","No|Yes",defaultval=1 ); 
//T3MA Check Periods 
T3MAP = Param("T3MA Periods", 46, 2, 300, 1, 10 ); 

function T3(price,periods) 
{ 
s = 0.84; 
e1=EMA(price,periods); 
e2=EMA(e1,Periods); 
e3=EMA(e2,Periods); 
e4=EMA(e3,Periods); 
e5=EMA(e4,Periods); 
e6=EMA(e5,Periods); 
c1=-s*s*s; 
c2=3*s*s+3*s*s*s; 
c3=-6*s*s-3*s-3*s*s*s; 
c4=1+3*s+s*s*s+3*s*s; 
Ti3=c1*e6+c2*e5+c3*e4+c4*e3; 
return ti3; 
} 
T3MA = T3(P,T3MAP); 
for( i = 1; i < BarCount; i++ ) 
{ 
//assignments 
NvadaOpen[i] = Close[i-1]; 
NvadaClose[i]=Close[i]; 
NvadaHigh[i]=IIf(NvadaOpen[i]>=NvadaClose[i],NvadaOpen[i],NvadaClose[i]); 
NvadaLow[i]=IIf(NvadaOpen[i]>=NvadaClose[i],NvadaClose[i],NvadaOpen[i]); 
averagechange[i]=(NvadaOpen[i]+NvadaClose[i])/2; 

//============================= 
//CHECKS 

//check1= uptrend and upbar as referred for last 2 bars 
Check1[i]=averagechange[i]>T3MA[i] AND NvadaClose[i]>=NvadaOpen[i-2]; 
//check2= uptrend and downbar as referred for last 2 bars 
Check2[i]=averagechange[i]>T3MA[i] AND NvadaClose[i]<NvadaOpen[i-2]; 

//check3= downtrend and downbar as referred for last 2 bars 
Check3[i]=averagechange[i]<T3MA[i] AND NvadaClose[i]<=NvadaOpen[i-2]; 
//check4= downtrend and upbar as referred for last 2 bars 
Check4[i]=averagechange[i]<T3MA[i] AND NvadaClose[i]>NvadaOpen[i-2]; 

//check5=check2 or check 4 => possible corrections! 
Check5[i]=Check2[i] OR Check4[i]; 

//Color assignment 
if(Check1[i]==1){pricolor[i] =colorGreen;} 
if(Check3[i]==1){pricolor[i] =colorRed;} 
if(Check5[i]==1){pricolor[i] =colorYellow;} 
//Pricolor = IIf(NvadaClose>Ref(NvadaOpen,-2),colorGreen,colorRed); 
} 



//T3MA Display 
if(T3MAT==1) 
{ 
T3MAcolor = IIf(C>=T3MA,colorGreen,colorRed); 
//Plot(T3MA,"T3MA",T3MAcolor,styleThick); 
} 
Buy=T3MAcolor==colorGreen; 
Sell=T3MAcolor==colorRed; 
Short=Sell; 
Cover=Buy; 

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

Buy=ExRem(Buy,Sell); 
Sell=ExRem(Sell,Buy); 
//PlotShapes(IIf(Buy , shapeUpArrow, shapeNone),colorWhite); 
//PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorYellow); 
no=Param( "Swing", 12, 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); 


//Plot(tsl, _DEFAULT_NAME(), tsl_col, styleStaircase); 




SetPositionSize(300,spsShares); 
ApplyStop(0,1,10,1); 
//-----------end-------------- 
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)+"","")); 
_SECTION_END(); 


H1 = SelectedValue( TimeFrameGetPrice( "H", inDaily, -1 ) ); 
L1 = SelectedValue( TimeFrameGetPrice( "L", inDaily, -1 ) ); 
C1 = SelectedValue( TimeFrameGetPrice( "C", inDaily, -1 ) ); 
H2 = SelectedValue( TimeFrameGetPrice( "H", inDaily, 0 ) ); 
L2 = SelectedValue( TimeFrameGetPrice( "L", inDaily, 0 ) ); 
O1 = SelectedValue( TimeFrameGetPrice( "open", inDaily, 0 ) ); 
F4 = 0; 
D1 = ( H1 - L1 ); 
D2 = ( H2 - L2 ); 
F1 = D1 * 0.433; 
F2 = D1 * 0.766; 
F3 = D1 * 1.35; 
if ( D2 <= F1 ) 
F4 = F1; 
else 
if ( D2 <= F2 ) 
F4 = F2; 
else 
F4 = F3; 

S_P = ( O1 - F4 ); 

B_P = ( O1 + F4 ); 

BP = ( L2 + F4 ); 

BPTGT = ( BP + ( BP * .0065 ) );//.0015 brokerage 

BPSTPLS = ( BP - ( BP * .0085 ) ); 

SP = ( H2 - F4 ); 

SPTGT = ( SP - ( SP * .0065 ) ); 

SPSTPLS = ( SP + ( SP * .0085 ) ); 


p = ( H1 + L1 + C1 ) / 3; 

s1 = ( H1 ); 

r1 = ( L1 ); 

r2 = SelectedValue( L2 ); 

s2 = SelectedValue( H2 ); 
Filter = Buy OR Sell; 

AddColumn( IIf( Buy, 66, 1 ), "Buy", formatChar, 1, bkcolor = IIf( Buy, 43, 33 ) ); 

AddColumn( IIf( Sell, 83, 1 ), "Sell", formatChar, 1, bkcolor = IIf( Sell, 25, 32 ) ); 

AddColumn( IIf( Short, 83, 1 ), "Short", formatChar, 1, bkcolor = IIf( Short, 25, 32 ) ); 

AddColumn( C, "CMP", 1.2, colorDefault, colorLightBlue ); 

AddColumn( BP, "SELL PRICE", 1.2, colorDefault, colorGreen ); 

AddColumn( BPTGT, "TGT PRICE", 1.2, colorDefault, colorBrown ); 

AddColumn( BPSTPLS, "STPLS BUY", 1.2, colorDefault, colorRed ); 

AddColumn( p, "PIVOT", 1.2, colorDefault, colorYellow ); 

AddColumn( SPSTPLS, "STPLS SELL", 1.2, colorDefault, colorRed ); 

AddColumn( SP, "SELL PRICE", 1.2, colorDefault, colorGreen ); 

AddColumn( SPTGT, "TGT PRICE", 1.2, colorDefault, colorBrown ); 


AddColumn( H1, "PRE-HIGH" ); 

AddColumn( L1, "PRE-LOW" ); 

AddColumn( D1, "PRE-DIFF" ); 

AddColumn( F1, "0.433" ); 

AddColumn( F2, "0.766" ); 

AddColumn( F3, "1.35" ); 

AddColumn( H2, "D-HIGH" ); 

AddColumn( L2, "D-LOW" ); 

AddColumn( D2, "D-DIFF" ); 

AddColumn( F4, "SELECT FACT" ); 
_SECTION_END(); 
//============== TITLE ============== 
_SECTION_BEGIN("Title"); 
if( Status("action") == actionIndicator ) 
( 
Title = EncodeColor(colorGold)+ "K T S" + EncodeColor(colorRose)+" (" + Name() + ") " + EncodeColor(colorGold)+ Interval(2) + 
" " + Date() +" " +" Open "+WriteVal(O,1.000)+" "+"Hi "+WriteVal(H,1.000)+" "+"Lo "+WriteVal(L,1.000)+" "+ 
"Close "+WriteVal(C,1.000)+" ("+WriteVal(C-Ref(C,-1),1,0)+" "+WriteVal((C-Ref(C,-1))*100/Ref(C,-1),1.1)+ "%) Vol= "+ WriteVal(V,1.0) 



+"\n"+EncodeColor(colorGrey50)+"------------------------------------------------------------------------------------------------------------" 

+"\n"+EncodeColor(colorGold)+ 
WriteIf (Buy , "Signal: Go Long - Entry Price: "+WriteVal(C)+" - Traget: "+WriteVal((BuyPrice+tsl)+BuyPrice) 
+" - StopLoss:"+WriteVal(tsl)+" " 
,"")+ 


WriteIf (Sell , "Signal: Go Short - Entry Price: "+WriteVal(C)+" - Target: "+WriteVal((tsl-SellPrice)-SellPrice)+" - StopLoss:"+WriteVal(tsl)+" ","")+ 
EncodeColor(ColorRGB(111,208,255))+ 
WriteIf(Long AND NOT Buy, "Trade: Long - Entry Price: "+WriteVal((H))+" - Profit: "+WriteVal((C-BuyPrice))+" "+EncodeColor(colorLime)+"Let your profit runs!","")+ 
WriteIf(shrt AND NOT Sell, "Trade: Short - Entry Price: "+WriteVal((L))+" - Profit: "+WriteVal((SellPrice-C))+" - "+EncodeColor(colorLime)+"Let your profit runs!","")

+"\n"+EncodeColor(colorGrey50)+"------------------------------------------------------------------------------------------------------------" 
); 

dist = 6*ATR(10); 
dist1 = 6*ATR(10); 
for( i = 0; i < BarCount; i++) 
{ 
if( Buy[i] ) 
{ 
//PlotText( "Buy:" + C[ i ] + "\nT= " + tsl[i] + "\nSL= " +((C[i]-tsl[i])+C[i]) , i, C[ i ]-dist[i], colorGreen, colorDarkOliveGreen ); 
} 
if( Sell[i] ) 
{ 
//PlotText( "Sell:" + C[ i ] + "\nT= " + (C[i]-(tsl[i]-C[i])) + "\nSL= " +tsl[i], i, C[ i ]+dist1[i], colorRed, colorDarkOliveGreen ); 
} 
} 




/*Plot Ribbon */ 
Ribbon1=IIf( (C) >(tsl) ,colorGreen, IIf(( tsl )>( C ), colorRed,colorBlack)); 
Plot(3, "Ribbon", Ribbon1, styleOwnScale| styleArea| styleNoLabel,-0.5,100); 

_SECTION_END();
Hi all
In above afl it explores/scan stocks for intraday only.Pl. anyone can make it scan for daily also?
Thanks & regards
 

amitrandive

Well-Known Member
Code:
_SECTION_BEGIN("Trend Identifire"); 
Show_color = ParamToggle("Display CandleColor", "No|Yes", 1); 
r1 = Param( "ColorFast avg", 5, 2, 200, 1 ); 
r2 = Param( "ColorSlow avg", 10, 2, 200, 1 ); 
r3 = Param( "ColorSignal avg", 5, 2, 200, 1 ); 

Prd1=Param("ATR Period",4,1,20,1); 
Prd2=Param("Look Back",7,1,20,1); 
green = HHV(LLV(L,Prd1)+ATR(Prd1),Prd2); 
red = LLV(HHV(H,Prd1)-ATR(Prd1),Prd2); 
flowerClose = EMA((Open+High+Low+Close)/4,3) ; 
flowerOpen = EMA((Ref(Open,-1) + Ref(flowerClose,-1))/2,3); 
Temp = Max(High, flowerOpen); 
flowerHigh = EMA(Max(Temp, flowerClose),3); 
Temp = Min(Low,flowerOpen); 
flowerLow = EMA(Min(Temp, flowerClose),3); 

SetPositionSize (1, spsShares);

m1=MACD(r1,r2); 
s1=Signal(r1,r2,r3); 
mycolor=IIf(m1<0 AND m1>s1, colorBlue,IIf(m1>0 AND 

m1>s1,colorGreen,IIf(m1>0 AND m1<s1,colorPink,colorRed))); 
if(Show_color) 
{ 
ColorHighliter = myColor; 
SetBarFillColor( ColorHighliter ); 
} 

barColor=IIf(C>Green ,colorWhite,IIf(C < RED,colorRed,colorWhite)); 


PlotOHLC( IIf(flowerOpen<flowerClose, flowerOpen, 

flowerClose),flowerHigh,flowerLow,IIf(flowerOpen<flowerClose, flowerClose, 

flowerOpen), "Close", barColor, styleNoTitle | styleCandle); 

_SECTION_END(); 







_SECTION_BEGIN("Bands"); 

SupResB =Param("Sup-Res Short",6,0,100,1); 
nn=SupResB; 



Bandlinecol=ParamColor("SupResLineColor",ColorRGB( 82,82,82)); 
ParmCloud = ParamToggle("Cloud", "No|Yes", 0); 
BoxCloudColor=ParamColor("BoxCloudColor",ColorRGB( 27,27,27)); 


Line2=Param("ResLineLength",100,2,500,0.1); 
Daysback1 = Line2; 
FirstBar1 = BarCount - DaysBack1; 
Hh=HHV(flowerHigh,nn); 
LL=LLV(flowerLow,nn); 

Res2=Hh; 
Sup2=LL; 

BandRes=IIf(BarIndex() >= Firstbar1,EndValue(Res2),Null); 
BandSup=IIf(BarIndex() >= Firstbar1,EndValue(Sup2),Null); 
Plot(BandRes,"",Bandlinecol,ParamStyle("ShortSupBa nd",styleLine|styleDashed|stylehidden|styleNoTitle |styleNoLabel|styleThick,maskAll)); 
Plot(BandSup,"",Bandlinecol,ParamStyle("ShortResBa nd",styleLine|styleDashed|stylehidden|styleNoTitle |styleNoLabel|styleThick,maskAll)); 




CS=BandRes; 
CR=BandSup; 


if(parmCloud == 1) 

PlotOHLC( CS, CS, CR,CR, "Band",BoxCloudColor, styleCloud | styleNoLabel|styleNoTitle); 

_SECTION_END(); 

_SECTION_BEGIN("Breakout"); 
Buyperiods=Param("Breakout periods best is usually 18",5,1,100,1,1); 
Sellperiods=Param("Exit Breakout",5,1,100,1,1); 

HaClose =EMA((O+H+L+C)/4,3); // Woodie 
//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 ) ); 
Buy= C>Ref(HHV(High,Buyperiods),-1) ; 
Sell= C<Ref(LLV(Low,Sellperiods),-1); 

/* exrem is one method to remove surplus strade signals. It removes excessive signals of arrow */ 
Buy = ExRem(Buy, Sell); 
Sell = ExRem(Sell, Buy); 

PlotShapes( IIf( Buy, shapeUpTriangle, shapeNone ), colorGreen, layer = 0,yposition = HaLow, offset = -30); 
//PlotShapes( IIf( Buy, shapeSmallCircle, shapeNone ), colorWhite, layer = 0,yposition = HaLow, offset = -8); 

PlotShapes( IIf( Sell, shapeDownTriangle, shapeNone ), colorRed, layer = 0, yposition = HaHigh, offset = -30); 
//PlotShapes( IIf( Sell, shapeSmallCircle, shapeNone ), colorRed, layer = 0, yposition = HaHigh, offset = -8); 

_SECTION_END(); 


_SECTION_BEGIN("PFE"); 

pds=10; 
x=sqrt((ROC(C,9)*ROC(C,9))+100); 
y=Sum(sqrt((ROC(C,1)* ROC(C,1))+1),pds); 
z=(x/y); 
pfe=EMA(IIf(C>Ref(C,-9),z,-z)*100,5); 

rsidn=pfe <-10 AND pfe<Ref(pfe,-1); 
rsiup=pfe >10 AND pfe>Ref(pfe,-1); 



rsiresult1 = WriteIf( rsiup,"cu", ""); 
rsiresult2 = WriteIf( rsidn,"cd", ""); 




RequestTimedRefresh( 0 ); 
GfxSelectFont( "Tahoma", 12, 120 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorWhite ); 

if ( rsiresult1 =="cu") 
{ 
GfxSelectSolidBrush( ColorRGB(0,90,0) ); 

} 
else 

if ( rsiresult2 =="cd") 

{ 
GfxSelectSolidBrush( ColorRGB(90,0,0)); 

} 

else 

if ( rsiresult2 =="") 

{ 
GfxSelectSolidBrush( colorDarkTeal ); 

} 

GfxSelectFont( "Arial", 10, 100 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorBlue ); 




_SECTION_END(); 





GfxRoundRect( 400,570,210,415, 50, 50 ); 

_SECTION_END(); 




_SECTION_BEGIN("Schaff Trend Cycle"); 
MA1=23; 
MA2=50; 
TCLen=10; 
MA1=Param("ShortMACDLen",23,5,36); 
MA2=Param("LOngMACDLen",50,10,100); 
TCLen=Param("TCLen(StochPeriod)",10,5,20); 
Factor=.5; 

XMac = MACD(MA1,MA2) ; 

Value1 = LLV(XMac, TCLen); 
Value2 = HHV(XMac, TCLen) - Value1; 

frac1=0; 
for (i = 1; i < BarCount; i++) { 
if (Value2[i] > 0) { 
frac1[i] = ((XMac[i] - Value1[i])/Value2[i])*100; 
} 
else { 
frac1[i]= frac1[i-1]; 
} 
} 


PF[0]=frac1[0]; 
PF[1]=frac1[1]; 
for (i = 2; i < BarCount; i++) { 
PF[i]=PF[i-1]+(Factor*(frac1[i]-PF[i-1])); 
} 


Value3 = LLV(PF, TCLen); 
Value4 = HHV(PF, TCLen) - Value3; 

frac2[0]=0; 
for (i = 1; i < BarCount; i++) { 
if (Value4[i] > 0 ) { 
frac2[i]=((PF[i] - Value3[i])/Value4[i])*100; 
} 
else { 
frac2[i]=frac2[i-1]; 
} 
} 

PFF[0]=frac2[0]; 
PFF[1]=frac2[1]; 
for (i = 2; i < BarCount; i++) { 
PFF[i]=PFF[i-1]+(Factor*(frac2[i]-PFF[i-1])); 
} 


rsidn=pff <2; 
rsiup=pff >98; 


rsiresult1 = WriteIf( rsiup,"cu", ""); 
rsiresult2 = WriteIf( rsidn,"cd", ""); 




RequestTimedRefresh( 0 ); 
GfxSelectFont( "Tahoma", 12, 120 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorWhite ); 

if ( rsiresult1 =="cu") 
{ 
GfxSelectSolidBrush( ColorRGB(0,120,0) ); 

} 
else 

if ( rsiresult2 =="cd") 

{ 
GfxSelectSolidBrush( ColorRGB(120,0,0)); 

} 

else 

if ( rsiresult2 =="") 

{ 
GfxSelectSolidBrush( colorDarkTeal ); 

} 

GfxSelectFont( "Arial", 10, 100 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorBlue ); 
GfxRoundRect( 390,560,220,425, 50, 50 ); 

_SECTION_END(); 


_SECTION_BEGIN("rsi"); 

//HT=ParamColor("HT", colorRed ); 

rsidn=RSI(7) <30; 
rsiup=RSI(7) >70; 


rsiresult1 = WriteIf( rsiup,"cu", ""); 
rsiresult2 = WriteIf( rsidn,"cd", ""); 




RequestTimedRefresh( 0 ); 
GfxSelectFont( "Tahoma", 12, 120 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorWhite ); 

if ( rsiresult1 =="cu") 
{ 
GfxSelectSolidBrush( ColorRGB(0,150,0) ); 

} 
else 

if ( rsiresult2 =="cd") 

{ 
GfxSelectSolidBrush( ColorRGB(150,0,0)); 

} 

else 

if ( rsiresult2 =="") 

{ 
GfxSelectSolidBrush( colorDarkTeal ); 

} 

GfxSelectFont( "Arial", 10, 100 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorBlue ); 

GfxRoundRect( 380,550,230,435, 50, 50 ); 

_SECTION_END(); 








_SECTION_BEGIN("Rays"); 


Pp1=3; 
Pp2=2; 

CS33=HHV(LLV(flowerHigh,Pp1)-ATR(Pp2),4); 
CR33=HHV(LLV(flowerHigh,Pp1)-ATR(Pp2),5); 

AtrupTrendCond1 = flowerClose> CS33 ; 
AtrdnTrendCond1 =CS33>flowerClose ; 


ATRup = WriteIf(AtrupTrendCond1,"atrup", ""); 
ATRdown= WriteIf( AtrdnTrendCond1,"atrdn", ""); 

if ( ATRup =="atrup") 
{ 
GfxSelectSolidBrush( ColorRGB(0,180,0) ); 

} 
else 

if (ATRdown =="atrdn") 

{ 
GfxSelectSolidBrush( ColorRGB(180,0,0)); 

} 

else 

if ( ATRdown =="") 

{ 
GfxSelectSolidBrush( colorDarkTeal ); 

} 

GfxSelectFont( "Arial", 10, 100 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorBlue ); 

GfxSelectPen( colorBlue, 1 ); // broader color 
GfxRoundRect( 370,540,240,445, 50, 50 ); 




_SECTION_END(); 


_SECTION_BEGIN("Exit_Beast-3"); 



EntrylookbackPeriod=10; 
EntryATRperiod=1.9; 
EntrySig = C > ( LLV( flowerLow, EntrylookbackPeriod ) + EntryATRperiod * ATR( 10 ) ); 
ExitSig = C < ( HHV( flowerHigh, EntrylookbackPeriod ) -EntryATRperiod * ATR( 10 ) ); 


RequestTimedRefresh( 0 ); 
GfxSelectFont( "Tahoma", 12, 100 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorWhite ); 

EntryB = WriteIf( EntrySig,"eu", ""); 
ExitB = WriteIf( ExitSig,"ed", ""); 

if ( EntryB =="eu") 
{ 
GfxSelectSolidBrush( ColorRGB(0,210,0) ); // 

} 
else 

if ( ExitB =="ed") 

{ 
GfxSelectSolidBrush( ColorRGB(210,0,0)); // 

} 

else 

if ( ExitB =="") 

{ 
GfxSelectSolidBrush( colorDarkTeal ); 

} 

GfxSelectFont( "Arial", 10, 100 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorBlue ); 

GfxSelectPen( colorBlue, 1 ); // broader color 
GfxRoundRect( 360,530,250,455, 50, 50 ); 



_SECTION_END(); 



_SECTION_BEGIN("CCI9-2"); 


ccidn=CCI(8) < 0; 
cciup=CCI(9) > 0; 


ccresult1 = WriteIf( cciup,"cu", ""); 
ccresult2 = WriteIf( ccidn,"cd", ""); 




RequestTimedRefresh( 0 ); 
GfxSelectFont( "Tahoma", 12, 100 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorWhite ); 

if ( ccresult1 =="cu") 
{ 
GfxSelectSolidBrush( ColorRGB(0,240,0) ); 

} 
else 

if ( ccresult2 =="cd") 

{ 
GfxSelectSolidBrush( ColorRGB(240,0,0)); 

} 

else 

if ( ccresult2 =="") 

{ 
GfxSelectSolidBrush( colorDarkTeal ); 

} 

GfxSelectFont( "Arial", 10, 100 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorBlue ); 

GfxSelectPen( colorBlue, 1 ); // broader color 
GfxRoundRect( 350,520,260,465, 50, 50 ); 








_SECTION_END(); 




_SECTION_BEGIN("%BB7-1"); 

p=7; 
x=((C+2*StDev(C,p)-MA(C,p))/(4*StDev(C,p)))*100; 
bbdown= x < 40; 
bbup= x > 40; 

bbresult1 = WriteIf( bbup,"bu", ""); 
bbresult2 = WriteIf( bbdown,"bd", ""); 
bbresult3 = WriteIf( C,"bearishrevers", ""); 



RequestTimedRefresh( 0 ); 
GfxSelectFont( "Tahoma", 12, 100 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorWhite ); 

if ( bbresult1 =="bu") 
{ 
GfxSelectSolidBrush( ColorRGB(62,255,62) ); 

} 
else 

if ( bbresult2 =="bd") 

{ 
GfxSelectSolidBrush( ColorRGB(255,62,62) ); 

} 

else 

if ( bbresult2 =="") 

{ 
GfxSelectSolidBrush( colorDarkTeal ); 

} 

GfxSelectFont( "Arial", 10, 100 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorBlue ); 

GfxSelectPen( colorBlue, 1 ); // broader color 

GfxRoundRect( 340,510,270,475, 50, 50 ); 


_SECTION_END(); 




x = 300; 
x2 = 200; 

y = Status( "pxchartheight" ); 
GfxSelectSolidBrush( colorBlue ); 
GfxSelectPen( colorWhite, 1); // broader color 
GfxRoundRect( 535, y - 80, 430,y ,7 , 7 ) ; 



_SECTION_BEGIN("MACDHIGHBULLISH"); 
r1 = Param( "Fast avg", 12, 2, 200, 1 ); 
r2 = Param( "Slow avg", 26, 2, 200, 1 ); 
r3 = Param( "Signal avg", 9, 2, 200, 1 ); 
r4 = Param( "Wk slow", 17, 2, 200, 1 ); 
r5 = Param( "Wk fast", 8, 2, 200, 1 ); 
m1=MACD(r1,r2); 
s1=Signal(r1,r2,r3); 





rsidn=m1>0 AND m1>s1; 
rsiresult2 = WriteIf( rsidn,"cd", ""); 
if ( rsiresult2 =="cd") 

{ 
GfxSelectSolidBrush( ColorRGB(0,147,0)); 

} 

else 

if ( rsiresult2 =="") 

{ 
GfxSelectSolidBrush( colorDarkTeal ); 

} 
RequestTimedRefresh( 0 ); 
GfxSelectFont( "Arial", 10, 100 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorBlue ); 

GfxSelectPen( colorBlue, 1 ); 
// broader color 
GfxCircle( 445,550,10 ); 

_SECTION_END(); 


rsidn=m1<0 AND m1>s1; 
rsiresult2 = WriteIf( rsidn,"cd", ""); 
if ( rsiresult2 =="cd") 

{ 
GfxSelectSolidBrush( ColorRGB(0,147,0)); 

} 

else 

if ( rsiresult2 =="") 

{ 
GfxSelectSolidBrush( colorDarkTeal ); 

} 
RequestTimedRefresh( 0 ); 
GfxSelectFont( "Arial", 10, 100 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorBlue ); 

GfxSelectPen( colorBlue, 1 ); 
// broader color 

GfxCircle( 470,550,10 ); 

_SECTION_END(); 

_SECTION_BEGIN("MACDLOWHBEARISH"); 
r1 = Param( "Fast avg", 12, 2, 200, 1 ); 
r2 = Param( "Slow avg", 26, 2, 200, 1 ); 
r3 = Param( "Signal avg", 9, 2, 200, 1 ); 
r4 = Param( "Wk slow", 17, 2, 200, 1 ); 
r5 = Param( "Wk fast", 8, 2, 200, 1 ); 
m1=MACD(r1,r2); 
s1=Signal(r1,r2,r3); 





rsidn=m1>0 AND m1<s1; 
rsiresult2 = WriteIf( rsidn,"cd", ""); 
if ( rsiresult2 =="cd") 

{ 
GfxSelectSolidBrush( ColorRGB(225,0,0)); 

} 

else 

if ( rsiresult2 =="") 

{ 
GfxSelectSolidBrush( colorDarkTeal ); 

} 
RequestTimedRefresh( 0 ); 
GfxSelectFont( "Arial", 10, 100 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorBlue ); 

GfxSelectPen( colorBlue, 1 ); 
// broader color 

GfxCircle(495,550,10); 

_SECTION_END(); 

_SECTION_BEGIN("MACDHIGHHBEARISH"); 
r1 = Param( "Fast avg", 12, 2, 200, 1 ); 
r2 = Param( "Slow avg", 26, 2, 200, 1 ); 
r3 = Param( "Signal avg", 9, 2, 200, 1 ); 
r4 = Param( "Wk slow", 17, 2, 200, 1 ); 
r5 = Param( "Wk fast", 8, 2, 200, 1 ); 
m1=MACD(r1,r2); 
s1=Signal(r1,r2,r3); 
rsidn=m1<0 AND m1<s1; 
rsiresult2 = WriteIf( rsidn,"cd", ""); 
if ( rsiresult2 =="cd") 
{ 
GfxSelectSolidBrush( ColorRGB(225,0,0)); 
} 

else 

if ( rsiresult2 =="") 

{ 
GfxSelectSolidBrush( colorDarkTeal ); 

} 
RequestTimedRefresh( 0 ); 
GfxSelectFont( "Arial", 10, 100 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorBlue ); 

GfxSelectPen( colorBlue, 1 ); 
// broader color 

GfxCircle( 520,550,10 ); 

_SECTION_END(); 


_SECTION_BEGIN("Average 0"); 
P = HaClose; 
Type = ParamList("Type", "Weighted,Lagless-21,Hull-26,Linear 
Regression-45,Exponential,Double Exponential,Tripple 
Exponential,Wilders,Simple"); 
Periods = Param("Periods", 20, 2, 200 ); 
Displacement = Param("Displacement", 1, -50, 50 ); 
m = 0; 

if( Type == "Weighted" ) m= WMA( P, Periods ); 
if( Type == "Lagless-21" ) m= 2*EMA(P, Periods)-EMA(EMA(P, Periods), Periods); 
if( Type == "Hull-26" ) m= WMA(2*(WMA(P, Periods/2))-WMA(P, Periods) ,4 ); 
if( Type == "Linear Regression-45" ) m= LinearReg( P, Periods ); 
if( Type == "Exponential" ) m = EMA( P, Periods ); 
if( Type == "Double Exponential" ) m = DEMA( P, Periods ); 
if( Type == "Tripple Exponential" ) m = TEMA( P, Periods ); 
if( Type == "Wilders" ) m = Wilders( P, Periods ); 
if( Type == "Simple" ) m = MA( P, Periods ); 

_SECTION_END(); 


_SECTION_BEGIN("Average 1"); 
//Average_switch = ParamToggle("Candle On/off", "Off|On"); 
P = HaClose; 
Type = ParamList("Type", "Weighted,Lagless-21,Hull-26,Linear 
Regression-45,Exponential,Double Exponential,Tripple 
Exponential,Wilders,Simple"); 
Periods = Param("Periods", 60, 2, 200 ); 
Displacement = Param("Displacement", 1, -50, 50 ); 
m = 0; 

if( Type == "Weighted" ) m= WMA( P, Periods ); 
if( Type == "Lagless-21" ) m= 2*EMA(P, Periods)-EMA(EMA(P, Periods), Periods); 
if( Type == "Hull-26" ) m= WMA(2*(WMA(P, Periods/2))-WMA(P, Periods) ,4 ); 
if( Type == "Linear Regression-45" ) m= LinearReg( P, Periods ); 
if( Type == "Exponential" ) m = EMA( P, Periods ); 
if( Type == "Double Exponential" ) m = DEMA( P, Periods ); 
if( Type == "Tripple Exponential" ) m = TEMA( P, Periods ); 
if( Type == "Wilders" ) m = Wilders( P, Periods ); 
if( Type == "Simple" ) m = MA( P, Periods ); 

_SECTION_END(); 

_SECTION_BEGIN("Average 5"); 
P = HaClose; 
Type = ParamList("Type", "Weighted,Lagless-21,Hull-26,Linear 
Regression-45,Exponential,Double Exponential,Tripple 
Exponential,Wilders,Simple"); 
Periods = Param("Periods", 120 ,2, 200 ); 
Displacement = Param("Displacement", 1, -50, 50 ); 
m = 0; 

if( Type == "Weighted" ) m= WMA( P, Periods ); 
if( Type == "Lagless-21" ) m= 2*EMA(P, Periods)-EMA(EMA(P, Periods), Periods); 
if( Type == "Hull-26" ) m= WMA(2*(WMA(P, Periods/2))-WMA(P, Periods) ,4 ); 
if( Type == "Linear Regression-45" ) m= LinearReg( P, Periods ); 
if( Type == "Exponential" ) m = EMA( P, Periods ); 
if( Type == "Double Exponential" ) m = DEMA( P, Periods ); 
if( Type == "Tripple Exponential" ) m = TEMA( P, Periods ); 
if( Type == "Wilders" ) m = Wilders( P, Periods ); 
if( Type == "Simple" ) m = MA( P, Periods ); 
_SECTION_END(); 


_SECTION_BEGIN("Sell Average 3"); 
P = HaClose; 
Type = ParamList("Type", "Weighted,Lagless-21,Hull-26,Linear 
Regression-45,Exponential,Double Exponential,Tripple 
Exponential,Wilders,Simple"); 
Periods = Param("Periods", 180, 2, 800 ); 
Displacement = Param("Displacement", 1, -50, 50 ); 
m = 0; 

if( Type == "Weighted" ) m= WMA( P, Periods ); 
if( Type == "Lagless-21" ) m= 2*EMA(P, Periods)-EMA(EMA(P, Periods), Periods); 
if( Type == "Hull-26" ) m= WMA(2*(WMA(P, Periods/2))-WMA(P, Periods) ,4 ); 
if( Type == "Linear Regression-45" ) m= LinearReg( P, Periods ); 
if( Type == "Exponential" ) m = EMA( P, Periods ); 
if( Type == "Double Exponential" ) m = DEMA( P, Periods ); 
if( Type == "Tripple Exponential" ) m = TEMA( P, Periods ); 
if( Type == "Wilders" ) m = Wilders( P, Periods ); 
if( Type == "Simple" ) m = MA( P, Periods ); 
_SECTION_END(); 


_SECTION_BEGIN("traing sl"); 

function vstop_func(trBull,trBear) 
{ 
trailArray[ 0 ] = C[ 0 ]; // initialize 
for( i = 1; i < BarCount; i++ ) 
{ 
prev = trailArray[ i - 1 ]; 

if (C[ i ] > prev AND C[ i - 1 ] > prev) 
{ 
trailArray[ i ] = Max(prev,C[ i ] - trBull[ i ]); 
} 
else if (C[ i ] < prev AND C[ i - 1 ] < prev) 
{ 
trailArray[ i ] = Min(prev,C[ i ] + trBear[ i ]); 
} 
else if (C[ i ] > prev) 
{ 
trailArray[ i ] = C[ i ] - trBull[ i ]; 
} 
else 
{ 
trailArray[ i ] = C[ i ] + trBear[ i ];	
} 
} 
return trailArray; 
} 

per = Param("per",20, 1, 150, 1); 
multBull = Param("multBull",2, 1, 4, 0.05); 
multBear = Param("multBear",2, 1, 4, 0.05); 

trBull = multBull * ATR(per); 
trBear = multBear * ATR(per); 

trailArray = vstop_func(trBull,trBear); 
s0=trailArray; 

s1= s0 > C ; 
s2= s0 <C ; 
ccresult1 = WriteIf( s1,"cu", ""); 
ccresult2 = WriteIf( s2,"cd", ""); 

GfxSelectFont("arial", 13, 700 ); GfxSetBkMode( colorRed); 
GfxSetTextColor( ParamColor("Color",colorRed) ); 
Hor=Param("Horizontal Position",30,10,1200,1); 
Ver=Param("Vertical Position",185,100,50,50); 



_SECTION_END(); 

_SECTION_BEGIN("traing s2"); 

s0=trailArray; 

s1= s0 > C ; 
s2= s0 <C ; 
ccresult1 = WriteIf( s1,"cu", ""); 
ccresult2 = WriteIf( s2,"cd", ""); 



_SECTION_END(); 


_SECTION_BEGIN("buycircle"); 
GfxSelectFont( "Arial", 10, 100 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorBlue ); 
GfxSelectPen( colorBlue, 1 ); 
if ( ccresult2 =="cd") 
{ 
GfxSelectSolidBrush( ColorRGB(0,255,0) ); 
} 
else 
{ 
GfxSelectSolidBrush( ColorRGB(0,0,94) ); 
} 

GfxCircle( 455,510,20 ); 

_SECTION_END(); 
_SECTION_BEGIN("sellcircle"); 
GfxSelectFont( "Arial", 10, 100 ); 
GfxSetBkMode( 1 ); 
GfxSetTextColor( colorBlue ); 
GfxSelectPen( colorBlue, 1 ); 
if ( ccresult1 =="cu") 
{ 
GfxSelectSolidBrush( ColorRGB(255,0,0) ); 
} 
else 
{ 
GfxSelectSolidBrush( ColorRGB(0,0,94) ); 
} 

GfxCircle( 510,510,20 ); 
_SECTION_END(); 
_SECTION_BEGIN("ema_crossover"); 
Plot(EMA(Close,10),"",colorOrange,styleLine ); 
Plot(EMA(Close,20),"",colorBlueGrey,styleLine); 
Plot(EMA(Close,30),"",colorTeal,styleLine); 
_SECTION_END(); 








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

for ( i = 0; i < BarCount; i++ ) 
{ 
if ( HH[i] ) 
PlotText( "H TOP ", i, H[ i ] + dist[i], colorYellow ); 

if ( LH[i] ) 
PlotText( "L TOP", i, H[ i ] + dist[i], colorYellow ); 

if ( HL[i] ) 
PlotText( "H Bottom", i, L[ i ] - dist[i], colorYellow ); 

if ( LL[i] ) 
PlotText( "L Bottom", i, L[ i ] - dist[i], colorYellow ); 

} 































_SECTION_BEGIN("Magnified Market Price"); 
FS=Param("Font Size",30,30,100,1); 
GfxSelectFont("Arial", FS, 700, italic = False, underline = False, True ); 
GfxSetBkMode( colorWhite ); 
GfxSetTextColor( ParamColor("Color",colorWhite) ); 
Hor=Param("Horizontal Position",350,800,800,800); 
Ver=Param("Vertical Position",50,27,27,27); 
GfxTextOut(""+C,Hor+250 , Ver-53 ); 
YC=TimeFrameGetPrice("C",inDaily,-1); 
DD=Prec(C-YC,2); 
xx=Prec((DD/YC)*100,2); 
GfxSelectFont("Arial", 12, 700, italic = False, underline = False, True ); 
GfxSetBkMode( colorWhite ); 
GfxSetTextColor(ParamColor("Color",colorYellow) ); 
GfxTextOut(""+DD+" ("+xx+"%)", Hor+250, Ver-1 ); 
_SECTION_END(); 

_SECTION_BEGIN("Right 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(); 


_SECTION_BEGIN("trending ribbon"); 
uptrend=PDI()>MDI()AND Signal()<MACD(); 
downtrend=MDI()>PDI()AND Signal()>MACD(); 



_SECTION_END(); 


_SECTION_BEGIN("Swing"); 

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(); 



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



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); 

dist =0.5* ATR(10); 
dist1 = 2*ATR(10); 
for (i=0; i<BarCount; i++) { 
if ( Buy[i] ) 
PlotText("Buy:" + H[ i ], i, H[ i ]-3*dist[i], colorGreen); 

if ( Sell[i] ) 
PlotText("Sell:" + L[ i ], i, L[ i ]+3*dist[i], colorRed); 
} 

AlertIf( Buy, "", "BUY @ " + H, 1 ); 
AlertIf( Sell, "", "SELL @ " + L, 2 ); 
AlertIf( Buy, "EMAIL", "A sample alert on "+FullName(), 1 ); 
AlertIf( Sell, "EMAIL", "A sample alert on "+FullName(), 2 ); 
_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(sloss,"Swing",colorYellow,styleStaircase); 

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

//ParamColor("BgBottom", ColorRGB( 172,172,172 )),ParamColor("titleblock",ColorRGB( 172,172,172 ))); 
//Alerts 


GraphXSpace = 5; 

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

SetChartBkColor(colorBlack); 
SetChartOptions(0,chartShowArrows|chartShowDates); 

/* -------------------------------------------------------------------------------------- */ 
//////////////////////////////////////////////////////////////////////////////////////////////// 
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",colorYellow,styleLine |styleDashed|styleThick); 
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 @ " + H, 1 ); 
AlertIf( Sell, "", "SELL @ " + L, 2 ); 

for (i=BarCount-1; i>1; i--) { 
if (Buy[i] == 1) { 
entry =H[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 = L[i]; 
sl = sloss[i]; 
tar1 = entry - (entry * .0050); 
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)); 





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



_SECTION_END(); 

_SECTION_BEGIN("EMA1"); 
P = ParamField("Price field",-1); 
Periods = Param("Periods", 15, 2, 300, 1, 10 ); 
Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") ); 
_SECTION_END(); 

_SECTION_BEGIN("ATP"); 

B=Volume; 
A=Avg; 
Value=B*A; 
Barsfromtodaybegin = 1 + BarsSince( Day() != Ref(Day(), -1)); 
Totalvalue=Sum(Value,Barsfromtodaybegin); 
Totalvolume=Sum(V,Barsfromtodaybegin); 
ATP=(Totalvalue/Totalvolume); 
ColorATP=IIf(ATP>Ref(ATP,-1),colorBrightGreen,colorRed); 
Plot(ATP,"ATP",colorATP,styleThick); 
_SECTION_END(); 

a=20; 
GraphXSpace=5; 
p=30; 
p = Param("p",30,2,100,1); 

Om=DEMA(O,p); 
hm=DEMA(H,p); 
lm=DEMA(L,p); 
Cm=DEMA(C,p); 
HACLOSE=(Om+Hm+Lm+Cm)/4; 
HaOpen = AMA( Ref( HaClose, -1), 1); 
HaHigh = Max( Hm, Max( HaClose, HaOpen ) ); 
HaLow = Min( Lm, Min( HaClose, HaOpen ) ); 

slope = Param("slope",2,2,100,1); 

Color20= IIf(LinRegSlope(MA(HaClose,a),slope)<0,colorRed,colorGreen); 
Plot(MA(HaClose,a),"", color20,styleThick); 

Color=IIf(Haclose>MA(HaClose,a),colorGreen, colorRed); 
//PlotOHLC( HaOpen, HaOpen, HaClose, HaClose, "" + Name(), Color, styleCandle); 
_SECTION_END(); 

_SECTION_BEGIN("Priyanvada's Price Action"); 
P = ParamField( "Price field" ); 
CandleT=ParamToggle("Candlestick Display","No|Yes",defaultval=1 ); 
BarT=ParamToggle("Bar Display","No|Yes",defaultval=0 ); 
LineT=ParamToggle("Line Display","No|Yes",defaultval=0 ); 
//T3MA toggle 
T3MAT=ParamToggle("Moving Average","No|Yes",defaultval=1 ); 
//T3MA Check Periods 
T3MAP = Param("T3MA Periods", 46, 2, 300, 1, 10 ); 

function T3(price,periods) 
{ 
s = 0.84; 
e1=EMA(price,periods); 
e2=EMA(e1,Periods); 
e3=EMA(e2,Periods); 
e4=EMA(e3,Periods); 
e5=EMA(e4,Periods); 
e6=EMA(e5,Periods); 
c1=-s*s*s; 
c2=3*s*s+3*s*s*s; 
c3=-6*s*s-3*s-3*s*s*s; 
c4=1+3*s+s*s*s+3*s*s; 
Ti3=c1*e6+c2*e5+c3*e4+c4*e3; 
return ti3; 
} 
T3MA = T3(P,T3MAP); 
for( i = 1; i < BarCount; i++ ) 
{ 
//assignments 
NvadaOpen[i] = Close[i-1]; 
NvadaClose[i]=Close[i]; 
NvadaHigh[i]=IIf(NvadaOpen[i]>=NvadaClose[i],NvadaOpen[i],NvadaClose[i]); 
NvadaLow[i]=IIf(NvadaOpen[i]>=NvadaClose[i],NvadaClose[i],NvadaOpen[i]); 
averagechange[i]=(NvadaOpen[i]+NvadaClose[i])/2; 

//============================= 
//CHECKS 

//check1= uptrend and upbar as referred for last 2 bars 
Check1[i]=averagechange[i]>T3MA[i] AND NvadaClose[i]>=NvadaOpen[i-2]; 
//check2= uptrend and downbar as referred for last 2 bars 
Check2[i]=averagechange[i]>T3MA[i] AND NvadaClose[i]<NvadaOpen[i-2]; 

//check3= downtrend and downbar as referred for last 2 bars 
Check3[i]=averagechange[i]<T3MA[i] AND NvadaClose[i]<=NvadaOpen[i-2]; 
//check4= downtrend and upbar as referred for last 2 bars 
Check4[i]=averagechange[i]<T3MA[i] AND NvadaClose[i]>NvadaOpen[i-2]; 

//check5=check2 or check 4 => possible corrections! 
Check5[i]=Check2[i] OR Check4[i]; 

//Color assignment 
if(Check1[i]==1){pricolor[i] =colorGreen;} 
if(Check3[i]==1){pricolor[i] =colorRed;} 
if(Check5[i]==1){pricolor[i] =colorYellow;} 
//Pricolor = IIf(NvadaClose>Ref(NvadaOpen,-2),colorGreen,colorRed); 
} 



//T3MA Display 
if(T3MAT==1) 
{ 
T3MAcolor = IIf(C>=T3MA,colorGreen,colorRed); 
//Plot(T3MA,"T3MA",T3MAcolor,styleThick); 
} 
Buy=T3MAcolor==colorGreen; 
Sell=T3MAcolor==colorRed; 
Short=Sell; 
Cover=Buy; 

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

Buy=ExRem(Buy,Sell); 
Sell=ExRem(Sell,Buy); 
//PlotShapes(IIf(Buy , shapeUpArrow, shapeNone),colorWhite); 
//PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorYellow); 
no=Param( "Swing", 12, 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); 


//Plot(tsl, _DEFAULT_NAME(), tsl_col, styleStaircase); 




SetPositionSize(300,spsShares); 
ApplyStop(0,1,10,1); 
//-----------end-------------- 
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)+"","")); 
_SECTION_END(); 


H1 = SelectedValue( TimeFrameGetPrice( "H", inDaily, -1 ) ); 
L1 = SelectedValue( TimeFrameGetPrice( "L", inDaily, -1 ) ); 
C1 = SelectedValue( TimeFrameGetPrice( "C", inDaily, -1 ) ); 
H2 = SelectedValue( TimeFrameGetPrice( "H", inDaily, 0 ) ); 
L2 = SelectedValue( TimeFrameGetPrice( "L", inDaily, 0 ) ); 
O1 = SelectedValue( TimeFrameGetPrice( "open", inDaily, 0 ) ); 
F4 = 0; 
D1 = ( H1 - L1 ); 
D2 = ( H2 - L2 ); 
F1 = D1 * 0.433; 
F2 = D1 * 0.766; 
F3 = D1 * 1.35; 
if ( D2 <= F1 ) 
F4 = F1; 
else 
if ( D2 <= F2 ) 
F4 = F2; 
else 
F4 = F3; 

S_P = ( O1 - F4 ); 

B_P = ( O1 + F4 ); 

BP = ( L2 + F4 ); 

BPTGT = ( BP + ( BP * .0065 ) );//.0015 brokerage 

BPSTPLS = ( BP - ( BP * .0085 ) ); 

SP = ( H2 - F4 ); 

SPTGT = ( SP - ( SP * .0065 ) ); 

SPSTPLS = ( SP + ( SP * .0085 ) ); 


p = ( H1 + L1 + C1 ) / 3; 

s1 = ( H1 ); 

r1 = ( L1 ); 

r2 = SelectedValue( L2 ); 

s2 = SelectedValue( H2 ); 
Filter = Buy OR Sell; 

AddColumn( IIf( Buy, 66, 1 ), "Buy", formatChar, 1, bkcolor = IIf( Buy, 43, 33 ) ); 

AddColumn( IIf( Sell, 83, 1 ), "Sell", formatChar, 1, bkcolor = IIf( Sell, 25, 32 ) ); 

AddColumn( IIf( Short, 83, 1 ), "Short", formatChar, 1, bkcolor = IIf( Short, 25, 32 ) ); 

AddColumn( C, "CMP", 1.2, colorDefault, colorLightBlue ); 

AddColumn( BP, "SELL PRICE", 1.2, colorDefault, colorGreen ); 

AddColumn( BPTGT, "TGT PRICE", 1.2, colorDefault, colorBrown ); 

AddColumn( BPSTPLS, "STPLS BUY", 1.2, colorDefault, colorRed ); 

AddColumn( p, "PIVOT", 1.2, colorDefault, colorYellow ); 

AddColumn( SPSTPLS, "STPLS SELL", 1.2, colorDefault, colorRed ); 

AddColumn( SP, "SELL PRICE", 1.2, colorDefault, colorGreen ); 

AddColumn( SPTGT, "TGT PRICE", 1.2, colorDefault, colorBrown ); 


AddColumn( H1, "PRE-HIGH" ); 

AddColumn( L1, "PRE-LOW" ); 

AddColumn( D1, "PRE-DIFF" ); 

AddColumn( F1, "0.433" ); 

AddColumn( F2, "0.766" ); 

AddColumn( F3, "1.35" ); 

AddColumn( H2, "D-HIGH" ); 

AddColumn( L2, "D-LOW" ); 

AddColumn( D2, "D-DIFF" ); 

AddColumn( F4, "SELECT FACT" ); 
_SECTION_END(); 
//============== TITLE ============== 
_SECTION_BEGIN("Title"); 
if( Status("action") == actionIndicator ) 
( 
Title = EncodeColor(colorGold)+ "K T S" + EncodeColor(colorRose)+" (" + Name() + ") " + EncodeColor(colorGold)+ Interval(2) + 
" " + Date() +" " +" Open "+WriteVal(O,1.000)+" "+"Hi "+WriteVal(H,1.000)+" "+"Lo "+WriteVal(L,1.000)+" "+ 
"Close "+WriteVal(C,1.000)+" ("+WriteVal(C-Ref(C,-1),1,0)+" "+WriteVal((C-Ref(C,-1))*100/Ref(C,-1),1.1)+ "%) Vol= "+ WriteVal(V,1.0) 



+"\n"+EncodeColor(colorGrey50)+"------------------------------------------------------------------------------------------------------------" 

+"\n"+EncodeColor(colorGold)+ 
WriteIf (Buy , "Signal: Go Long - Entry Price: "+WriteVal(C)+" - Traget: "+WriteVal((BuyPrice+tsl)+BuyPrice) 
+" - StopLoss:"+WriteVal(tsl)+" " 
,"")+ 


WriteIf (Sell , "Signal: Go Short - Entry Price: "+WriteVal(C)+" - Target: "+WriteVal((tsl-SellPrice)-SellPrice)+" - StopLoss:"+WriteVal(tsl)+" ","")+ 
EncodeColor(ColorRGB(111,208,255))+ 
WriteIf(Long AND NOT Buy, "Trade: Long - Entry Price: "+WriteVal((H))+" - Profit: "+WriteVal((C-BuyPrice))+" "+EncodeColor(colorLime)+"Let your profit runs!","")+ 
WriteIf(shrt AND NOT Sell, "Trade: Short - Entry Price: "+WriteVal((L))+" - Profit: "+WriteVal((SellPrice-C))+" - "+EncodeColor(colorLime)+"Let your profit runs!","")

+"\n"+EncodeColor(colorGrey50)+"------------------------------------------------------------------------------------------------------------" 
); 

dist = 6*ATR(10); 
dist1 = 6*ATR(10); 
for( i = 0; i < BarCount; i++) 
{ 
if( Buy[i] ) 
{ 
//PlotText( "Buy:" + C[ i ] + "\nT= " + tsl[i] + "\nSL= " +((C[i]-tsl[i])+C[i]) , i, C[ i ]-dist[i], colorGreen, colorDarkOliveGreen ); 
} 
if( Sell[i] ) 
{ 
//PlotText( "Sell:" + C[ i ] + "\nT= " + (C[i]-(tsl[i]-C[i])) + "\nSL= " +tsl[i], i, C[ i ]+dist1[i], colorRed, colorDarkOliveGreen ); 
} 
} 




/*Plot Ribbon */ 
Ribbon1=IIf( (C) >(tsl) ,colorGreen, IIf(( tsl )>( C ), colorRed,colorBlack)); 
Plot(3, "Ribbon", Ribbon1, styleOwnScale| styleArea| styleNoLabel,-0.5,100); 

_SECTION_END();
Hi all
In above afl it explores/scan stocks for intraday only.Pl. anyone can make it scan for daily also?
Thanks & regards

Change settings to daily


 

Similar threads