Advance camarilla AFL

#1
I cant find a perfect Camarilla AFl. so i make it my self


How to use advanced camarilla calculator




Look at the opening price for the stock/futures/commodities/currency.
There are various scenarios that can occur

Scenario 1

Open price is between H3 and L3

For Long

Wait for the price to go below L3 and then when it moves back above L3, buy. Stoploss will be when price moves below L4. Target1 - H1, Target2 - H2, Target3 - H3

For Short Sell

Wait for the price to go above H3 and then when the price moves back below H3, sell. Stoploss will be when price moves above H4. Target1 - L1, Target2 - L2, Target3- L3

Scenario 2

Open price is between H3 and H4

For Long

When price moves above H4, buy. Stoploss when price goes below H3. Target 1 - H5, Target 2 - H6

For Short Sell

When the price goes below H3, sell. Stopless when prices moves above H4. Target1 - L1, Target2 - L2, Target3- L3

Scenario 3

Open price is between L3 and L4

For Long

When price moves above L3, buy. Stoploss when price moves below L4. Target1 - H1, Target2 - H2, Target3 - H3

For Short Sell

When the price goes below L4, sell. Stoploss when price moves above L3. Target 1 - L5, Target 2 - L6

Scenario 4

Open price is outside the H4 and L4
Wait for the prices to come in range and trade accordingly.
Code:
_SECTION_BEGIN("Chart");

SetChartOptions(0, chartShowArrows | chartShowDates);
SetChartBkGradientFill(ParamColor("Upper Chart", ColorRGB(11, 50, 57)), ParamColor("Lower Chart", ColorRGB(69, 163, 186)));
SetChartBkColor(ParamColor("Outer Panel", ColorRGB(19, 88, 100 )));

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

_SECTION_END();
/////////////


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

EntrySignal =   HAI_F6(20,10,29,13);
ExitSignal =HAI_F7(20,10,29,13);
Color = IIf( EntrySignal, colorBlue, IIf( ExitSignal, colorRed, colorLightGrey ));
colorHighliter = IIf(C >= O, ColorRGB(0, 128, 0), ColorRGB(128, 0, 0));


 
//Demand Point
//colorDemandPoint = ParamColor("Demand Line", ColorRGB(0, 128, 255));
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;
for (i = 0; i < BarCount; i++) {
	CurrentBar = (BarCount - 1) - i;
	if (DemandPoint[CurrentBar]) {
		if (dx1 == 0 & dy1 == 0) {
			dx1 = CurrentBar;
			dy1 = L[CurrentBar];
		} else {
			dx0 = CurrentBar;
			dy0 = L[CurrentBar];
		}
		if (dx0 != 0 & dx1 != 0 & dy0 != 0 & dy1 != 0) {
			if (dy0 < dy1) {
				a = (-dy0 + dy1) / (-dx0 + dx1);
				b = dy0 - dx0 * a;
				for (j = dx1; j < BarCount; j++) {
					if (j != dx1) {
						y2 = a * j + b;
						if (C[j] < y2) {
							dy1 = y2;
							dx1 = j;
							colorHighliter[j] = ColorRGB(128, 0, 128);
							CountTrendBars[j] = dx1 - dx0 - 1;
							break;
						}
					}
				}
				if (dy1 != y2) {
					dy1 = y2;
					dx1 = BarCount - 1;
				}
				//Plot(LineArray(dx0, dy0, dx1, dy1, 0), "", colorDemandPoint, styleLine, Null, Null, 0, 0, 2);
			}
			dx1 = dx0;
			dy1 = dy0;
			dx0 = dy0 = 0;
		}	
	}
	if (SupplyPoint[CurrentBar]) {
		if (sx1 == 0 & sy1 == 0) {
			sx1 = CurrentBar;
			sy1 = H[CurrentBar];
		} else {
			sx0 = CurrentBar;
			sy0 = H[CurrentBar];
		}
		if (sx0 != 0 & sx1 != 0 & sy0 != 0 & sy1 != 0) {
			if (sy0 > sy1) {
				a = (-sy0 + sy1) / (-sx0 + sx1);
				b = sy0 - sx0 * a;
				for (j = sx1; j < BarCount; j++) {
					if (j != sx1) {
						y2 = a * j + b;
						if (C[j] > y2) {
							sy1 = y2;
							sx1 = j;
							colorHighliter[j] = ColorRGB(128, 128, 0);
							CountTrendBars[j] = sx1 - sx0 - 1;
							break;
						}
					}
				}
				if (sy1 != y2) {
					sy1 = y2;
					sx1 = BarCount - 1;
				}
				//Plot(LineArray(sx0, sy0, sx1, sy1, 0), "", colorSupplyPoint, styleLine, Null, Null, 0, 0, 2);
			}
			sx1 = sx0;
			sy1 = sy0;
			sx0 = sy0 = 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);


//---- 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


//............camarilla pivots
H6 = ( (DayH-DayL) * (1.0922) ) + DayC;
H5 = ( (DayH-DayL) * (.8244) ) + DayC;
H4 = ( (DayH-DayL) * (.55) ) + DayC;
H3 = ( (DayH-DayL) * (.275) ) + DayC;
H2 = ( (DayH-DayL) * (.183) ) + DayC;
H1 = ( (DayH-DayL) * (.0916) ) + DayC;
p = (DayH + DayL + DayC ) /3 ;
L1 = DayC - ( (DayH-DayL) * (.0916) );
L2 = DayC - ( (DayH-DayL) * (.183) ) ;
L3 = DayC - ( (DayH-DayL) * (.275) ) ;
L4 = DayC - ( (DayH-DayL) * (.55) ) ;
L5 = DayC - ( (DayH-DayL) * (.8244) ) ;
L6 = DayC - ( (DayH-DayL) * (1.0922) ) ;
Plot(H6, "H6",colorRED,styleLine|styleNoRescale);
Plot(H5, "H5",colorRED,styleLine|styleNoRescale);

Plot(H4, "H4",colorRED,styleLine|styleNoRescale);
Plot(H3, "H3",colorRED,styleLine|styleNoRescale);
Plot(H2, "H2",colorRED,styleLine|styleNoRescale);
Plot(H1, "H1",colorRED,styleLine|styleNoRescale);
Plot(P, "P",colorWhite,styleLine|styleNoRescale);


Plot(L6, "L6",colorGreen,styleLine|styleNoRescale);
Plot(L5, "L5",colorGreen,styleLine|styleNoRescale);

Plot(L4, "L4",colorGreen,styleLine|styleNoRescale);
Plot(L3, "L3",colorGreen,styleLine|styleNoRescale);
Plot(L2, "L2",colorGreen,styleLine|styleNoRescale);
Plot(L1, "L1",colorGreen,styleLine|styleNoRescale);

H1I = LastValue (H1,1);
H2I = LastValue (H2,1);
H3I = LastValue (H3,1);
H4I = LastValue (H4,1);
H5I = LastValue (H5,1);
H6I = LastValue (H6,1);

PI = LastValue (P,1);

L1I = LastValue (L1,1);
L2I = LastValue (L2,1);
L3I = LastValue (L3,1);
L4I = LastValue (L4,1);
L5I = LastValue (L5,1);
L6I = LastValue (L6,1);


BSL = ((L4-L3)/2)+L3;
SSL = ((H4-H3)/2)+H3;


Plot(BSL, "BSL",colorBLUE,styleLine|styleNoRescale);
Plot(SSL, "SSL",colorBLUE,styleLine|styleNoRescale);

numbars = LastValue(Cum(Status("barvisible")));
fraction= IIf(StrRight(Name(),3) == "", 5, 1);
hts = 100;
PlotText(" L6 =  " + WriteVal(L6,fraction), LastValue(BarIndex())-(numbars/Hts),L6I , colorWHITE);
PlotText(" L5 =  " + WriteVal(L5,fraction), LastValue(BarIndex())-(numbars/Hts),L5I , colorWHITE);
PlotText(" L4 =  " + WriteVal(L4,fraction), LastValue(BarIndex())-(numbars/Hts),L4I , colorWHITE);
PlotText(" L3 =  " + WriteVal(L3,fraction), LastValue(BarIndex())-(numbars/Hts),L3I , colorWHITE);
PlotText(" L2 =  " + WriteVal(L2,fraction), LastValue(BarIndex())-(numbars/Hts),L2I , colorWHITE);
PlotText(" L1 =  " + WriteVal(L1,fraction), LastValue(BarIndex())-(numbars/Hts),L1I , colorWHITE);

PlotText(" PIVOT =  " + WriteVal(P,fraction), LastValue(BarIndex())-(numbars/Hts),PI,20 , colorORANGE);

PlotText(" H1 =  " + WriteVal(H1,fraction), LastValue(BarIndex())-(numbars/Hts),H1I , colorWHITE);
PlotText(" H2 =  " + WriteVal(H2,fraction), LastValue(BarIndex())-(numbars/Hts),H2I , colorWHITE);
PlotText(" H3 =  " + WriteVal(H3,fraction), LastValue(BarIndex())-(numbars/Hts),H3I , colorWHITE);
PlotText(" H4 =  " + WriteVal(H4,fraction), LastValue(BarIndex())-(numbars/Hts),H4I , colorWHITE);
PlotText(" H5 =  " + WriteVal(H5,fraction), LastValue(BarIndex())-(numbars/Hts),H5I , colorWHITE);
PlotText(" H6 =  " + WriteVal(H6,fraction), LastValue(BarIndex())-(numbars/Hts),H6I , colorWHITE);



///////////////////////
FS=Param("MM Price Font Size",20,11,100,1);
Hor=Param("MM Price Horizontal Position",840,1,1200,1);
Ver=Param("MM price Vertical Position",10,1,830,1); 

  GfxSelectFont("tahoma", FS, 700, True ); 
   GfxSetBkMode( 1 );  
   GfxSetTextColor( colorLime); 
   GfxTextOut(""+C, Hor+29 , Ver);
   YC=TimeFrameGetPrice("C",inDaily,-1);
   DD=Prec(C-YC,2);
   xx=Prec((DD/YC)*100,2);
  GfxSelectFont("tahoma", 11, 700, True ); 
  GfxSetBkMode( 1 );  
  GfxSetTextColor(7); 
   GfxTextOut(""+DD+"  ("+xx+"%)", Hor+29 , Ver+29 );
//////////////////////////////////////////////////////////
 

Similar threads