Saturday, 24 January 2015

For Intraday Trading for Amibroker (AFL)


For Intraday Trading for Amibroker (AFL)

This indicaror given by my friend & its giving good result in
intraday trading…so plz first check from your side…do back testing &
if u satisfy then ENJOY TRADING….Thx



_SECTION_BEGIN("System");

SetChartOptions(0,chartShowArrows|chartShowDates);
Title = ("" + Name()+" " + Date() +" "+Interval(2) +" "+ EncodeColor(colorLime)+",Open "+Open +" ,High "+H+" ,Low "+L+" ,Close "+C+" "+"{{VALUES}}");

per1=Param("First Period",6,2,30,1);
per2=Param("Second Period",2,2,30,1);
Om=MA(O,per1);
hm=MA(H,per1);
lm=MA(L,per1);
Cm=MA(C,per1);



//==============================================================================================================
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 ) );
//PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "" + Name(), colorBlack, styleCandle | styleNoLabel );

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

PlotOHLC( Of, Hf, Lf, Cf, "" + Name(), colorGreen, styleCandle | styleNoLabel );



Plot(C,"Close",colorLime,styleLine);
//=======================================================================================================================

MO=MA(O,40);
ML=MA(L,40);
MH=MA(H,40);

Plot(MO,"",colorBlue,styleDashed);
Plot(ML,"",4,styleDashed);
Plot(MH,"",colorDarkGreen,styleDashed);


_SECTION_BEGIN("Background text");
C13=Param("fonts",20,10,30,1 );
C14=Param("left-right",2.1,1.0,5.0,0.1 );
C15=Param("up-down",12,1,20,1 );
Miny = Status("axisminy");
Maxy = Status("axismaxy");
lvb = Status("lastvisiblebar");
fvb = Status("firstvisiblebar");
pxwidth = Status("pxwidth");
pxheight = Status("pxheight");
GfxSetBkMode(transparent=1);
GfxSetOverlayMode(1);
GfxSelectFont("Tahoma", Status("pxheight")/C13 );
GfxSetTextAlign( 6 );
GfxSetTextColor( ColorRGB (217,217,213));
GfxTextOut( Name(), Status("pxwidth")/C14, Status("pxheight")/C15 );
GfxSelectFont("Tahoma", Status("pxheight")/C13*0.5 );
GfxSetTextColor( ColorRGB (103,103,103));
GfxSelectFont("Tahoma", Status("pxheight")/C13*0.5 );
GfxSetTextColor( ColorRGB (103,103,103));
GfxSelectFont("MS Sans Serif", 10, 500, False, False, 0);
_SECTION_BEGIN("Background Color");
BKswitch = ParamToggle("Background Color","On,Off");

OUTcolor = ParamColor("Outer Panel Color",colorLightBlue);
INUPcolor = ParamColor("Inner Panel Upper",colorLightYellow);
INDNcolor = ParamColor("Inner Panel Lower",colorSeaGreen);
TitleColor = ParamColor("Title Color ",ColorRGB(245,245,245));

if (NOT BKswitch)
{
SetChartBkColor(OUTcolor); // color of outer border
SetChartBkGradientFill(INUPcolor,INDNcolor,TitleColor); // color of inner panel
}
_SECTION_END();

/*1. Here are some observations to keep in mind that will help assure
you are in a good trending move which is detrimental to the success
of the trade moving higher before the inevitable over exhausted trend.

2 Consider only going long on the 5M if the 30M (two rows above) is also blue.

3 Consider the 1hr row as well being blue since it has an effect too.

4 The 15M row has to be blue with NO exceptions

5 The 30M row if blue has less effect on the trade as compared to the 15M row
but keep this in mind. The 30M row being blue helps the 15M row continue to stay blue.

6 The 1hr row has even less effect OR importance but it too keeps the 30M
from weakening to some minor degree.
*/
// Define label bar (x) position location

blankRightBars = 5; //insert actual blank right bars specified in Preferences
barsInView = Status("lastvisiblebarindex") - Status("firstvisiblebarindex") - blankRightBars;
Offset = Param("Offset Bar", 0.95, 0, 1, 0.01);
textOffset = BarCount - (Offset * barsInView);

_SECTION_BEGIN("default");
HaClose =EMA((O+H+L+C)/4,3);
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
PlotText("Heinkein 4T tf :"+Interval(2), textoffset, 41.01, colorYellow);

Color = IIf( Haopen > Haclose,4, IIf( Haopen == Haclose,colorYellow, 6));
Plot(10,"", Color,  styleHistogram+styleThick|styleOwnScale|styleNoLabel, 0, 100 );
Plot( 11,"",colorBlack,styleOwnScale|styleArea|styleNoLabel,0, 100 );

_SECTION_BEGIN("2");
Compress2= Param("Compression",2,1,3,1);
TimeFrameSet(Compress2* Interval());
HaClose2 =EMA((O+H+L+C)/4,3);
HaOpen2 = AMA( Ref( HaClose2, -1 ), 0.5 );
HaHigh2 = Max( H, Max( HaClose2, HaOpen2 ) );
HaLow2 = Min( L, Min( HaClose2, HaOpen2 ) );
PlotText("Heinkein 4T tf :"+Interval(2), textoffset, 41.055, colorYellow);
TimeFrameRestore();
HAopen2f=TimeFrameExpand( Haopen2, Compress2* Interval());
Haclose2f=TimeFrameExpand( Haclose2, Compress2* Interval());
HaHigh2f=TimeFrameExpand( Hahigh2, Compress2* Interval());
HaLow2f=TimeFrameExpand( Halow2, Compress2* Interval());
Color2 = IIf( Haopen2f > Haclose2f,4, IIf(Haopen2f == Haclose2f,colorYellow, 6));
Plot(20,"", Color2,  styleHistogram+styleThick|styleOwnScale|styleNoLabel, 0, 100 );
Plot( 21,"",colorBlack,styleOwnScale|styleArea|styleNoLabel,0, 100 );

_SECTION_BEGIN("3");
Compress3= Param("Compression3",4,2,6,1);
TimeFrameSet(Compress3* Interval());
HaClose3 =EMA((O+H+L+C)/4,3);
HaOpen3 = AMA( Ref( HaClose3, -1 ), 0.5 );
HaHigh3 = Max( H, Max( HaClose3, HaOpen3 ) );
HaLow3 = Min( L, Min( HaClose3, HaOpen3 ) );
PlotText("Heinkein 4T tf :"+Interval(2), textoffset,41.10, colorYellow);
TimeFrameRestore();
HAopen3f=TimeFrameExpand( Haopen3, Compress3* Interval());
Haclose3f=TimeFrameExpand( Haclose3, Compress3* Interval());
HaHigh3f=TimeFrameExpand( Hahigh3, Compress3* Interval());
HaLow3f=TimeFrameExpand( Halow3, Compress3* Interval());
color3 = IIf( Haopen3f > Haclose3f,4, IIf( Haopen3f == Haclose3f,colorYellow,6));
Plot(30,"", Color3,  styleHistogram+styleThick|styleOwnScale|styleNoLabel, 0, 100 );
Plot( 31,"",colorBlack,styleOwnScale|styleArea|styleNoLabel,0, 100 );

_SECTION_BEGIN("4");
Compress4= Param("Compression4",8,2,10,1);
TimeFrameSet(Compress4* Interval());
HaClose4 =EMA((O+H+L+C)/4,3);
HaOpen4 = AMA( Ref( HaClose4, -1 ), 0.5 );
HaHigh4 = Max( H, Max( HaClose4, HaOpen4 ) );
HaLow4 = Min( L, Min( HaClose4, HaOpen4 ) );
PlotText("Heinkein 4T tf :"+Interval(2), textoffset, 41.14, colorYellow);
TimeFrameRestore();
HAopen4f=TimeFrameExpand( Haopen4, Compress4* Interval());
Haclose4f=TimeFrameExpand( Haclose4, Compress4* Interval());
HaHigh4f=TimeFrameExpand( Hahigh4, Compress4* Interval());
HaLow4f=TimeFrameExpand( Halow4, Compress4* Interval());
Color4 = IIf( Haopen4f > Haclose4f,4, IIf( Haopen4f == Haclose4f ,colorYellow, 6));
Plot(40,"", Color4,  styleHistogram+styleThick|styleOwnScale|styleNoLabel, 0, 100 );
Plot( 41,"",colorBlack,styleOwnScale|styleArea|styleNoLabel,0, 100 );
_N(Title = "{{NAME}} - {{INTERVAL}} {{DATE}} "+_DEFAULT_NAME()+" : {{OHLCX}} {{VALUES}}" );

Previous Pivots for Amibroker (AFL)


Previous Pivots for Amibroker (AFL)

i have found in technical stories, most of the peoples are working with todays and tomorrows pivots. but yesterdays pivots are working very good most of the times…….Enjoy…….



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

PO=TimeFrameGetPrice( "O", inDaily, -1 );
PL=TimeFrameGetPrice( "L", inDaily, -1 );
PH=TimeFrameGetPrice( "H", inDaily, -1 );
PC=TimeFrameGetPrice( "C", inDaily, -1 );

P=((PH+PL+PC)/3);PI=LastValue(P,1);
R1=((2*P)-PL);R1I=LastValue(R1,1);
S1=((2*P)-PH);S1I=LastValue(S1,1);
R2=((P-S1)+R1);R2I=LastValue(R2,1);
S2=(P-(R1-S1));S2I=LastValue(S2,1);
R3=PH+(2*(P-PL));R3I=LastValue(R3,1);
S3=PL-(2*(PH-P));S3I=LastValue(S3,1);
if(ppl==1) {
Plot(R1,"Resistance 1",colorRed,styleDashed);
Plot(R2,"Resistance 1",colorRed,styleDashed);
Plot(R3,"Resistance 1",colorRed,styleDashed);
Plot(S1,"Support 1",colorBrightGreen,styleDashed);
Plot(S2,"support 2",colorBrightGreen,styleDashed);
Plot(S3,"Support 3",colorBrightGreen,styleDashed);
Plot(P,"Resistance 1",colorWhite,styleDashed);
PlotText(" Y Day Pivot = " + WriteVal(P,fraction), LastValue(BarIndex())-(numbars/Hts), PI +0.05, colorWhite);
PlotText(" Y Day Resistance 1 = " + WriteVal(R1,fraction), LastValue(BarIndex())-(numbars/Hts), R1I +0.05, colorRed);
PlotText(" Y Day Resistance 2 = " + WriteVal(R2,fraction), LastValue(BarIndex())-(numbars/Hts), R2I +0.05, colorRed);
PlotText(" Y Day Resistance 3 = " + WriteVal(R3,fraction), LastValue(BarIndex())-(numbars/Hts), R3I +0.05, colorRed);
PlotText(" Y Day Support 1 = " + WriteVal(S1,fraction), LastValue(BarIndex())-(numbars/Hts), S1I +0.05, colorBrightGreen);
PlotText(" Y Day Support 2 = " + WriteVal(S2,fraction), LastValue(BarIndex())-(numbars/Hts), S2I +0.05, colorBrightGreen);
PlotText(" Y Day Support 3 = " + WriteVal(S3,fraction), LastValue(BarIndex())-(numbars/Hts), S3I +0.05, colorBrightGreen);
}

_SECTION_BEGIN("@Candle great");
A=(H+L)/2;
var1=Wilders(A,34);
var2=Wilders(A,5);
var3=var2-var1;
var4=var3-Wilders(var3,5);
Var5=(H-L)/V;
AO=Var3;
AC=Var4;



barcolor=IIf(AO>Ref(AO,-1) AND AC>Ref(AC,-1),colorGreen,IIf(AO<Ref(AO,-1) AND AC<Ref(AC,-1),colorRed,IIf(V>0 AND Var5<Ref(Var5,-1) AND V>Ref(V,-1),colorGold,colorBrown)));

Plot(C,"Close",barcolor,64+styleNoTitle );
_SECTION_END();

_SECTION_BEGIN("Background text");
SetChartBkColor(colorBlack);
strWeekday = StrMid("---SUNDAY---MONDAY--TUESDAYWEDNESDAY-THURSDAY--FRIDAY--SATURDAY", SelectedValue(DayOfWeek())*9,9);
GraphXSpace=Param("GraphXSpace",10,-55,200,1);
C13=Param("fonts",20,10,30,1 );
C14=Param("left-right",2.1,1.0,5.0,0.1 );
C15=Param("up-down",12,1,20,1 );
Miny = Status("axisminy");
Maxy = Status("axismaxy");
lvb = Status("lastvisiblebar");
fvb = Status("firstvisiblebar");
pxwidth = Status("pxwidth");
pxheight = Status("pxheight");
YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);
GfxSetBkMode(transparent=1);
GfxSetOverlayMode(1);
GfxSelectFont("Candara", Status("pxheight")/C13 );
GfxSetTextAlign( 6 );
GfxSetTextColor(   ColorRGB (217,217,213));
GfxTextOut( Name(), Status("pxwidth")/C14, Status("pxheight")/C15 );
GfxSelectFont("Tahoma", Status("pxheight")/C13*0.5 );
GfxSetTextColor( ColorRGB (217,217,213));
GfxTextOut( "L.T.P. : "+ C +"", Status("pxwidth")/C14, Status("pxheight")/C15*2 );
GfxSelectFont("Candara", Status("pxheight")/C13*0.5 );
GfxSetTextColor(  ColorRGB (217,217,213));
GfxTextOut( ""+DD+ " ( "+xx+"%)", Status("pxwidth")/C14, Status("pxheight")/C15*2.5 );

_SECTION_BEGIN("Title");

DODay = TimeFrameGetPrice("O", inDaily);
DHiDay = TimeFrameGetPrice("H", inDaily);
DLoDay = TimeFrameGetPrice("L", inDaily);

Title = EncodeColor(colorWhite)+"   "+EncodeColor(colorWhite)+ Name() + ", " + Interval(2) + ", " + Date() + "   -  "+strWeekday + "  - " +
EncodeColor(colorWhite)   +  "\nO " + EncodeColor(colorWhite) + O +

 ",   H :  "   + H +
 ",   L  :  " + L +
 ",   C  :  "  + C +
EncodeColor(colorWhite)+ "\n Day-Open : " +DODay + "  Day-High : " +DHiDay + "  Day-Low : " + DLoDay
;

MACD ON PRICE CHART for Amibroker (AFL)


MACD ON PRICE CHART for Amibroker (AFL)

Hi friends
This is a plain Macd formula the 26-12-9 ema plotted on a price chart and if used to detect divergence or price to macd discrepancy clearly shown in chart works wonders.
Those who trade with macd will be very useful.Please see the inserted image and have clearly marked the areas of discrepancy with price and macd indicator.This indicator has to be used with a regular macd indicator at bottom.
Thank You all
Hope will be useful to you all
Here is a screenshot of how the indicator looks:

 

 



_SECTION_BEGIN("EMA Crossover");

Plot(Close, "Price", colorWhite, styleCandle);
Plot(EMA(Close,12),"12-EMA",colorBlue,styleThick);
Plot(EMA(Close,26),"26-EMA",colorRed,styleThick);
Plot(EMA(Close,9),"9-EMA",colorBrightGreen,styleDots,styleThick);

//Formula for EMA Crossover Price
XR=(EMA(Close,5) * (2 / 6 - 1) - EMA(Close,10) * (2 / 11 - 1)) / (2 / 6 - 2 / 11);



Title = Name() + " " + Date() + EncodeColor( colorBlue ) + "  Close: " + C + EncodeColor( colorBlack ) + "   Open: " + O + "   High: " + H + "   Low: " + L + EncodeColor( colorBlue )+  "\n" + EncodeColor(colorDarkGreen) + WriteVal (XR, format=1.2 ) + " Price Required for EMA Crossover";
_SECTION_END();

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

RSI - With Overbought & Oversold coloured for Amibroker (AFL)


This is RSI Indicator, with coloured Overbought and Oversold area , to make easier to analyze.
Here is a screenshot of how the indicator looks:

_SECTION_BEGIN("RSI");
SetChartOptions(0,0,ChartGrid30|ChartGrid70,0,100);
periods = Param( "Periods", 14, 1, 200, 1 );
z = RSI( periods);

RSILineColor = ParamColor("RSI Line Color",ColorRGB(127,0,83));
RSIOverboughtColor = ParamColor("RSI Overbought Color",ColorRGB(127,0,83));
RSIOversoldColor = ParamColor("RSI Oversold Color",colorRed);


Plot( z, _DEFAULT_NAME(), RSILineColor , styleLine  );
Plot( 50, _DEFAULT_NAME(), RSILineColor , styleDashed|styleNoTitle  );
Plot( 70, _DEFAULT_NAME(), RSILineColor , styleLine|styleNoTitle  );
Plot( 30, _DEFAULT_NAME(), RSILineColor , styleLine|styleNoTitle  );
PlotOHLC(z,z,50,z,"",IIf(z>50,RSIOverboughtColor,RSIOversoldColor),styleCloud|styleClipMinMax,30,70);


_SECTION_END();

Wise wave for Amibroker (AFL) -David Weis a veteran VSA teacher commercialized


Wise wave for Amibroker (AFL)

David Weis a veteran VSA teacher commercialized his Weis Wave indicator which is considered as A Modern Adaptation of the Wyckoff Wave & Volume. Get introduced about Weis wave reading the description “Weis Wave Plugin_ A Modern Adaptation of the Wyckoff Wave & Volume” from the link-
This is collected one and thanks to original author who took the pain in transforming the code for amibroker also regretting for not mentioning his name as I cant recall his name right now.
Here is a screenshot of how the indicator looks:


_SECTION_BEGIN("WeisWave");
//up[0] = V[0]; 
//dn[0] = V[0];
//vol[0] = V[0]; 
trend[0] = 0;
wave[0] = 0;
vol[0] = 0;
mov[0] = 0;
dif=1;
rp    = Param("Reversal Bars", 0.03,0.1,5,0.1);
for( i=1; i<BarCount; i++) {

if (Close[i]-Close[i-1]>rp) mov[i]=1;
if (Close[i]-Close[i-1]==rp) mov[i]=0;
if (Close[i]-Close[i-1]<-rp) mov[i]=-1; 

if ((mov[i]!=0) && (mov[i]!=mov[i-1])) 
{
trend[i]=mov[i];
} 
else {trend[i]=trend[i-1];} 
if ((trend[i]!=wave[i-1]) && (abs(Close[i]-Close[i-1])*10000>=dif)) 
{
wave[i]=trend[i];
} 
else 
{
wave[i]=wave[i-1];
}    
if (wave[i]==wave[i-1]) 
{
vol[i]=vol[i-1]+Volume[i];
} 
else 
{
vol[i]=Volume[i];
}

if (wave[i]==1) 
{
up[i]=vol[i]; 
dn[i]=0;
}
if (wave[i]==-1) 
{
dn[i]=vol[i]; 
up[i]=0;
}
if (wave[i]==0) 
{
dn[i]=vol[i-1]; 
up[i]=vol[i-1];
}
}

 
PlotOHLC(0,up,0,up,"SwingWave",5 , 2|styleThick ) ;
PlotOHLC(0,dn,0,dn,"",4 , 2|styleThick ) ;




GfxSetOverlayMode(1);
GfxSetTextColor(10); 
GfxSelectFont("MS Sans Serif", 6, 300, False, False, 0); 
GfxTextOut(" By : Casoni ", Status("pxwidth")-60 , Status("pxheight")-13 );
_SECTION_END();

Advanced Elliott for Amibroker (AFL)


Advanced Elliott for Amibroker (AFL)




_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,3,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)
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();

AutoTrade Control For NEST/NOW for Amibroker (AFL)

AutoTrade Control For NEST/NOW

This is the updation of Manual Trade Control for NEST/NOW. This afl have new features like it will have all the trades in its memory.
This AFL is not a strategy for trading. It is only integrating the Amibroker to NEST/NOW through NEST PLUS API.
You have to replace the existing buy/sell strategy with your buy/sell strategy.
Strictly do not use the buy/sell strategy in this afl for real trading.








Title = " ";
_SECTION_BEGIN("AutoTrade1V00 ");

EnableRealTimeControl = ParamList("Enable Controls", "No|Yes", 0);
EnableStrategy = ParamList("Enable Strategy", "No|Yes", 0);
StrategyType = ParamList("StrategyType", "Long/Short|Long|Short", 0);
EnableAutoTrade = ParamList("Enable Autotrade", "No|Yes", 0);
BuyPriceSelection = ParamList("Buy Price", "Bid Price|Ask Price|LTP", 0);
SellPriceSelection = ParamList("Sell Price", "Ask Price|Bid Price|LTP", 0);
ProductType = ParamList("Product Type", "MIS|NRML", 0);
OrderType = ParamList("Order Type", "LIMIT|MARKET", 0);
ClientIdValue = ParamStr("Client Id", "CLIENTID");
LotQuantity = Param("Lot Quantity", 1000, 50, 100000, 10); 
X2 = Param("Button X Offset", 0, 0, 2000, 100);
Y2 = Param("Button Y Offset", 0, 0, 2000, 100);
X1 = Param("Button Size", 100, 100, 300, 50);

Buy = 0;
Sell = 0;
Short = 0;
Cover = 0;

if(EnableStrategy == "Yes")
{


Buy = Cross(MACD(12, 26), Signal(12, 26, 9));
Sell = Cross(Signal(12, 26, 9), MACD(12, 26));

Short = Cross(Signal(12, 26, 9), MACD(12, 26));
Cover = Cross(MACD(12, 26), Signal(12, 26, 9));


}


if(EnableAutoTrade == "Yes" && EnableRealTimeControl == "Yes")
{
    if(StaticVarGetText("firstflagforNest")=="")
    {
        nestplus = Null;
        if(IsNull(nestplus))
        {
            nestplus = CreateStaticObject("Nest.PlusApi");
            nestplus.SetObjectName("AutoTrade");
        }
        StaticVarSetText ("firstflagforNest","0", 1);
    }
   
}

X0 = 20;
Y0 = 10;
procedure DashBoard (Text, x1, y1, x2, y2, colorFrom, colorTo)
{
    GfxSetOverlayMode(0);
    GfxSelectFont("Segoe UI", 8.5, 500);
    GfxSetBkMode(1);
    GfxGradientRect(x1, y1, x2, y2, colorFrom, colorTo);
    GfxDrawText(Text, x1, y1, x2, y2, 32|0|4|16);
}
GfxSetTextColor(colorWhite);

DashBoard (" Strategy: " + EnableStrategy, X0, Y0, X0+150, Y0+13, colorGrey40, colorGrey40);
DashBoard (" Strategy Type: " + StrategyType, X0, Y0+13, X0+150, Y0+26, colorGrey40, colorGrey40);
DashBoard (" Auto Trade: " + EnableAutoTrade, X0, Y0+26, X0+150, Y0+38, colorGrey40, colorGrey40);
DashBoard (" Buy Price: " + BuyPriceSelection, X0, Y0+38, X0+150, Y0+50, colorGrey40, colorGrey40);
DashBoard (" Sell Price: " + SellPriceSelection, X0, Y0+50, X0+150, Y0+62, colorGrey40, colorGrey40);
DashBoard (" Product Type: " + ProductType, X0, Y0+62, X0+150, Y0+75, colorGrey40, colorGrey40);
DashBoard (" Order Type: " + OrderType, X0, Y0+75, X0+150, Y0+88, colorGrey40, colorGrey40);
DashBoard ("", X0+1, Y0+88, X0+149, Y0+89, colorRed, colorRed);
GfxSetTextColor(colorAqua);
DashBoard (" ", X0, Y0+89, X0+150, Y0+105, colorBlack, colorBlack);

X0 = 180;
Y0 = 10;
procedure DrawData (Text, x1, y1, x2, y2, colorFrom, colorTo)
{
    GfxSetOverlayMode(0);
    GfxSelectFont("Segoe UI", 8.5, 600);
    GfxSetBkMode(1);
    GfxGradientRect(x1, y1, x2, y2, colorFrom, colorTo);
    GfxDrawText(Text, x1, y1, x2, y2, 32|0|4|16);
}
GfxSetTextColor(colorWhite);
DrawData (" " + Name(), X0, Y0, X0+200, Y0+15, colorGrey40, colorGrey40);
DrawData (" " + Date(), X0+205, Y0, X0+360, Y0+15, colorGrey40, colorGrey40);
DrawData (" Open : " + Open, X0+365, Y0, X0+505, Y0+15, colorGrey40, colorGrey40);
DrawData (" Close : " + Close, X0+510, Y0, X0+650, Y0+15, colorGrey40, colorGrey40);
DrawData (" High : " + High, X0+655, Y0, X0+795, Y0+15, colorGrey40, colorGrey40);
DrawData (" Low : " + Low, X0+800, Y0, X0+940, Y0+15, colorGrey40, colorGrey40);
DrawData (" Volume : " + NumToStr(Volume,1,0), X0+945, Y0, X0+1100, Y0+15, colorGrey40, colorGrey40);
DrawData (" % Change : " + NumToStr( (((C-O)*100)/O), 1.2, True), X0+1105, Y0, X0+1235, Y0+15, colorGrey40, colorGrey40);

if(StaticVarGetText("firstflag")=="")
{
    StaticVarSet("OrderNo", 0);
   
    StaticVarSetText ("firstflag","0");
}

if(StaticVarGetText("firstflag"+Name())=="")
{
    StaticVarSet(("BuyIndex" + Name()), 0);
    StaticVarSet(("BuyCount" + Name()), 0);
    StaticVarSet(("BuyFlag"  + Name()), 0);
    StaticVarSet(("BuyPrice"  + Name()), 0);
    StaticVarSet(("BuyQty"  + Name()), 0);
   
    StaticVarSet(("SellIndex" + Name()), 0);
    StaticVarSet(("SellCount" + Name()), 0);
    StaticVarSet(("SellFlag"  + Name()), 0);
    StaticVarSet(("SellPrice"  + Name()), 0);
    StaticVarSet(("SellQty"  + Name()), 0);
   
    StaticVarSet(("ShortIndex" + Name()), 0);
    StaticVarSet(("ShortCount" + Name()), 0);
    StaticVarSet(("ShortFlag"  + Name()), 0);
    StaticVarSet(("ShortPrice"  + Name()), 0);
    StaticVarSet(("ShortQty"  + Name()), 0);
   
    StaticVarSet(("CoverIndex" + Name()), 0);
    StaticVarSet(("CoverCount" + Name()), 0);
    StaticVarSet(("CoverFlag"  + Name()), 0);
    StaticVarSet(("CoverPrice"  + Name()), 0);
    StaticVarSet(("CoverQty"  + Name()), 0);
   
    StaticVarSet("LTPSave" + Name(), 0);
    StaticVarSet("LTQSave" + Name(), 0);
    StaticVarSet("VolumeTemp" + Name(), 0);
    StaticVarSet("AskSave" + Name(), 0);
    StaticVarSet("BidSave" + Name(), 0);
   
    StaticVarSet("LastLTPColor" + Name(), colorGrey40);
    StaticVarSet("LastLTQColor" + Name(), colorGrey40);
    StaticVarSet("LastAskColor" + Name(), colorGrey40);
    StaticVarSet("LastBidColor" + Name(), colorGrey40);
   
    StaticVarSetText("firstflag"+Name(), "0");
}

CurrentAskPrice = LastValue(Aux1);
CurrentBidPrice = LastValue(Aux2);
CurrentTradedPrice = LastValue(C);
CurrentVolume = LastValue(Volume);

if(BuyPriceSelection == "Bid Price")
{
    BuyPriceValue = CurrentBidPrice;
}
else if(BuyPriceSelection == "Ask Price")
{
    BuyPriceValue = CurrentAskPrice;
}
else
{
    BuyPriceValue = CurrentTradedPrice;
}

if(SellPriceSelection == "Ask Price")
{
    SellPriceValue = CurrentAskPrice;
}
else if(SellPriceSelection == "Bid Price")
{
    SellPriceValue = CurrentBidPrice;
}
else
{
    SellPriceValue = CurrentTradedPrice;
}

LTPTemp = StaticVarGet("LTPSave" + Name());
LTQTemp = StaticVarGet("LTQSave" + Name());
VolumeTemp = StaticVarGet("VolumeTemp" + Name());
AskTemp = StaticVarGet("AskSave" + Name());
BidTemp = StaticVarGet("BidSave" + Name());

CurrentLTQ = (CurrentVolume - VolumeTemp);

if(CurrentLTQ < 0)
{
    CurrentLTQ = CurrentLTQ * -1;
}

if(CurrentLTQ == 0)
{
    CurrentLTQ = LTQTemp;
}

LTPColor = StaticVarGet("LastLTPColor" + Name());
LTQColor = StaticVarGet("LastLTQColor" + Name());
AskColor = StaticVarGet("LastAskColor" + Name());
BidColor = StaticVarGet("LastBidColor" + Name());


if(LTPTemp > CurrentTradedPrice)
{
    LTPColor = colorRed;
}
else if(LTPTemp < CurrentTradedPrice)
{
    LTPColor = colorGreen;
}

if(LTQTemp > CurrentLTQ)
{
    LTQColor = colorRed;
}
else if(LTQTemp < CurrentLTQ)
{
    LTQColor = colorGreen;
}

if(AskTemp > CurrentAskPrice)
{
    AskColor = colorRed;
}
else if(AskTemp < CurrentAskPrice)
{
    AskColor = colorGreen;
}

if(BidTemp > CurrentBidPrice)
{
    BidColor = colorRed;
}
else if(BidTemp < CurrentBidPrice)
{
    BidColor = colorGreen;
}

StaticVarSet("LastLTPColor" + Name(), LTPColor);
StaticVarSet("LastLTQColor" + Name(), LTQColor);
StaticVarSet("LastAskColor" + Name(), AskColor);
StaticVarSet("LastBidColor" + Name(), BidColor);

StaticVarSet("LTPSave" + Name(), CurrentTradedPrice);
StaticVarSet("LTQSave" + Name(), CurrentLTQ);
StaticVarSet("VolumeTemp" + Name(), CurrentVolume);
StaticVarSet("AskSave" + Name(), CurrentAskPrice);
StaticVarSet("BidSave" + Name(), CurrentBidPrice);


X0 = X2 + 20;
Y0 = Y2 + 120;
LBClick = GetCursorMouseButtons() == 9;    // Click
MouseX  = Nz(GetCursorXPosition(1));        //
MouseY  = Nz(GetCursorYPosition(1));        //



procedure DrawBut (Text, x1, y1, x2, y2, colorFrom, colorTo)
{
    GfxSetOverlayMode(0);
    GfxSelectFont("Segoe UI", 9, 700);
    GfxSetBkMode(1);
    GfxGradientRect(x1, y1, x2, y2, colorFrom, colorTo);
    GfxDrawText(Text, x1, y1, x2, y2, 32|1|4|16);
}
GfxSetTextColor(colorWhite);

if(EnableRealTimeControl == "Yes")
{

    DrawBut ("Buy", X0, Y0, X0+X1, Y0+30, colorGreen, colorGreen);
    CursorInBuyButton = MouseX >= X0 AND MouseX <= X0+X1 AND MouseY >= Y0 AND MouseY <= Y0+30;
    BuyButtonClick = CursorInBuyButton AND LBClick;
    if (BuyButtonClick || NumPad7 )
    {
        TempBuy = Buy;
        Buy = IIf((DateTime() == LastValue(DateTime())) || (TempBuy == True), True, False);
    }

    DrawBut ("Sell", X0, Y0+40, X0+X1, Y0+70, colorRed, colorRed);
    CursorInSellButton = MouseX >= X0 AND MouseX <= X0+X1 AND MouseY >= Y0+40 AND MouseY <= Y0+70;
    SellButtonClick = CursorInSellButton AND LBClick;
    if (SellButtonClick || NumPad8)
    {
        TempSell = Sell;
        Sell = IIf((DateTime() == LastValue(DateTime())) || (TempSell == True), True, False);
    }
   
    DrawBut ("Short", X0, Y0+80, X0+X1, Y0+110, colorOrange, colorOrange);
    CursorInShortButton = MouseX >= X0 AND MouseX <= X0+X1 AND MouseY >= Y0+80 AND MouseY <= Y0+110;
    ShortButtonClick = CursorInShortButton AND LBClick;
    if (ShortButtonClick || NumPad4)
    {
        TemShort = Short;
        Short = IIf((DateTime() == LastValue(DateTime())) || (TemShort == True), True, False);
    }

    DrawBut ("Cover", X0, Y0+120, X0+X1, Y0+150, colorTurquoise, colorTurquoise);
    CursorInCoverButton = MouseX >= X0 AND MouseX <= X0+X1 AND MouseY >= Y0+120 AND MouseY <= Y0+150;
    CoverButtonClick = CursorInCoverButton AND LBClick;
    if (CoverButtonClick || NumPad5)
    {
        TempCover = Cover;
        Cover = IIf((DateTime() == LastValue(DateTime())) || (TempCover == True), True, False);
    }

    DrawBut ("Clear Data", X0, Y0+160, X0+X1, Y0+190, colorGrey40, colorGrey40);
    CursorInClearButton = MouseX >= X0 AND MouseX <= X0+X1 AND MouseY >= Y0+160 AND MouseY <= Y0+190;
    ClearButtonClick = CursorInClearButton AND LBClick;
    if (ClearButtonClick || NumPad0 )
    {
        DrawBut("Clear", X0+X1+10, Y0, X0+X1+75, Y0+30,  colorGrey40, colorGrey40);

        StaticVarSetText("firstflag"+Name(), "");
    }
   
    //TempBuy = Buy;
    TempBuy = IIf((DateTime() == LastValue(DateTime())) && (LastValue(Buy) == True), True, False);
    BuyTempData = StaticVarGet("BuyIndex" + Name());
    TempCount = StaticVarGet("BuyCount" + Name());
    BuyPrevTemp = 0;
    for(i = 0; i <= TempCount; i++)
    {
        BuyPrevTemp = BuyPrevTemp | (IIf(DateTime() == BuyTempData[i], True, False));
    }
    Buy = IIf(((BuyPrevTemp == True) || (TempBuy == True)), True, False);
   
    //TempSell = Sell;
    TempSell = IIf((DateTime() == LastValue(DateTime())) && (LastValue(Sell) == True), True, False);
    SellTempData = StaticVarGet("SellIndex" + Name());
    TempCount = StaticVarGet("SellCount" + Name());
    SellPrevTemp = 0;
    for(i = 0; i <= TempCount; i++)
    {
        SellPrevTemp = SellPrevTemp | (IIf(DateTime() == SellTempData[i], True, False));
    }
    TempCount = StaticVarGet("BuyCount" + Name());
    Sell = IIf((TempCount > 0) && ((SellPrevTemp == True) || (TempSell == True)), True, False);
   
    //TempShort = Short;
    TempShort = IIf((DateTime() == LastValue(DateTime())) && (LastValue(Short) == True), True, False);
    ShortTempData = StaticVarGet("ShortIndex" + Name());
    TempCount = StaticVarGet("ShortCount" + Name());
    ShortPrevTemp = 0;
    for(i = 0; i <= TempCount; i++)
    {
        ShortPrevTemp = ShortPrevTemp | (IIf(DateTime() == ShortTempData[i], True, False));
    }
    Short = IIf(((ShortPrevTemp == True) || (TempShort == True)), True, False);
   
    //TempCover = Cover;
    TempCover = IIf((DateTime() == LastValue(DateTime())) && (LastValue(Cover) == True), True, False);
    CoverTempData = StaticVarGet("CoverIndex" + Name());
    TempCount = StaticVarGet("CoverCount" + Name());
    CoverPrevTemp = 0;
    for(i = 0; i <= TempCount; i++)
    {
        CoverPrevTemp = CoverPrevTemp | (IIf(DateTime() == CoverTempData[i], True, False));
    }
    TempCount = StaticVarGet("ShortCount" + Name());
    Cover = IIf((TempCount > 0) && ((CoverPrevTemp == True) || (TempCover == True)), True, False);
   
}

if(StrategyType == "Long")
{
    Short = 0;
    Cover = 0;
}
else if(StrategyType == "Short")
{
    Buy = 0;
    Sell = 0;
}

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

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

Buyshape = Buy * shapeUpArrow;
SellShape = Sell * shapeDownArrow;
PlotShapes( Buyshape, colorBrightGreen, 0, Low );
PlotShapes( SellShape, colorRed, 0, High );

Shortshape = Short * shapeDownArrow;
CoverShape = Cover * shapeUpArrow;
PlotShapes( Shortshape, colorOrange, 0, High, -30);
PlotShapes( CoverShape, colorTurquoise, 0, Low, -30 );

GraphXSpace = 5;
   
   
if(EnableRealTimeControl == "Yes")
{
    if((LastValue(Buy) == True) && (StaticVarGet(("BuyFlag" + Name())) != LastValue(DateTime())))
    {
        StaticVarSet(("BuyFlag" + Name()), LastValue(DateTime()));
        DrawBut("Buy", X0+X1+10, Y0, X0+X1+75, Y0+30,  colorGrey40, colorGrey40);
        TempCount = StaticVarGet("BuyCount" + Name());
        TempIndex = StaticVarGet("BuyIndex" + Name());
        TempPrice = StaticVarGet("BuyPrice"  + Name());
        TempQty = StaticVarGet("BuyQty"  + Name());
        TempIndex[TempCount] = LastValue(DateTime());
        TempPrice[TempCount] = BuyPriceValue;
        TempQty[TempCount] = LotQuantity;
        TempCount++;
        StaticVarSet("BuyCount" + Name(), TempCount);
        StaticVarSet(("BuyIndex" + Name()), TempIndex);
        StaticVarSet(("BuyPrice" + Name()), TempPrice);
        StaticVarSet(("BuyQty" + Name()), TempQty);
       
        if(EnableAutoTrade == "Yes")
        {
            LastOrderNo = StaticVarGet("OrderNo");
            LastOrderNo++;
            StaticVarSet("OrderNo", LastOrderNo);
            TempOrderNo = ClientIdValue + NumToStr(Now(3),1,0) + "00" + LastOrderNo;
            TempName = Name() + "-EQ";
            nestplus.PlaceOrder("BUY", TempOrderNo, "NSE", TempName, "DAY", OrderType, LotQuantity, BuyPriceValue, 0.0, 0, ProductType, ClientIdValue);
        }
    }

    if((LastValue(Sell) == True) && (StaticVarGet(("SellFlag" + Name())) != LastValue(DateTime())))
    {
        StaticVarSet(("SellFlag" + Name()), LastValue(DateTime()));
        DrawBut("Sell", X0+X1+10, Y0, X0+X1+75, Y0+30,  colorGrey40, colorGrey40);
        TempCount = StaticVarGet("SellCount" + Name());
        TempIndex = StaticVarGet("SellIndex" + Name());
        TempPrice = StaticVarGet("SellPrice"  + Name());
        TempQty = StaticVarGet("SellQty"  + Name());
        TempIndex[TempCount] = LastValue(DateTime());
        TempPrice[TempCount] = SellPriceValue;
        TempQty[TempCount] = LotQuantity;
        TempCount++;
        StaticVarSet("SellCount" + Name(), TempCount);
        StaticVarSet(("SellIndex" + Name()), TempIndex);
        StaticVarSet(("SellPrice" + Name()), TempPrice);
        StaticVarSet(("SellQty" + Name()), TempQty);
       
        if(EnableAutoTrade == "Yes")
        {
            LastOrderNo = StaticVarGet("OrderNo");
            LastOrderNo++;
            StaticVarSet("OrderNo", LastOrderNo, 1);
            TempOrderNo = ClientIdValue + NumToStr(Now(3),1,0) + "00" + LastOrderNo;
            TempName = Name() + "-EQ";
            nestplus.PlaceOrder("SELL", TempOrderNo, "NSE", TempName, "DAY", OrderType, LotQuantity, SellPriceValue, 0.0, 0, ProductType, ClientIdValue);
        }
    }
   
    if((LastValue(Short) == True) && (StaticVarGet(("ShortFlag" + Name())) != LastValue(DateTime())))
    {
        StaticVarSet(("ShortFlag" + Name()), LastValue(DateTime()));
        DrawBut("Short", X0+X1+10, Y0, X0+X1+75, Y0+30,  colorGrey40, colorGrey40);
        TempCount = StaticVarGet("ShortCount" + Name());
        TempIndex = StaticVarGet("ShortIndex" + Name());
        TempPrice = StaticVarGet("ShortPrice"  + Name());
        TempQty = StaticVarGet("ShortQty"  + Name());
        TempIndex[TempCount] = LastValue(DateTime());
        TempPrice[TempCount] = SellPriceValue;
        TempQty[TempCount] = LotQuantity;
        TempCount++;
        StaticVarSet("ShortCount" + Name(), TempCount);
        StaticVarSet(("ShortIndex" + Name()), TempIndex);
        StaticVarSet(("ShortPrice" + Name()), TempPrice);
        StaticVarSet(("ShortQty" + Name()), TempQty);
       
        if(EnableAutoTrade == "Yes")
        {
            LastOrderNo = StaticVarGet("OrderNo");
            LastOrderNo++;
            StaticVarSet("OrderNo", LastOrderNo);
            TempOrderNo = ClientIdValue + NumToStr(Now(3),1,0) + "00" + LastOrderNo;
            TempName = Name() + "-EQ";
            nestplus.PlaceOrder("SELL", TempOrderNo, "NSE", TempName, "DAY", OrderType, LotQuantity, SellPriceValue, 0.0, 0, ProductType, ClientIdValue);
        }
    }

    if((LastValue(Cover) == True) && (StaticVarGet(("CoverFlag" + Name())) != LastValue(DateTime())))
    {
        StaticVarSet(("CoverFlag" + Name()), LastValue(DateTime()));
        DrawBut("Cover", X0+X1+10, Y0, X0+X1+75, Y0+30,  colorGrey40, colorGrey40);
        TempCount = StaticVarGet("CoverCount" + Name());
        TempIndex = StaticVarGet("CoverIndex" + Name());
        TempPrice = StaticVarGet("CoverPrice"  + Name());
        TempQty = StaticVarGet("CoverQty"  + Name());
        TempIndex[TempCount] = LastValue(DateTime());
        TempPrice[TempCount] = BuyPriceValue;
        TempQty[TempCount] = LotQuantity;
        TempCount++;
        StaticVarSet("CoverCount" + Name(), TempCount);
        StaticVarSet(("CoverIndex" + Name()), TempIndex);
        StaticVarSet(("CoverPrice" + Name()), TempPrice);
        StaticVarSet(("CoverQty" + Name()), TempQty);
       
        if(EnableAutoTrade == "Yes")
        {
            LastOrderNo = StaticVarGet("OrderNo");
            LastOrderNo++;
            StaticVarSet("OrderNo", LastOrderNo, 1);
            TempOrderNo = ClientIdValue + NumToStr(Now(3),1,0) + "00" + LastOrderNo;
            TempName = Name() + "-EQ";
            nestplus.PlaceOrder("BUY", TempOrderNo, "NSE", TempName, "DAY", OrderType, LotQuantity, BuyPriceValue, 0.0, 0, ProductType, ClientIdValue);
        }
    }
}
   
X0 = 180;
Y0 = 30;

if(EnableRealTimeControl == "Yes")
{
    TotPrice = 0;
    TotQty = 0;
    TotVal = 0;
    TempPriceArray = StaticVarGet("BuyPrice" + Name());
    TempQtyArray = StaticVarGet("BuyQty" + Name());
    TempCount = StaticVarGet("BuyCount" + Name());
    for(i = 0; i < TempCount; i++)
    {
        TotPrice = TotPrice + TempPriceArray[i];
        TotQty = TotQty + TempQtyArray[i];
        TotVal = TotVal + TempPriceArray[i] * TempQtyArray[i];
    }
    if(TempCount == 0)
    {
        AvgBuyPrice = 0;
        LastBuyPrice = 0;
        LastBuyQty = 0;
    }
    else
    {
        AvgBuyPrice = (TotPrice / TempCount);
        LastBuyPrice = TempPriceArray[(TempCount - 1)];
        LastBuyQty = NumToStr(TempQtyArray[(TempCount - 1)], 1, 0);
    }
    TotBuyQty = NumToStr(TotQty, 1, 0);
    NetBuyQty = TotQty;
    NetBuyValue = TotVal;
   
    TotPrice = 0;
    TotQty = 0;
    TotVal = 0;
    TempPriceArray = StaticVarGet("SellPrice" + Name());
    TempQtyArray = StaticVarGet("SellQty" + Name());
    TempCount = StaticVarGet("SellCount" + Name());
    for(i = 0; i < TempCount; i++)
    {
        TotPrice = TotPrice + TempPriceArray[i];
        TotQty = TotQty + TempQtyArray[i];
        TotVal = TotVal + TempPriceArray[i] * TempQtyArray[i];
    }
    if(TempCount == 0)
    {
        AvgSellPrice = 0;
        LastSellPrice = 0;
        LastSellQty = 0;
    }
    else
    {
        AvgSellPrice = (TotPrice / TempCount);
        LastSellPrice = TempPriceArray[(TempCount - 1)];
        LastSellQty = NumToStr(TempQtyArray[(TempCount - 1)], 1, 0);
    }
    TotSellQty = NumToStr(TotQty, 1, 0);
    NetSellQty = TotQty;
    NetSellValue = TotVal;
   
    TotPrice = 0;
    TotQty = 0;
    TotVal = 0;
    TempPriceArray = StaticVarGet("ShortPrice" + Name());
    TempQtyArray = StaticVarGet("ShortQty" + Name());
    TempCount = StaticVarGet("ShortCount" + Name());
    for(i = 0; i < TempCount; i++)
    {
        TotPrice = TotPrice + TempPriceArray[i];
        TotQty = TotQty + TempQtyArray[i];
        TotVal = TotVal + TempPriceArray[i] * TempQtyArray[i];
    }
    if(TempCount == 0)
    {
        AvgShortPrice = 0;
        LastShortPrice = 0;
        LastShortQty = 0;
    }
    else
    {
        AvgShortPrice = (TotPrice / TempCount);
        LastShortPrice = TempPriceArray[(TempCount - 1)];
        LastShortQty = NumToStr(TempQtyArray[(TempCount - 1)], 1, 0);
    }
    TotShortQty = NumToStr(TotQty, 1, 0);
    NetShortQty = TotQty;
    NetShortValue = TotVal;
   
    TotPrice = 0;
    TotQty = 0;
    TotVal = 0;
    TempPriceArray = StaticVarGet("CoverPrice" + Name());
    TempQtyArray = StaticVarGet("CoverQty" + Name());
    TempCount = StaticVarGet("CoverCount" + Name());
    for(i = 0; i < TempCount; i++)
    {
        TotPrice = TotPrice + TempPriceArray[i];
        TotQty = TotQty + TempQtyArray[i];
        TotVal = TotVal + TempPriceArray[i] * TempQtyArray[i];
    }
    if(TempCount == 0)
    {
        AvgCoverPrice = 0;
        LastCoverPrice = 0;
        LastCoverQty = 0;
    }
    else
    {
        AvgCoverPrice = (TotPrice / TempCount);
        LastCoverPrice = TempPriceArray[(TempCount - 1)];
        LastCoverQty = NumToStr(TempQtyArray[(TempCount - 1)], 1, 0);
    }
    TotCoverQty = NumToStr(TotQty, 1, 0);
    NetCoverQty = TotQty;
    NetCoverValue = TotVal;
   
    NetQty = NetSellQty - NetBuyQty + NetShortQty - NetCoverQty;
    NetValue = NetSellValue - NetBuyValue + NetShortValue - NetCoverValue;
   
    NetQuantityColor = colorGrey40;
    NetValueColor = colorGrey40;

    if(NetQty > 0)
    {
        NetQuantityColor = colorRed;
        NetValueColor = colorRed;
    }
    else if(NetQty < 0)
    {
        NetQuantityColor = colorGreen;
        NetValueColor = colorGreen;
    }
    else if(NetQty == 0)
    {
        if(NetValue > 0)
        {
            NetValueColor = colorGreen;
        }
        else if(NetValue < 0)
        {
            NetValueColor = colorRed;
        }
    }
   
    DrawData (" AvgBuyPr: " + AvgBuyPrice, X0, Y0, X0+150, Y0+15, colorGrey40, colorGrey40);
    DrawData (" TotBuyQty: " + TotBuyQty, X0+155 , Y0, X0+305, Y0+15, colorGrey40, colorGrey40);
    DrawData (" AvgSellPr: " + AvgSellPrice, X0+310, Y0, X0+460, Y0+15, colorGrey40, colorGrey40);
    DrawData (" TotSellQty: " + TotSellQty, X0+465, Y0, X0+615, Y0+15, colorGrey40, colorGrey40);
    DrawData (" AvgShortPr: " + AvgShortPrice, X0+620, Y0, X0+770, Y0+15, colorGrey40, colorGrey40);
    DrawData (" TotShortQty: " + TotShortQty, X0+775 , Y0, X0+925, Y0+15, colorGrey40, colorGrey40);
    DrawData (" AvgCoverPr: " + AvgCoverPrice, X0+930, Y0, X0+1080, Y0+15, colorGrey40, colorGrey40);
    DrawData (" TotCoverQty: " + TotCoverQty, X0+1085, Y0, X0+1235, Y0+15, colorGrey40, colorGrey40);
   
    Y0 = 50;
   
    DrawData (" LastBuyPr: " + LastBuyPrice, X0, Y0, X0+150, Y0+15, colorGrey40, colorGrey40);
    DrawData (" LastBuyQty: " + LastBuyQty, X0+155 , Y0, X0+305, Y0+15, colorGrey40, colorGrey40);
    DrawData (" LastSellPr: " + LastSellPrice, X0+310, Y0, X0+460, Y0+15, colorGrey40, colorGrey40);
    DrawData (" LastSellQty: " + LastSellQty, X0+465, Y0, X0+615, Y0+15, colorGrey40, colorGrey40);
    DrawData (" LastShortPr: " + LastShortPrice, X0+620, Y0, X0+770, Y0+15, colorGrey40, colorGrey40);
    DrawData (" LastShortQty: " + LastShortQty, X0+775 , Y0, X0+925, Y0+15, colorGrey40, colorGrey40);
    DrawData (" LastCoverPr: " + LastCoverPrice, X0+930, Y0, X0+1080, Y0+15, colorGrey40, colorGrey40);
    DrawData (" LastCoverQty: " + LastCoverQty, X0+1085, Y0, X0+1235, Y0+15, colorGrey40, colorGrey40);
   
    Y0 = 70;
   
    DrawData (" LTP : " + CurrentTradedPrice, X0, Y0, X0+125, Y0+15, LTPColor, LTPColor);
    DrawData (" LTQ : " + NumToStr(CurrentLTQ,1,0), X0+130, Y0, X0+255, Y0+15, LTQColor, LTQColor);
    DrawData (" Bid : " + CurrentBidPrice, X0+260, Y0, X0+385, Y0+15, AskColor, AskColor);
    DrawData (" Ask : " + CurrentAskPrice, X0+390, Y0, X0+515, Y0+15, BidColor, BidColor);
   
    NestOredrNo = ClientIdValue + NumToStr(Now(3),1,0) + "00" + StaticVarGet("OrderNo");
    DrawData (" NetQty : " + NetQty, X0+520, Y0, X0+670, Y0+15, NetQuantityColor, NetQuantityColor);
    DrawData (" NetValue : " + NetValue, X0+675, Y0, X0+900, Y0+15, NetValueColor, NetValueColor);
    DrawData (" Order No : " + NestOredrNo, X0+905, Y0, X0+1150, Y0+15, colorGrey40, colorGrey40);
   
}

_SECTION_END();



_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
//_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} \nOpen : %g, Close : %g (%.1f%%) \nLow : %g, High : %g (%.1f%%) \nVolume : " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, C,(((C-O)*100)/O), L, H, (((H-L)*100)/L) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();

_SECTION_BEGIN("MA");
P = ParamField("Price field",-1);
Periods = Param("Periods", 10, 2, 200, 1 );
Plot( MA( P, Periods ), /*_DEFAULT_NAME()*/ "", ParamColor( "Color", colorGreen ), ParamStyle("Style", styleLine | styleNoLabel ) | styleNoRescale );
_SECTION_END();

_SECTION_BEGIN("EMA");
P = ParamField("Price field",-1);
Periods = Param("Periods", 30, 2, 300, 1, 10 );
Plot( EMA( P, Periods ), /*_DEFAULT_NAME()*/ "", ParamColor( "Color", colorOrange ), ParamStyle("Style", styleLine | styleNoLabel) | styleNoRescale );
_SECTION_END();

_SECTION_BEGIN("Long MA");
P = ParamField("Price field",-1);
Periods = Param("Periods", 45, 2, 400, 1 );
Plot( MA( P, Periods ), /*_DEFAULT_NAME()*/ "", ParamColor( "Color", colorYellow ), ParamStyle("Style", styleLine | styleNoLabel ) | styleNoRescale );
_SECTION_END();

_SECTION_BEGIN("BBands");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 100, 1 );
Width = Param("Width", 2, 0, 10, 0.05 );
Color = ParamColor("Color", colorLightGrey );
Color = ColorBlend( Color,  GetChartBkColor(), 0.5 );
Style = ParamStyle("Style", styleLine | styleNoLabel ) | styleNoRescale;;
Plot( bbt = BBandTop( P, Periods, Width ), /*"BBTop" + _PARAM_VALUES()*/ "", Color, Style );
Plot( bbb = BBandBot( P, Periods, Width ), /*"BBBot" + _PARAM_VALUES()*/ "", Color, Style );
PlotOHLC( bbt, bbt, bbb, bbb, "", ColorBlend( Color, GetChartBkColor(), 0.7 ), styleNoLabel | styleCloud | styleNoRescale, Null, Null, Null, -1 );
_SECTION_END();

_SECTION_BEGIN("Volume");
Color = ParamColor("Color", ColorRGB( 128, 128, 192 ) );
Plot( Volume, /*_DEFAULT_NAME()*/"", ColorBlend( Color, GetChartBkColor(), 0.2  ), styleNoTitle | ParamStyle( "Style", styleHistogram | styleOwnScale | styleThick | styleNoLabel, maskHistogram  ), 2 );
_SECTION_END();