Sei sulla pagina 1di 4

_SECTION_BEGIN("Adv Camarilla Levels");

// Background color
SetChartOptions(0,chartShowArrows|chartShowDates);
SetChartBkGradientFill( ParamColor("BgTop", colorWhite),
ParamColor("BgBottom", colorWhite),ParamColor("titleblock",colorWhite ));
EntrySignal = C > ( LLV( L, 20 ) + 2 * ATR( 10 ) );
ExitSignal = C < ( HHV( H, 20 ) - 2 * ATR( 10 ) );
Color = IIf( EntrySignal, colorBlue, IIf( ExitSignal, colorRed, colorGrey50 ));
Plot(C, "", IIf(O>=C, colorDarkRed, colorDarkGreen), ParamStyle("Price
Style",styleCandle,maskPrice));
//---- Camarilla pivot points
DayH = TimeFrameGetPrice("H", inDaily, -1);// yesterdays high
DayL = TimeFrameGetPrice("L", inDaily, -1);//low
DayC = TimeFrameGetPrice("C", inDaily, -1);//close
DayO = TimeFrameGetPrice("O", inDaily);// current day open
HiDay = TimeFrameGetPrice("H", inDaily);
LoDay = TimeFrameGetPrice("L", inDaily);
TimeFrameSet( inDaily );
H6 = (DayH / DayL) * DayC;
H5 = ((DayH - DayL)*0.782) + DayC;
H4 = (((DayH / DayL) + 0.83) / 1.83) * DayC;
H3 = ( ( (DayH / DayL) + 2.66) / 3.66) * DayC;
H2 = ( ( (DayH / DayL) + 4.5) / 5.5) * DayC;
H1 = ( ( (DayH / DayL) + 10) / 11) * DayC;
L1 = (2- ( ( (DayH / DayL) + 10) / 11)) * DayC;
L2 = (2-( (DayH / DayL) + 4.5) / 5.5) * DayC;
L3 = (2-(( DayH / DayL) + 2.66) / 3.66) * DayC;
L4 = (2-( (DayH / DayL) + 0.83) / 1.83) * DayC;
L5 = (DayC-( DayH - DayL)*0.782);
L6 = (2-( DayH / DayL)) * DayC;
CUEcolor = IIf( C < L2, colorBlue, colorRed);
ShowH5 = ParamToggle("H5", "No|Yes");
H5Color=ParamColor( "H5Color", colorGold );
ShowH4 = ParamToggle("H4", "yes|no");
H4Color=ParamColor( "H4Color", colorDarkRed );
ShowH3 = ParamToggle("H3", "yes|no");
H3Color=ParamColor( "H3Color", colorRed );
ShowH2 = ParamToggle("H2", "No|Yes");
H2Color=ParamColor( "H2Color", colorOrange );
ShowH1 = ParamToggle("H1", "No|Yes");
H1Color=ParamColor( "H1Color", colorOrange );
ShowL1 = ParamToggle("L1", "No|Yes");
L1Color=ParamColor( "L1Color", colorOrange );
ShowL2 = ParamToggle("L2", "No|Yes");
L2Color=ParamColor( "L2Color", colorOrange );
ShowL3 = ParamToggle("L3", "yes|no");
L3Color=ParamColor( "L3Color", colorGreen );
ShowL4 = ParamToggle("L4", "yes|no");
L4Color=ParamColor( "L4Color", colorDarkGreen );
ShowL5 = ParamToggle("L5", "No|Yes");
L5Color=ParamColor( "L5Color", colorGold );
//Shadowcolor = ParamColor("Shadow",ColorRGB(40,30,20));
//ShadowcoloH1 = ParamColor("Shadow1",ColorRGB(20,30,20));
//ShadowcoloH2 = ParamColor("Shadow2",ColorRGB(30,40,0));
//style = styleDots | styleThick + styleNoRescale ;
style = styleLine + styleNoRescale ;
if(ShowH2 == False)
Plot(H2, "H2",H2Color,styleLine);
if(ShowH1 == False)
Plot(H1, "H1",H1Color,styleLine);
if(ShowL1 == False)
Plot(L1, "L1",L1Color,styleLine);
if(ShowL2 == False)
Plot(L2, "L2",L2Color,styleLine);
ToolTip=StrFormat("Open: %g\nHigh: %g\nLow: %g\nClose: %g (%.1f%%)\nVolume:
"+NumToStr( V, 1 ), O, H, L, C, SelectedValue( ROC( C, 1)));
TimeFrameRestore();
Title = EncodeColor(colorWhite)+ "Amibroker Afl Collections group" + " - " + Name()
+ " - " + EncodeColor(colorWhite)+ Interval(2) + EncodeColor(colorWhite) +
" - " + Date() +" - "
//+ WriteIf(Col_action==colorGreen, EncodeColor(colorGreen)+"stay LONG","")+
WriteIf(Col_action==colorRed, EncodeColor(colorRed)+"stay SHORT","")+
WriteIf(Col_action==colorBlack, EncodeColor(colorYellow)+"No Trend","")+"\n"
+ "Vol= "+ WriteVal(V) +WriteIf ( V > MA(V,26) ,EncodeColor(colorWhite)+" UP "+
(V/MA(V,26))*100 + " %", EncodeColor(colorWhite)+" DOWN "+ (V/MA(V,26))*100 + " %")
+ EncodeColor(colorBlack)+ "\n H2: "+ EncodeColor(colorBlack)+H2
+ EncodeColor(colorBlack)+ "\n H1: "+ EncodeColor(colorBlack)+H1
+ EncodeColor(colorBlack)+ "\n L1: "+ EncodeColor(colorBlack)+L1
+ EncodeColor(colorBlack)+ "\n L2: "+ EncodeColor(colorBlack)+L2
+ EncodeColor(colorBlue) +"\n buy/" +EncodeColor(colorRed) +"sell- "
+EncodeColor(SelectedValue(CUEcolor)) + C;
//+ EncodeColor(colorBlack)+ "\n L7: "+ EncodeColor(colorBlack)+L7 ;
_SECTION_END();
Pt= Param("camarilla range",0.10,0.10,5,0.10);
UPH1= H1*(1+Pt/100);
DnH1= H1*(1-Pt/100);
UPH2= H2*(1+Pt/100);
DnH2= H2*(1-Pt/100);
UPL1= L1*(1+Pt/100);
DnL1= L1*(1-Pt/100);
UPL2= L2*(1+Pt/100);
DnL2= L2*(1-Pt/100);
Sell1 = (C < UPH1 AND C > DnH1) OR (C < UPH2 AND C > DnH2);
buy1 = (C < UPL1 AND C > DnL1) OR (C < UPL2 AND C > DnL2);
//============================ End of Camarilla Code =========
_SECTION_BEGIN("Linear Regression Channel");
//CyberMan's Linear Regression Channel.
//Linear Regression Line with 2 Standard Deviation Channels Plotted Above and Below
//The original was written by Patrick Hargus, with critical hints from Marcin
Gorzynski, Amibroker.com Technical Support
//Wysiwyg coded the angle in degrees part
//I modified the original Linear Regression code so that the line will change color
based on the degree of the Linear Regression slope.
//I combine this with my trading system.
//When my system gives an entry signal I look at the Linear Regression Line and I
will only take long positions if the Linear Regression line is green and the entry
price is below the LR line.
//When my system gives an entry signal I look at the Linear Regression Line and I
will only take short positions if the Linear Regression line is red and the entry
price is above the LR line.
//It is usefull for filtering out lower probability trades.
//================================================Start Chart
Configuration======================================================================
======
//================================================End Chart
Configuration======================================================================
=========
//====================================Start of Linear Regression
Code===============================================================================
===
P = ParamField("Price field",-1);
Length = 150;
Daysback = Param("Period for Liner Regression Line",Length,1,300,1);
shift = Param("Look back period",0,0,300,1);
//=============================== Math Formula
===================================================================================
=====================
x = Cum(1);
lastx = LastValue( x ) - shift;
aa = LastValue( Ref(LinRegIntercept( p, Daysback), -shift) );
bb = LastValue( Ref(LinRegSlope( p, Daysback ), -shift) );
y = Aa + bb * ( x - (Lastx - DaysBack +1 ) );
//==================Plot the Linear Regression Line
===================================================================================
=================
LRColor = ParamColor("LR Color", colorCycle );
LRStyle = ParamStyle("LR Style");
LRLine = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y, Null );
LRStyle = ParamStyle("LR Style");
Angle = Param("Angle", 0.05, 0, 50, 0.01);// A slope higher than 0.05 radians will
turn green, less than -0.05 will turn red and anything in between will be white.
LRLine = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y, Null );
Pi = 3.14159265 * atan(1); // Pi
SlopeAngle = atan(bb)*(180/Pi);
LineUp = SlopeAngle > Angle;
LineDn = SlopeAngle < - Angle;
LRCol= IIf(LineUp,colorGreen,IIf(LineDn,colorRed,colorWhite));
Plot(LRLine, "Lin. Reg. Line Up", LRCol, LRStyle);
Title= Title+ EncodeColor(colorBlack)+ "\n" + "Angle Slope : " +
WriteVal(SlopeAngle,1.2);
//========================== Plot 1st SD Channel
===================================================================================
===================
SDP = Param("Standard Deviation", 1.5, 0, 6, 0.1);
SD = SDP/2;
width = LastValue( Ref(SD*StDev(p, Daysback),-shift) ); //Set width of inside
chanels here.
SDU = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y+width , Null ) ;
SDL = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y-width , Null ) ;
SDColor = ParamColor("SD Color", colorCycle );
SDStyle = ParamStyle("SD Style");
Plot( SDU , "Upper Lin Reg", colorBlue,SDStyle ); //Inside Regression Lines
Plot( SDL , "Lower Lin Reg", colorBlue,SDStyle ); //Inside Regression Lines
//========================== Plot 2d SD Channel
===================================================================================
=====================
SDP2 = Param("2d Standard Deviation", 2.0, 0, 6, 0.1);
SD2 = SDP2/2;
width2 = LastValue( Ref(SD2*StDev(p, Daysback),-shift) ); //Set width of outside
chanels here.
SDU2 = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y+width2 , Null ) ;
SDL2 = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y-width2 , Null ) ;
SDColor2 = ParamColor("2 SD Color", colorCycle );
SDStyle2 = ParamStyle("2 SD Style");
Plot( SDU2 , "Upper Lin Reg", colorBlue,SDStyle2 ); //OutSide Regression Lines
Plot( SDL2 , "Lower Lin Reg", colorBlue,SDStyle2 ); //OutSide Regression Lines
Trend = IIf(LRLine > Ref(LRLine,-1),colorGreen,colorRed);//Changes LR line to green
if sloping up and red if sloping down.
Plot( LRLine , "LinReg", Trend, LRSTYLE );
SELL2 = C > SDU2;
BUY2 = C < SDL2;
//============================ End Indicator Code =========
_SECTION_END();
Buy= buy1 AND BUY2;
Sell= Sell1 AND SELL2;
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorBlue, colorBlack ), 0, IIf( Buy, Low, High ) );

Potrebbero piacerti anche