Bbband+adx - Evening Code
Bbband+adx - Evening Code
drt = StDev(C,22)-ATR(15);
range = Param("Periods", 10, 2, 200, 1 );
iadx = HMA(ADX(range),10);
inc = iadx > Ref(iadx,-1);
dec = iadx < Ref(iadx,-1);
//SetChartBkColor(ColorBlend(colorGrey40,colorBlack));
color = IIf(inc AND iadx >40, colorBlue, IIf(inc AND iadx > 30, colorGreen, IIf(inc
AND iadx > 20,colorbrightGreen, IIf(inc, colorPaleGreen,
IIf(dec AND iadx >40, colorBrown, IIf(dec AND iadx > 30 ,
colorDarkRed, IIf(dec AND iadx > 20 , colorRed, IIf(dec,
colorLightOrange,colorGrey40))))))));
Bollitop = BBandTop(C,20,2);
Bollibottom = BBandBot(C,20,2);
Cbuy= C1 OR C2 OR C3;
Cshort = C1 OR C2 OR C3 ;
TimeRange = ParamToggle("Time","No|Yes");
Starttime = Param("Starttime",093000,090000,235500,0);
Closetime = Param("Closetime",144000,100000,235500,0);
ExitToday = (Ref(DateNum(),1) > DateNum());
B1= High > Bollitop AND High > Ref(Close,-1) AND Cbuy AND RSI(10)>60 AND
ADX(10)>25 AND drt >0 ;
S1 = Close<EMA(Close,10) ;
Sh1 = Low < Bollibottom AND Cshort AND RSI(10)<40 AND ADX(10)>25 AND drt >0 ;
Co1 = Close>EMA(Close,10) ;
Buy= ExRem(Buy,Sell);
Sell= ExRem(Sell,Buy);
_SECTION_END();
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle |
ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();
if(delay)
{Buy=Ref(Buy,-1); Sell=Ref(Sell,-1); Short= Ref(Short,-1); Cover= Ref(Cover,-1);}
global algoji;
algoji = Name() + NumToStr( Interval() / 60, 1.0, False ) ;
return Var;
}
sym = Name();
//_TRACE("t"+t);
Checkdt=Nz(aStaticVarGet("lastdt"));
dt = LastValue( DateTime() );
Checkdtss=Nz(aStaticVarGet("lastdtss"));
dtss = LastValue( DateTime() );
Checkdtc=Nz(aStaticVarGet("lastdtc"));
dtc = LastValue( DateTime() );
Checkdts=Nz(aStaticVarGet("lastdts"));
dts = LastValue( DateTime() );
RTBuy = LastValue( Buy) AND Checkdt != dt;
RTShort = LastValue( Short) AND Checkdtss != dtss;
RTCover = LastValue( Cover) AND Checkdtc != dtc;
RTSell = LastValue( Sell) AND Checkdts != dts;
if ( RTCover )
{
aStaticVarSet("lastdtc",dtc );
StaticVarSet("counter", Nz(StaticVarGet("counter"))+1 );
_TRACE( "#"+Nz(StaticVarGet("counter"))+",SX,"+sym+",,," +bp
+","+qty+","+instr+",,");
Algoji_Signal(NumToStr(Nz(StaticVarGet("counter")),0,False),
"SX",sym,"M","",bp,qty,instr,stag);
}
if ( RTSell )
{
aStaticVarSet("lastdts",dts );
StaticVarSet("counter", Nz(StaticVarGet("counter"))+1 );
_TRACE( "#"+Nz(StaticVarGet("counter"))+",LX,"+sym+",,," +sp
+","+qty+",,,");
Algoji_Signal(NumToStr(Nz(StaticVarGet("counter")),0,False),
"LX",sym,"M","",sp,qty,instr,stag);
}
if ( RTBuy )
{
aStaticVarSet("lastdt",dt );
StaticVarSet("counter", Nz(StaticVarGet("counter"))+1 );
_TRACE( "#"+Nz(StaticVarGet("counter"))+",LE,"+sym+",,," +bp
+","+qty+","+instr+",,");
Algoji_Signal(NumToStr(Nz(StaticVarGet("counter")),0,False),
"LE",sym,"M","",bp,qty,instr,stag);
}
if ( RTShort )
{
aStaticVarSet("lastdtss",dtss );
StaticVarSet("counter", Nz(StaticVarGet("counter"))+1 );
sp= NumToStr(Close[BarCount-1],1.2, False);
_TRACE( "#"+Nz(StaticVarGet("counter"))+",SE,"+sym+",,," +sp
+","+qty+","+instr+",,");
Algoji_Signal(NumToStr(Nz(StaticVarGet("counter")),0,False),
"SE",sym,"M","",bp,qty,instr,stag);
}
function GetSecondNum()
{
Time = Now( 4 );
Seconds = int( Time % 100 );
Minutes = int( Time / 100 % 100 );
Hours = int( Time / 10000 % 100 );
SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );
return SecondNum;
}
if ( Button == 0 )
{
click = GetCursorMouseButtons() == 9;
Px = GetCursorXPosition( 1 );
Py = GetCursorYPosition( 1 );
x2 = x1 + 60;
y2 = y1 + 60;
GfxSelectSolidBrush( ColorRGB( 0, 102, 0 ) ); //buy
GfxSelectFont( "Tahoma", 13, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );
GfxRoundRect( x1, y1, x2, y2 , 7, 7 ) ;
GfxTextOut( "LE", x1 + 20, y1 + 20 );
sx1 = x2;
sy1 = y1;
sx2 = sx1 + 60;
sy2 = sy1 + 60;
GfxSelectSolidBrush( ColorRGB( 255, 204, 204 ) );//sell
GfxRoundRect( sx1, sy1, sx2, sy2 , 7, 7 ) ;
GfxSetTextColor( ColorRGB( 153, 0, 0 ) );
GfxTextOut( "SE", sx1 + 20, sy1 + 20 );
ex1 = x1;
ey1 = y1+60;
ex2 = ex1 + 60;
ey2 = ey1 + 60;
GfxSelectSolidBrush( ColorRGB( 255, 204, 204 ) );//sell
GfxRoundRect( ex1, ey1, ex2, ey2 , 7, 7 ) ;
GfxSetTextColor( ColorRGB( 153, 0, 0 ) );
GfxTextOut( "LX", ex1 + 20, ey1 + 20 );
_SECTION_BEGIN("Background text");
//C11=ParamColor("up panel",colorBlack );
C12=ParamColor("dn panel",colorBlack );
C13=Param("fonts",20,10,30,1 );
//C14=Param("left-right",2.1,1.0,5.0,0.1 );
C14=Param("left-right",3,5,5.0,0.1 );
C15=Param("up-down",8,1,30,1 );
Miny = Status("axisminy");
Maxy = Status("axismaxy");
lvb = Status("lastvisiblebar");
fvb = Status("firstvisiblebar");
pxwidth = Status("pxwidth");
pxheight = Status("pxheight");
GfxSetBkMode( 0 );
GfxSelectFont("Tahoma", 12, 500, False, False, 0);
GfxSetTextColor(colorCustom12);
GfxSetTextAlign( 6 );
GfxSelectFont("Tahoma", 15, 600, False, False, 0);
GfxSetTextColor(colorBlack);
GfxSetTextAlign( 6 );
//GfxTextOut( "LTP "+WriteVal(C,1.2), Status("pxwidth")/C15,
Status("pxheight")/C15);
GfxSelectFont("Tahoma", 10, 400, False, False, 0);
/*GfxSetTextColor(colorBrightGreen);
GfxSelectFont("Tahoma", 12, 400, False, False, 0);
GfxSetTextColor(colorRed);
GfxSelectFont("Tahoma", 12, 400, False, False, 0);
GfxSetTextColor(colorYellow);
GfxSelectFont("Tahoma", 12, 400, False, False, 0);
GfxSetTextColor(colorGreen);
GfxSelectFont("Tahoma", 12, 400, False, False, 0);
GfxSetTextColor(colorGreen);
*/
pricechange=(C-Ref(C,-1))*100/Ref(C,-1);
changeponit=C-Ref(C,-1);
Vlp=Param("Volume lookback period",15,10,300,10);
Vrg=MA(V,Vlp);
St = StDev(Vrg,Vlp);
Vp3 = Vrg + 3*st;
Vp2 = Vrg + 2*st;;
Vp1 = Vrg + 1*st;;
Vn1 = Vrg -1*st;
Vn2 = Vrg -2*st;
x=Param("xposn",1,0,1000,1);
y=Param("yposn",1,0,1000,1);
_SECTION_BEGIN("Bollinger Bands");
P = ParamField("Price field",-1);
Periods = Param("Periods",20, 2, 100, 1 );
Width = Param("Width", 2, 0, 10, 0.05 );
Color = ParamColor("Color", colorLightGrey );
Style = ParamStyle("Style", styleLine | styleNoLabel ) | styleNoLabel;
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.8 ),
styleNoLabel | styleCloud | styleNoRescale, Null, Null, Null, -1 );
_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();