any one have this afl

#13
HTML:
//|------------------------------------------------------------------
//|Dhavin.com - Nifty PRO 4.2P. 							
//|Version:4.2P   05 - July - 2012
//|Copyright © 2010, Dhavin.com
//|http://www.dhavin.com
//|e-mail: [email protected]
//|------------------------------------------------------------------
SetChartOptions(0,chartShowDates|chartLogarithmic|chartWrapTitle);
#pragma nocache
// Commentry output ....
EnableTextOutput(False);
System= ParamList("System Selection","NiftyPro4.2|Option_Trading|NiftyPro3.6|NiftyPro3.5",0);
SL1_show = ParamToggle("10 Min SL", "Off|On"); 
AudioAlert = ParamToggle("Audio Alert", "On|Off"); 
Print_SR = ParamToggle("Print Minor Levels", "Off|On"); 
Print_Band = ParamToggle("Print Band", "Off|On");
Print_Fib = ParamToggle("Intraday Fibonacci", "Off|On"); 
Print_DSR = ParamToggle("Dynamic Sup / Res", "On|Off");
Print_Divergence = ParamToggle("Divergence", "Off|On");
Print_MACD = ParamToggle("MACD Buy / Sell", "Off|On");
Text_Display = ParamToggle("Alert Messages", "On|Off");  // Display Alert messages on Chart.


 


_SECTION_BEGIN("S / R Parameters");
Sensitivity = Param("Sensitivity",32,10,100,1); 

DisRange = Param("Plot 'far away' Lines Trigger",300,0,1000,20);
Color_SL=  ParamColor("Support",colorLime);
Color_RL=  ParamColor("Resistance",colorRed);
_SECTION_END(); 



_SECTION_END();
Plot( EMA( C, 65 ), _DEFAULT_NAME(), ParamColor("21 MA Color", colorGrey40 ),1+ 4096+styleNoTitle ); 

TimeFrameSet( inDaily ); 

EngulfingPattern = WriteIf(CdBullishEngulfing(), "Bullish Engulfing Candle Pattern", 
                   WriteIf( CdBearishEngulfing(), "Bearish Engulfing Candle Pattern",
					  WriteIf( CdDoji(), "DOJI Candle Pattern",
					  WriteIf( CdHammer(), "HAMMER Candle Pattern", 
                   " no Candle Pattern"))));
TimeFrameRestore();
NiftyPro4point2P();

sVCXB = BarsSince(VCXB); sVCXS= BarsSince(VCXS);

if (Print_BAND) {

Cord = 0; // initialize 
for( Counter = 52; Counter >= 26; Counter-- ) 
{ 
  Cord = Max( Cord, LinearReg(Close,Counter) ); 
} 

ProportionalATR = ind101*2.5 / (Sum(C, 52) /13); 
Factor = 2.618 * Cord * ProportionalATR; 
LD = Cord - Factor; 
LD = IIf(Cord < LD, Cord, LD); 
UD = Cord + Factor; 

//Plot(Cord, "Cord", colorYellow); 
Plot(LD, "LD", colorRed); 
Plot(UD, "UD", colorGreen);
}

per1 = SelectedValue(Sensitivity *SelectedValue(0.2*uIV_AVG)); 
per2 = SelectedValue(per1 * 3); 
x=Cum(1);  
Tp1 = TroughBars(L,per1,1) == 0;
Pp1 = PeakBars  (H,per1,1) == 0;
Tp2 = TroughBars(L,per2,1) == 0;
Pp2 = PeakBars  (H,per2,1) == 0;

XT1 =SelectedValue(ValueWhen(Tp1,x,1));
XT2 =SelectedValue(ValueWhen(Tp1,x,2));
XT3 =SelectedValue(ValueWhen(Tp1,x,3));
XT4 =SelectedValue(ValueWhen(Tp1,x,4));
XT5 =SelectedValue(ValueWhen(Tp1,x,5));
XT6 =SelectedValue(ValueWhen(Tp2,x,1));
XT7 =SelectedValue(ValueWhen(Tp2,x,2));

XP1 =SelectedValue(ValueWhen(Pp1,x,1));
XP2 =SelectedValue(ValueWhen(Pp1,x,2));
XP3 =SelectedValue(ValueWhen(Pp1,x,3));
XP4 =SelectedValue(ValueWhen(Pp1,x,4));
XP5 =SelectedValue(ValueWhen(Pp1,x,5));
XP6 =SelectedValue(ValueWhen(Pp2,x,1));
XP7 =SelectedValue(ValueWhen(Pp2,x,2));

T1 = SelectedValue(ValueWhen(Tp1,L,1));
T2 = SelectedValue(ValueWhen(Tp1,L,2));
T3 = SelectedValue(ValueWhen(Tp1,L,3));
T4 = SelectedValue(ValueWhen(Tp1,L,4));
T5 = SelectedValue(ValueWhen(Tp1,L,5));
T6 = SelectedValue(ValueWhen(Tp2,L,1));
T7 = SelectedValue(ValueWhen(Tp2,L,2));

P1  = SelectedValue(ValueWhen(Pp1,H,1));
P2  = SelectedValue(ValueWhen(Pp1,H,2));
P3  = SelectedValue(ValueWhen(Pp1,H,3));
P4  = SelectedValue(ValueWhen(Pp1,H,4));
P5 = SelectedValue(ValueWhen(Pp1,H,5));
P6 = SelectedValue(ValueWhen(Pp2,H,1));
P7 = SelectedValue(ValueWhen(Pp2,H,2));

breakout_lasttrough_G1 = Cross(T1,C);
breakout_lasttrough_G2 = Cross(T6,C);
breakout_lastpeak_G1 =   Cross(C,P1);
breakout_lastpeak_G2 =   Cross(C,P6);
bu_breakout = Cross(C,P1)  OR  Cross(C,P6);
be_breakout = Cross(T1,C)  OR  Cross(T6,C);
break_G1_val = IIf(breakout_lasttrough_G1,-1,IIf(breakout_lastpeak_G1,1,0));
break_G2_val = IIf(breakout_lasttrough_G2,-1,IIf(breakout_lastpeak_G2,1,0));




/*Display Conditions*/  
Vis_percent =DisRange*SelectedValue(MA(abs(ROC(C,1)),10));
pR = (Vis_percent/100) + 1;
nR = ((100-VIS_percent)/100);
lC = SelectedValue(C);
RT1 = T1<PR*LC & T1>nR*LC;
RT2 = T2<PR*LC & T2>nR*LC;
RT3 = T3<PR*LC & T3>nR*LC;
RT4 = T4<PR*LC & T4>nR*LC;
RT5 = T5<PR*LC & T5>nR*LC;
RP1 = P1<PR*LC & P1>nR*LC;
RP2 = P2<PR*LC & P2>nR*LC;
RP3 = P3<PR*LC & P3>nR*LC;
RP4 = P4<PR*LC & P4>nR*LC;
RP5= P5<PR*LC & P5>nR*LC;
RT6= T6<PR*LC & T6>nR*LC;
RT7= T7<PR*LC & T7>nR*LC;
RP6= P6<PR*LC & P6>nR*LC;
RP7= P7<PR*LC & P7>nR*LC;
/*End Display Conditions*/

//Anyline_zero 
AnZ= T1==0 & T2==0 & T3==0 & T4==0 & T5==0 & T6==0 & T7==0 & P1==0 & P2==0 & P3==0 & P4==0 & P5==0 & P6==0 & P7==0;

LastBar = Cum(1) == SelectedValue(Cum(1));


if(Print_SR) 
{



Plot(IIf(x>=XT2 & RT2 &NOT T2==0,T2,-1e10),"T2",IIf( SelectedValue(C)<T2,Color_RL, Color_SL ),1 + 2048+styleNoTitle);
Plot(IIf(x>=XT3 & RT3 &NOT T3==0,T3,-1e10),"T3",IIf( SelectedValue(C) < T3 , Color_RL, Color_SL ),1 + 2048+styleNoTitle);
Plot(IIf(x>=XT4 & RT4 &NOT T4==0,T4,-1e10),"T4",IIf( SelectedValue(C)<T4,Color_RL, Color_SL ),1 + 2048+styleNoTitle);
Plot(IIf(x>=XT5 & RT5 &NOT T5==0,T5,-1e10),"T5",IIf( SelectedValue(C)<T5,Color_RL, Color_SL ),1 + 2048+styleNoTitle);



Plot(IIf(x>=XP2 & RP2 &NOT P2==0,P2,-1e10), "P2" ,IIf( SelectedValue(C)<P2,Color_RL, Color_SL ),1 + 2048+styleNoTitle);
Plot(IIf(x>=XP3 & RP3 &NOT P3==0,P3,-1e10), "P3" ,IIf( SelectedValue(C)<P3,Color_RL, Color_SL ),1 + 2048+styleNoTitle);
Plot(IIf(x>=XP4 & RP4 &NOT P4==0,P4,-1e10), "P4" ,IIf( SelectedValue(C)<P4,Color_RL, Color_SL ),1 + 2048+styleNoTitle);
Plot(IIf(x>=XP5 & RP5 &NOT P5==0,P5,-1e10),"P5",IIf( SelectedValue(C)<P5,Color_RL, Color_SL ),1 + 2048+styleNoTitle);
}

Plot(IIf(x>=XT1 & RT1 &NOT T1==0,T1,-1e10),"T1",colorBlue,1 + 2048+styleNoTitle);
Plot(IIf(x>=XP1 & RP1 &NOT P1==0,P1,-1e10), "P1" ,colorBlue,1 + 2048+styleNoTitle);
Plot(IIf(x>=XT6 & RT6 &NOT T6==0,T6,-1e10),"T6",IIf( SelectedValue(C)<T6,Color_RL, Color_SL ),8 + 2048+styleNoTitle + styleNoLabel);
Plot(IIf(x>=XT7 & RT7 &NOT T7==0,T7,-1e10),"T7",IIf( SelectedValue(C)<T7,Color_RL, Color_SL ),8 + 2048+styleNoTitle+ styleNoLabel);
Plot(IIf(x>=XP6 & RP6 &NOT P6==0,P6,-1e10),"P6",IIf( SelectedValue(C)<P6,Color_RL, Color_SL ),8 + 2048+styleNoTitle);
Plot(IIf(x>=XP7 & RP7 &NOT P7==0,P7,-1e10),"P7",IIf( SelectedValue(C)<P7,Color_RL, Color_SL ),8 + 2048+styleNoTitle);

//if (NiftyConditions3point7()==1) {

//Color Settings.....


Color = IIf( ui7 < -100, 32, IIf( ui7 > 100, 27, IIf((ui7 > 50), 34, IIf((ui7 > 20), 51, IIf((ui7 < - 50), 25, IIf((ui7 < - 20), 33, 55 )))))); 



/* plot color ribbon */ 

 
Plot( 1, "", Color, styleArea | styleOwnScale | styleNoLabel, -0.1, 60 );



Volumecolor = IIf(MAV_Value1 > 3 AND C > O, colorGreen,IIf(MAV_Value1 > 3 AND C < O, colorRed,
				IIf(MAV_Value1 > 1.2, colorBlue, IIf(MAV_Value1 > 0.8, colorLightBlue,  colorWhite))));
Plot( 1, "", Volumecolor, styleArea | styleOwnScale | styleNoLabel, -0.1, 25 );

MACD_Buy = Cross( MACD(),Signal() ); 
MACD_Sell = Cross(Signal() ,MACD());

NewDay = Day()!= Ref(Day(), -1);

DH = HHV( H, NewDay);
DL =  LLV(L, NewDay);
rsiDH = HHV( RSIa(H, 14), NewDay); //param 14
rsiDL =  LLV(RSIa(L, 14), NewDay);
RSI_Parameter = Param("RSIA PARAM",15,8,20,1);
////// RSI Day high / low detection ////
RSIBull1 = (L < Ref(dl, -1) AND RSIa(L, RSI_Parameter) > Ref(RSIdl, -1)) OR 
           (L > Ref(dl, -1) AND RSIa(L, RSI_Parameter) < Ref(RSIdl, -1)) ;
RSIBear1 = (H > Ref(dh, -1) AND RSIa(H, RSI_Parameter) < Ref(RSIdh, -1)) OR 
           (H < Ref(dh, -1) AND RSIa(H, RSI_Parameter) > Ref(RSIdh, -1));
RSIburev = BarsSince(RSIbull1);
RSIberev = BarsSince(RSIbear1);

CCI_Periods = Param("CCI Periods",32,10,50,1);

bear_CCI = (CCI() >Ref( HHV(CCI(), CCI_Periods), -1)   AND H < Ref(HHV(H, CCI_Periods), -1)) OR 
             (CCI() < Ref( HHV(CCI(), CCI_Periods), -1)   AND H > Ref(HHV(H, CCI_Periods), -1));

bull_CCI = (CCI() > Ref( LLV(CCI(), CCI_Periods), -1)   AND L < Ref(LLV(L, CCI_Periods), -1)) OR 
            ( CCI() < Ref( LLV(CCI(), CCI_Periods), -1)   AND L > Ref(LLV(L, CCI_Periods), -1));
Sbullcci = BarsSince(bull_CCI);
Sbearcci = BarsSince(bear_CCI);

BeReversal = ( Close >= HHV( Close, 18 ) AND RSI(14) < HHV( RSI(14), 18 )) ; 
BuReversal = ( Close <= LLV( Close, 18 ) AND RSI(14) > LLV( RSI(14), 18 ));
BeReversal1 = ( RSI(15) <= LLV( RSI(14), 14) AND Close > LLV(Close,14));
BuReversal1 = ( RSI(15) >= HHV( RSI(14), 14 ) AND Close < HHV( Close, 14 ));



NewBeReversal = ( H >= (Ref(HHV( H, 24 ), -1)+1) AND (RSIa(H, 24) < (HHV( RSIa(H, 24), 24 )) - 2)); 
NewBuReversal = ( L <= (Ref(LLV( L, 24 ), -1)-1) AND (RSIa(L,24) > (LLV( RSIa(L,24), 24 )) + 2));
Confirm_BeReversal = Ref( NewBeReversal, -1) AND H <= Ref(H, -1);
Confirm_BuReversal = Ref(NewBuReversal, -1) AND L >= Ref(L, -1);
since_BeReversal = BarsSince(BeReversal);
since_BuReversal = BarsSince(BuReversal);

since_Confirm_BeReversal = BarsSince(Confirm_BeReversal);
since_Confirm_BuReversal = BarsSince(Confirm_BuReversal);

sinceOverBought = BarsSince(RSI(14) > 65);
sinceOverSold = BarsSince(RSI(14) < 35);



/*BULLISH STOCHASTIC DIVERGENCE, DD==30*/
ST33=StochD();
TR1=LLVBars(ST33,4);
TR2=IIf(ST33<30 AND TR1>0 AND Ref(TR1,-1)==0,Ref(ST33,-1),0);
TRC=IIf(TR2>0,C,0);
vs=ValueWhen(tr2, Ref(st33,-1), 1);
dvs=vs-Ref(vs,-1);
vc=ValueWhen(trc, LLV(C,3), 1);
dvc=vc-Ref(vc,-1);
diver=IIf(dvs>0 AND dvc<0,30,0);
DAS=BarsSince(Ref(TR2,-1)>0);
DD=IIf(DAS<20 AND C>=Ref(C,-1),DIVER,0);
//Graph0=DD;
//Graph0BarColor=4;
STBULL=DD==30;



/*BEARISH STOCHASTIC DIVERGENCE, BDDD==90*/

BTR1=HHVBars(ST33,4);
BTR2=IIf(ST33>70 AND BTR1>0 AND Ref(BTR1,-1)==0,Ref(ST33,-1),0);
BTRC=IIf(BTR2>0,C,0);
Bvs=ValueWhen(Btr2, Ref(st33,-1), 1);
Bdvs=Bvs-Ref(Bvs,-1);
Bvc=ValueWhen(Btrc, HHV(H,3), 1);
Bdvc=Bvc-Ref(Bvc,-1);
Bdiver=IIf(Bdvs<0 AND Bdvc>0,90,0);
BDAS=BarsSince(Ref(BTR2,-1)>0);
Bddd=IIf(BDAS<20 AND C<=Ref(C,-1),BDIVER,0);
//Graph2=BDDD;
//Graph2BarColor=4;
STBEAR=BDDD==90;
sinceSTBULL = BarsSince(STBULL);
sinceSTBEAR = BarsSince(STBEAR);


Hist = MACD()-Signal();
macdBeReversal = ( H >= (Ref(HHV( H, 14 ), -1)+2) AND (Hist < (HHV( Hist, 14 )) - 2)); 
macdBuReversal = ( L <= (Ref(LLV( L, 14 ), -1)-2) AND (Hist > (LLV( Hist, 14 )) + 2));
Confirm_macdBeReversal = Ref(macdBeReversal, -1) AND H <= Ref(H, -1);
Confirm_macdBuReversal = Ref(macdBuReversal, -1) AND L >= Ref(L, -1);


if (Print_MACD) {
PlotShapes(shapeHollowSmallSquare  * MACD_Buy, colorGreen, 0, L, -5);
PlotShapes(shapeHollowSmallSquare * MACD_Sell, colorDarkRed, 0, H, 5);

}

if (Print_Divergence) {
PlotShapes(shapeHollowSmallCircle  * BuReversal, colorGreen, 0, L, -5);
PlotShapes(shapeHollowSmallCircle * BeReversal, colorRed, 0, H, 5);
PlotShapes(shapeSmallCircle  * BuReversal1, colorGreen, 0, L, -5);
PlotShapes(shapeSmallCircle * BeReversal1, colorRed, 0, H, 5);
PlotShapes(shapeSmallCircle  * Confirm_MacdBuReversal, colorDarkGreen, 0, L, -4);
PlotShapes(shapeSmallCircle * Confirm_MacdBeReversal, colorDarkRed, 0, H, 4);
PlotShapes(shapeStar  * confirm_BuReversal, colorDarkGreen, 0, L, -11);
PlotShapes(shapeStar * Confirm_BeReversal, colorRed, 0, H, 11);
PlotShapes(shapeSmallSquare  * STBULL, colorBlue, 0, L, -15);
PlotShapes(shapeSmallSquare * STBEAR, colorRed, 0, H, 15);
}




if(Print_Fib) 
{

Plot(feb1,"",colorBlue,512 +styleThick + styleDashed);
Plot(feb2,"",colorBlue,512+ styleThick+styleDashed);
Plot(TDH,"",colorRed,512+ styleDashed);
Plot(TDL,"",colorGreen,512+ styleDashed);
}



intcond = (Vint / 60) < 20;  ///Should Remove this one...


Negative_Bias = (TDL < PDL OR TDH < PDH OR L < Ref(TDL, -1)) AND C < DL1 ;  ///Should Remove this one...
Positive_Bias = (TDL > PDL OR TDH > PDH OR H > Ref(TDH, -1)) AND C > DH1 ;  ///Should Remove this one...
InsideBar = TDH < PDH AND TDL > PDL AND TimeNum() > 143000;
PreviousDR = PDH - PDL;
TodayRange = TDH - TDL;
NR4 = TodayRange < Ref(TodayRange, -1) AND TodayRange < Ref(TodayRange, -2) AND TodayRange < Ref(TodayRange, -3)  AND TimeNum() > 143000;
NR7 = NR4 AND TodayRange < Ref(TodayRange, -4) AND TodayRange < Ref(TodayRange, -5) AND TodayRange < Ref(TodayRange, -6) AND TimeNum() > 143000;
/* plot color ribbon */ 
//TrendColor = IIf( Negative_Bias AND NOT Positive_Bias, colorRed, IIf( Positive_Bias AND NOT Negative_Bias, colorGreen,colorLightGrey )); 

//Plot( 1, "", TrendColor, styleArea | styleOwnScale | styleNoLabel, -0.1, 25 );

TrendText = WriteIf(Negative_Bias AND NOT Positive_Bias, " -Negative- " , WriteIf(Positive_Bias AND NOT Negative_Bias, " +Positive+ ", "Nutral" ));
IBNRtext = WriteIf(NR7 AND InsideBar, " NR7 & InsideBar Day ",   WriteIf(NR4 AND InsideBar, " NR4 and InsideBar Day ",
           WriteIf(NR7, " NR7 Day ",WriteIf(NR4, " NR4 Day ",WriteIf(InsideBar, " InsideBar Day ", " None ")))));

sDHbeC = BarsSince(DHbeC); sDLbuC = BarsSince(DLbuC); SDayH = BarsSince(H==Dayh); sDayL = BarsSince(L ==DayL);
SPikeUp = ((HHV(dayH - Thr11, 12) > C*0.007) OR (HHV(H, 18) - LLV(L, 18) > C*0.008)) AND sDHbeC < 12 AND sDHbeC == SDayH AND Spikeup1 ;
SPikeDown = ((HHV(Pk11 - dayL, 12) > C*0.007) OR (HHV(H, 18) - LLV(L, 18) > C*0.008))  AND spikedown1 AND sDLbuC == sDayL AND sDLbuC < 12;
Bfilter7 = Buy1 && AvoidB7 && Ref(HHV(MAV_Value1, 6), -1) < 1.1;
/*


/*
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/



EnableTextOutput(True);


EnableTextOutput(False);
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/


if(System=="NiftyPro4.2"){

bgbtmcolor = colorPaleBlue;



Buy2_1 = (Buy2  OR SpikeDown) AND AvoidBuyFinal  &&! Bfilter7;
Short2_1 = ((Short2 OR Spikeup ) AND NOT AvoidShort) OR DhSpike  OR SerialClimax_sHORT OR GapUpShort2 ;
Buy2_1 = ExRem(Buy2_1, Short2_1); Short2_1 = ExRem(Short2_1, Buy2_1);
Buy0 = ExRem(Buy0, Short0); Short0 = ExRem(Short0, Buy0) ;
sBuy0 = BarsSince(Buy0); sShort0 = BarsSince(Short0); sbuy2 = BarsSince(Buy2_1); sshort2 = BarsSince(Short2_1);
 Buy = Buy2_1 ; Short =  Short2_1 ; 


BuyPri1 = (ValueWhen(Buy, C, n = 1)); 
SellPri1 = (ValueWhen(Short, C, n = 1)); 

ExitLong11 = (ExitLong10 && C < BuyPri1*0.997) AND ((C < BuyPri1*0.997 )OR ELcond10);
ExitShort11 = ExitShort10 AND ((C > Sellpri1*1.003) OR EScond10);

Sell = (exitlong11  OR Short OR Sell2) AND TimeNum() < 152930;
Cover = exitshort11  OR Buy OR Cover2  AND TimeNum() < 152930;

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

 sCover = BarsSince( Cover ); sSell = BarsSince( Sell );

Buy3_1 = Buy2_1 OR ((Buy0 OR Buy0_1) AND sSell < sShort2) AND NOT Sell  AND TimeNum() < 152930;
Short3_1 = Short2_1 OR ((Short0 OR Short0_1) AND sCover < sBuy2) AND NOT Cover  AND TimeNum() < 152930;
Buy3_1 = ExRem(Buy3_1, (Sell OR Cover OR Short3_1)); Short3_1 = ExRem(Short3_1, (Cover OR Sell OR Buy3_1));
Buy = Buy3_1; Short = Short3_1;



sBuy = BarsSince( Buy ); sShort = BarsSince( Short );
}

if(System=="Option_Trading"){

bgbtmcolor = colorGrey50;
Buy21 = Buy1 && MAV_Value1 > 2.8 && MAV_Value1 < 4.3 && H < DayH && (C-O) > C*0.0012 && RSI() < 69;

//Buy2_1 = ((Buy2  OR SpikeDown) AND AvoidBuyFinal  &&! Bfilter7 &&! Buy1) || Buy21;
//Short2_1 = ((Short2 OR Spikeup ) AND NOT AvoidShort &&! Short1) OR DhSpike  OR SerialClimax_sHORT OR GapUpShort2;
Buy2_1 = ((Buy3  OR SpikeDown) AND AvoidBuyFinal  &&! Bfilter7) || Buy21;
Short2_1 = ((Short3 OR Spikeup ) AND NOT AvoidShort ) OR DhSpike  OR SerialClimax_sHORT OR GapUpShort2;
Buy = Buy2_1;
Short = Short2_1;
Sell = (Short3_Exit AND NOT AvoidShort) || Short2_1;
Cover = (Buy3_Exit AND AvoidBuyFinal  &&! Bfilter7) || Buy2_1;
Buy = ExRem(Buy, Sell); Short = ExRem(Short, Cover);
Sell = ExRem(Sell, Buy); Cover = ExRem(Cover, Short);
 sCover = BarsSince( Cover ); sSell = BarsSince( Sell );
sBuy = BarsSince( Buy ); sShort = BarsSince( Short );

}

if(System=="NiftyPro3.6"){

Buy = Buy1; Sell=  Short1; Buy = ExRem(Buy, Sell); Sell = ExRem(Sell, Buy); Cover = Buy; Short = Sell;
sBuy = BarsSince( Buy ); sShort = BarsSince( Short ); sCover = BarsSince( Cover ); sSell = BarsSince( Sell );
bgbtmcolor = colorGrey50;
}
if(System=="NiftyPro3.5"){

Buy = Buy0; Sell=  Short0; Buy = ExRem(Buy, (Sell )); Sell = ExRem(Sell, (Buy )); Cover = Buy; Short = Sell;
sBuy = BarsSince( Buy ); sShort = BarsSince( Short ); sCover = BarsSince( Cover ); sSell = BarsSince( Sell );
bgbtmcolor = colorGreen;
}
BuyPri = (ValueWhen(Buy, C, n = 1)); BuyPriHi = (ValueWhen(Buy, H, n = 1));
SellPri = (ValueWhen(Short, C, n = 1)); SellPriLo = (ValueWhen(Short, L, n = 1));
HiafterBuy = HHV(H, Buy); LoafterSell = LLV(L, Short);
LoafterBuy = LLV(L, Buy); HiafterSell = HHV(H, Short);
SellRunning = BarsSince( Buy ) > BarsSince( Short );
BuyRunning = BarsSince( Buy ) < BarsSince( Short );
SellRunning3_6 = BarsSince( Buy1 ) > BarsSince( Short1 );
BuyRunning3_6 = BarsSince( Buy1 ) < BarsSince( Short1 );
AlmostBuy = Buy1_1 AND SellRunning;
AlmostShort = Short1_1 AND BuyRunning;
CallNearBy = WriteIf(Almostshort, "   Short Avoided...Waiting for Additional Confirmations..", 
 			WriteIf(AlmostBuy, "   BUY Avoided...Waiting for Additional Confirmations..", ""));



SellRunning3_6 = BarsSince( Buy1 ) > BarsSince( Short1 );
BuyRunning3_6 = BarsSince( Buy1 ) < BarsSince( Short1 );



NOTrade = sCover < sshort AND sSell < sBuy AND NOT Cover AND NOT Sell;
MaxBuyProfit = WriteVal(HiafterBuy - BuyPri , 1.1);  MaxSellProfit = WriteVal(SellPri -LoafterSell, 1.1);
MaxProfit = WriteIf(sBuy < sShort AND sBuy >0 AND HiafterBuy > BuyPriHi AND NOT NOTrade, " Max. Profit since BUY " + MaxBuyProfit + " Pts. ("+ WriteVal(HiafterBuy, 1.1) + ")",
            WriteIf(sBuy > sShort  AND sShort >0 AND LoafterSell < SellPriLo AND NOT NOTrade, " Max. Profit since SELL " + MaxSellProfit + " Pts. ("+ WriteVal(LoafterSell, 1.1) + ")",""));


RunningCall = WriteIf(Buy OR Ref(Buy, -1), "Buy Call Entry  ", 
              WriteIf(Short OR Ref(Short, -1), "Short Call Entry  ",WriteIf(Sell, "Exit Long Position..  ", 
				WriteIf(Cover, "Exit Short Position..  ",WriteIf(NOTrade, "No-Trade is Open..  ","")))));  
CallWaiting = WriteIf(NOTrade AND sBuy < sShort && System=="NiftyPro4.2", "Waiting for a Short Sell Entry (Use DTP Till that time).... Buy Call will be Initiated only after Dip or after 11 AM..",  
				WriteIf(NOTrade AND sBuy > sShort && System=="NiftyPro4.2", "Waiting for a BUY Entry (Use DTP Till that time).... SELL Call will be Initiated only after a Rise  or after 11 AM..", ""));  
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
Plot(SL,"",colorBrown,512+ styleDashed);
if(Sl1_Show) 
{
Plot(SL1,"",colorDarkRed,512+ styleLine);
}


Short_Stoploss = WriteIf(C < SL, "Short Trade -- (Trail Stoploss  to " + WriteVal(SL + 1.5, 1.1) +" for Intraday Trade Only) \n\n"  + "Cmp : "+ WriteVal(C, 1.1), "");
Long_Stoploss = WriteIf(C > SL, "Long Trade -- (Trail Stoploss to " + WriteVal(SL- 1.5, 1.1)+ " for Intraday Trade Only) \n\n"  + "Cmp : "+ WriteVal(C, 1.1), "");

Uhk1 = Dh1 == TDH AND H > feb2 AND H < TDH  AND s13 > 0 AND O > C ;
Dhk1 = Dl1 == TDL AND L < feb1 AND L > TDL AND s13 > 0 AND C > O;
Uhk2 = Dh1 == TDH AND H > feb2 AND H < TDH  AND s13 > 0;
Dhk2 = Dl1 == TDL AND L < feb1 AND L > TDL AND s13 > 0 ;
since_UHK1 = BarsSince(uhk1);
since_DHK1 = BarsSince(Dhk1);

sinceNewDay = BarsSince(Day() != Ref(Day(), -1) );
sinceShortSL = BarsSince(C < SL);
sinceLongSL = BarsSince(C > SL);
ExitShort1 = (sinceSTBULL < 10 OR since_Confirm_BuReversal < 10 OR since_DHK1 < 8 OR ((NC103 == TDL) AND sinceNewDay > 15)) AND NC105 AND NifbuyCondition6
              AND C > SL AND (sinceOverSold < 14 OR since_DHK1 < 8 OR NC103 == TDL )  AND sBuy > sShort AND TimeNum() < 151000 AND NOT Uhk AND NOT Uhk2
              AND sinceShortSL < 10 AND H > Ref(H, -1);
ExitLong1 = (sinceSTBEAR < 10 OR since_Confirm_BeReversal < 10 OR since_UHK1 < 8 OR  ((NC101 == TDH ) AND sinceNewDay > 15)) AND NC105 AND NifSellCondition6
             AND C < SL AND (sinceOverBought < 14 OR since_UHK1 < 12 OR NC102 == TDH) AND sBuy < sShort AND TimeNum() < 151000 AND NOT Dhk AND NOT Dhk2
             AND sinceLongSL < 10 AND L < Ref(L, -1);
		
GfxSelectFont("Times New Roman", 10, 400, False ); 
Exitlong = ExRem(ExitLong1, C > SL);
ExitShort = ExRem(ExitShort1, C < SL);

PlotShapes(shapeSmallCircle * AlmostBuy, colorPlum, 0, L, 0);
PlotShapes(shapeSmallCircle * AlmostShort, colorPlum, 0, H, 0);
PlotShapes(shapeSmallCircle  * Exitshort, colorDarkGreen, 0, L, -12);
PlotShapes(shapeSmallCircle * ExitLong, colorRed, 0, H, 12);

Filter = Buy && H == DayH && SND > 3 && DayL < PDL;
AddColumn(Sl,"SL");

AddColumn(HHV(H, 12) - LLV(L, 12),"Range12", 1.1);
AddColumn(Buy,"Buy", 1); 
AddColumn(Short,"Short", 1); 
AddColumn(Buy,"Remarks", 1.1); 

EnableTextOutput(False);

EnableTextOutput(True);
printf(" ***  HNI Copy  ***\n");
uE8 + "\n";




EnableTextOutput(False);
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
RSI_Level = WriteIf(RSI() > 70, ",  RSI in OVER BOUGHT region, " ,WriteIf(RSI() < 30 , ",  RSI in OVER SOLD region, ", ""));

if(Text_Display) 
{
//Nifty();
yCount = Point2-Point1;
y1Count = Point1 +1;
XCount = Point4 - Point3;
Yt1Count = Point3 + 1;

Rangeout2 = DR2 > 0;
Rangeout1 = DS2 > 0;

if(NOT Print_DSR AND Rangeout1) 
{
SupportLine = LineArray( (BarCount-1-point2), DS2, BarCount -2 - Point1, DS1, 1 ); 
Plot( SupportLine, "Dynamic Support", colorBlue,8+ styleNoLabel+styleNoTitle );
 }
if(NOT Print_DSR AND Rangeout2) 
{
ResistanceLine = LineArray(BarCount-1-point4, DR2, BarCount -2 -Point3, DR1, 1 );
Plot( ResistanceLine, "Dynamic Resistance", colorBrown,8+ 4096 +styleNoTitle ); 


}

//PlotText( "CLOSE"+WriteVal(C, 1.1), BarCount-10, SL, colorBlack, colorYellow) ;
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/


diff = (((DR2 - DS2)/C)*100);

Rule3 = ((diff < 1)AND ( C < DR2) AND (C > DS2)); 
Rule3_1 = (((DR3 - DS3)/C) *100 < 1) AND ( C < DR3) AND (C > DS3);
DT_DB_Range = IIf((Rule3 OR Rule3_1), 36, 14);
Rule4 = Buy AND(((TDH - H)/C) *100 < 0.2)AND (DR3 > H);
Rule4_1 = Short AND (((L - TDL)/C) *100 < 0.2)AND (DS3 < L);
Rule5 = (((HHV(MA(C, 15), 15) - LLV(MA(C, 15), 15) )/C )*100);

DoubleTop = (((DR2 - DR1) / C)*100) ;
DoubleBottom = (((DS1 - DS2) / C)*100);
dt = doubleTop <DT_DB_Sens AND (xcount + Yt1count) > DT_DB_Range AND C < DR1;
db = doubleBottom < DT_DB_Sens AND (ycount + y1count) > DT_DB_Range AND C > DS1;
DT_BARS = BarsSince(DT);
DB_BARS = BarsSince(DB);
DataStopped = WriteIf(Now(4) > TimeNum() + 9, " Chart not Updating... ", "");
Volatile_DT = (H < DR1) AND (H > (DR1 - ((DR1 * DT_DB_Sens)/100))) AND (yt1count > 10) AND ((((DR1 - DS2) / DS2) * 100) > 0.8);
Volatile_Db = (L > DS1)AND (L < (DS1 + ((DS1 * DT_DB_Sens)/100))) AND (y1count > 10) AND ((((DR2 - DS1) / DR2) * 100) > 0.8);

Near_DT = (H < DR2) AND (H > (DR2 - ((DR2 * DT_DB_Sens)/100))) AND ((xcount + Yt1count) > (DT_DB_Range - 1)) AND NOT dt ;
Near_db = (L > DS2) AND (L < (DS2 + ((DS2 * DT_DB_Sens)/100)))AND ((ycount + y1count) > (DT_DB_Range - 1)) AND NOT db;
Near_DT2 = (H < DR3) AND (H > (DR3 - ((DR3 * DT_DB_Sens)/100))) AND NOT dt AND H > DR2 AND DR2 > 0;
Near_db2 = (L > DS3) AND (L < (DS3 + ((DS3 * DT_DB_Sens)/100))) AND NOT db AND L < DS2 AND DS2 > 0;

TWINTOP = ((H - Ref(H, -1)) < 0.1 AND (H - Ref(H, -1)) > -0.5) AND(( H - L > 10) OR (Ref(H, -1) - Ref(L, -1) > 10));
TWINBOTTOM = ((L - Ref(L, -1)) < 0.5 AND (L - Ref(L, -1)) > -0.1) AND(( H - L > 10) OR (Ref(H, -1) - Ref(L, -1) > 10));
BUY_ERROR1 = Buy AND (((H < Ref(H, -1)) OR (H == Ref(H, -1))) OR ( H < ChandelierCl(ATR(15),2.5)));
Sell_ERROR1 = Short AND (((L >  Ref(L, -1)) OR(L ==  Ref(L, -1)))OR ( L > ChandelierCl(ATR(15),2.5)));
RangeOut = WriteIf(DS2== 0 OR DS1 ==0 OR DS3 == 0 OR DR2 == 0 OR DR1==0 OR DR3 == 0, " Data out of Range !", "");
RangeOut1 = WriteIf(DS2== 0 OR DS1 ==0 OR DS3 == 0 OR DR2 == 0 OR DR1==0 OR DR3 == 0, "Not getting Enough Data to Calculate S/R, Switch to higher timeframe to get Support / Resistance, "+ " \n", "");
MajorSR_text		= WriteIf(C > 0, "Major Res : " + WriteVal(P6, 1.1)+ ",   " + WriteVal(P7,1.1) + ",   Major Sup : " + WriteVal(T6, 1.1)+ ",   " + WriteVal(T7,1.1)
 , "");




Normal_Text = WriteIf( NOT (rule3 OR RULE3_1 OR Rule4 OR Rule4_1), "   Normal Market Condition" + "  >>DH : " + WriteVal(TDH, 1.1) + ",  DL : " + WriteVal(TDL, 1.1), "");

Levels_Text		=WriteVal(NiftyBuyCondition2, 1)+WriteVal(NifBuyCondition2,1)  +WriteVal(NifBuyCondition3, 1) +
                   " , " + WriteVal(NiftySellCondition2, 1) + WriteVal(NifSellCondition2, 1) + WriteVal(NifSellCondition3, 1) +
" Strong Above : " + WriteVal(DR2, 1.1)+ ",   " + WriteVal(DR3,1.1);    
Levels_Text1 = ",  Weak Below : " + WriteVal(DS2, 1.1)+ ",   " + WriteVal(DS3,1.1) + " ";

Rule3_Text		=	WriteIf ( Rule3_1, "***EXTREME RangeBound Mkt. Condition Trade With Caution !!  *** ",WriteIf(RULE3, "RangeBound Mkt. Condition Trade With Caution !! " , " ")) ;

GfxSelectFont("Times New Roman", 10, 400, False ); 


Rule6_1 = WriteIf(db AND NOT Rule3_1 AND NOT Rule3  , "Higher / Double Bottom, " + (time * y1count) + " Min ago, betw. "+ ycount + " Periods, betw. "+ WriteVal(DS2, 1.1) + " & " + WriteVal(DS1, 1.1) + "  Levels,  " + "Bullish Reversal if Confirmed !" , "");
GfxTextOut(Rule6_1, 5 , 65);
Rule6 = WriteIf(dt AND NOT Rule3_1 AND NOT Rule3 , "Lower / Double Top, " + (time * yt1count) + " Min ago, betw.  "+ xcount + " Periods, betw.  "+ WriteVal(DR2, 1.1) + " & " + WriteVal(DR1, 1.1) + "  Levels,  "  + "Bearish Reversal if Confirmed ! ", ""); 
GfxSetTextColor(colorRed);
GfxTextOut(Rule6, 5 , 50);

Rule7_1 = WriteIf(C < SL AND Buy, " High Risky Call consider Buying on dips OR only above " + WriteVal(H*1.0001, 1.1) ,
          WriteIf(near_DT AND Buy, " Risky Call, Multiple Resistances @ " + WriteVal(DR2, 1.1)+ " & " + WriteVal(DR3, 1.1) + " Consider Buying on dips or on breakout" , 
          WriteIf(near_dt2 AND Buy, " High Risk CALL, (2 Double Top Forming) Resistance @ " + WriteVal(DR3, 1.1) + " Ref Rule 7.1" + " Consider Buying on dips or on breakout" ,
          WriteIf(Volatile_DT AND Buy, "High Volatilite Market (0 double Top formation  avoid trading, trade only above " + WriteVal (DR1, 1.1) + " or " + WriteVal(DR2, 1.1),
          WriteIf(C<DR1 AND H > DR1 AND Buy, "1 Res Violated & Trading Lower, Enter only above " + WriteVal(DR1+1, 1.1) + " on the Next bar or on dips to Support levels, Cmp "+ WriteVal(C, 1.1),
          WriteIf(C<DR2 AND H > DR2 AND Buy, "2 Res Violated & Trading Lower, Enter only above " + WriteVal(DR2 + 1, 1.1)+ " on the Next bar or on dips to Support levels, Cmp "+ WriteVal(C, 1.1),
          WriteIf(C<DR3 AND H > DR3 AND Buy, "3 Res Violated & Trading Lower, Enter only above " + WriteVal(DR3+1, 1.1)+ " on the Next bar or on dips to Support levels, Cmp "+ WriteVal(C, 1.1), 
       
          WriteIf(Buy AND ((H < Ref(H, -1)) OR (H == Ref(H, -1))), "Error 1, Buy only above " + WriteVal(Ref(H, -1), 1.1) + ", Cmp " + WriteVal(C, 1.1),
          WriteIf(Ref(Buy, -1) AND H < Ref(H, -1)*1.0001, "Error 2, BUY Call not Active, Avoid Entry / Enter Only above " + WriteVal(Ref(H, -1)*1.0001, 1.1),
          "")))))))));
Rule7_2 = WriteIf(C > SL AND Short, " High Risky Call consider Selling on rise OR only below " + WriteVal(L*0.9999, 1.1) , 
			WriteIf(near_db AND Short, " Risky Call, Multiple Supports @ " + WriteVal(DS2, 1.1)+ " & " + WriteVal(DS3, 1.1) + " Sell on Rise or " + " Below supports. ", 
          WriteIf(near_db2 AND Short, " High Risk CALL, (2 Double Bottom Forming) Support @ " + WriteVal(DS3, 1.1) + " Ref Rule 7.2" + " Consider Selling on rise or on breakout" , 
          WriteIf(Volatile_db AND Short, "High Volatilite Market (0 double Bottom formation  avoid trading, trade only below " + WriteVal (DS1, 1.1) + " or " + WriteVal(DS2, 1.1),
          WriteIf(C>DS1 AND L < DS1 AND Short, "1 Support Violated & Closing Higher, Enter only below " + WriteVal(DS1-1, 1.1)+ " on the Next bar or on rise to Res levels, Cmp " + WriteVal(C, 1.1),
          WriteIf(C>DS2 AND L < DS2 AND Short, "2 Support Violated & Closing Higher, Enter only below " + WriteVal(DS2-1, 1.1)+ " on the Next bar or on rise to Res levels, Cmp "+ WriteVal(C, 1.1),
          WriteIf(C>DS3 AND L < DS3 AND Short, "3 Support Violated & Closing Higher, Enter only below " + WriteVal(DS3-1, 1.1)+ " on the Next bar or on rise to Res levels, Cmp "+ WriteVal(C, 1.1),
          WriteIf(Short AND ((L >  Ref(L, -1)) OR(L ==  Ref(L, -1))) , "ERROR 1, SELL only below " + WriteVal(Ref(L, -1), 1.1) + ", Cmp " + WriteVal(C, 1.1),
          WriteIf(Ref(Short, -1) AND L > Ref(L, -1)*0.9999, "ERROR 2, SELL Call not Acitive, Avoid Entry / Enter Only below " + WriteVal(Ref(L, -1)*0.9999, 1.1) ,
          
          "")))))))));

BullishReversal = (since_BuReversal < 7  OR SinceSTBULL < 7)AND sinceOverSold < 5 AND db;
BearishReversal = (since_BeReversal < 7 OR sinceSTBEAR < 7) AND sinceOverBought < 5 AND dt;
TestRule3 = WriteIf(BullishReversal, "CAUTION **DoubleBottom with Bullish Divergence, Strong REVERSAL Possible ! if trades above " +  WriteVal(DR1, 1.1), 
            WriteIf(BearishReversal, "CAUTION **DoubleTOP with Bearish Divergence, Strong REVERSAL Possible ! if trades below " +  WriteVal(DS1, 1.1), ""));

ExitText = WriteIf( ExitShort, " EXIT Short position (Intraday Traders Only) &  re-enter below Day Low OR  " + WriteVal(DS1, 1.1),
               WriteIf( ExitLong, " EXIT Long position (Intraday Traders Only) &  re-enter above Day High OR " + WriteVal(DR1, 1.1), ""));

GfxTextOut(Rule7_1, 5 , 120);
GfxTextOut(Rule7_2, 5 , 135);

GfxSetTextColor(colorBlack);

GfxTextOut(Levels_Text + Levels_Text1 + RangeOut + Normal_Text , 5 , 15);
Rule6_2 = WriteIf(near_DT AND NOT Rule3_1 AND NOT Rule3 , " DoubleTop may form if " + Name() + " fails to cross " + WriteVal(DR2, 1.1), "");
Rule6_3 = WriteIf(near_Db AND NOT Rule3_1  AND NOT Rule3  , " DoubleBottom may form if " + Name() + " fails to break " + WriteVal(DS2, 1.1), "");

GfxTextOut(Rule6_2, 5 , 65);
GfxTextOut(Rule6_3, 5 , 65);
Rule6_4 = WriteIf(near_DT2 AND NOT Rule3_1  AND NOT Rule3  , "2 DoubleTop may form if " + Name() + " fails to cross " + WriteVal(DR3, 1.1), "");
Rule6_5 = WriteIf(near_Db2 AND NOT Rule3_1  AND NOT Rule3 , "2 DoubleBottom may form if " + Name() + " fails to break " + WriteVal(DS3, 1.1), "");

GfxTextOut(Rule6_4, 15 , 65);
GfxTextOut(Rule6_5, 15 , 65);
GfxTextOut(TestRule3, 5 , 150);
GfxTextOut(ExitText, 5 , 170);
GfxTextOut( Rule3_Text, 500 , 15);
}

time = Interval()/60;
NOT5min = WriteIf(time ==5 , "(5 minute Chart) ", WriteIf(time !=5 AND VIX > 21 ,"This Program is not designed for "+time+" min timeframe. ****Pls switchover to 5 min. Chart****", ""));



DayO = TimeFrameGetPrice("O", inDaily, 0);
PDO = TimeFrameGetPrice("O", inDaily, -1);
InsideBar = TimeNum() > 150000 AND DayH < PDH*1.001 AND DayL > PDL*0.999;
Hammer = TimeNum() > 150000 AND C > DayO AND (C - DayO) < (DayO - DayL)*1.25 AND (DayH - C) < (DayO - DayL);
BearishEngulfing = TimeNum() > 150000 AND DayO >= PDC*0.998 AND C < PDO AND DayH > PDO AND PDC > PDO;
BullishEngulfing = TimeNum() > 150000 AND DayO <= PDC*1.002 AND C > PDO AND DayL < PDO AND PDC < PDO;
//nr7 = TimeNum() > 151000 AND (Dayh - DayL) == LLV(Dayh - DayL, 7);
//nr4 = TimeNum() > 151000 AND (Dayh - DayL) == LLV(Dayh - DayL, 4);

PDHL = 
			WriteIf(SND < 2, "***Pls Verify DayHigh and DayLow, Correct it if required ***",
			WriteIf(TDL > PDL AND (C > PDL) AND ((L <  PDL) OR (L < PDL + 5)), "***CAUTION*** Trading close to Previous Day Low ",
          WriteIf(TDH < PDH AND C < PDH AND ((H > PDH) OR (H > PDH - 5)), "***CAUTION*** Trading close to Previous Day High",
		 	WriteIf(GDR, "***GAP-DOWN Recovery Detected*** Volatility Expected..",
	 		WriteIf(GUR, "***GAP-UP Reversal Detected*** Volatility Expected..", 
			WriteIf(InsideBar, "***INSIDE-BAR Day Detected*** ",
			WriteIf(Hammer, "***Bullish Hammer Candle Pattern Detected*** ",
			WriteIf(BearishEngulfing, "***Bearish Engulfing Pattern Detected***",
			WriteIf(BullishEngulfing, "***Bullish Engulfing Pattern Detected***","")))))))));
 


HookReversal = WriteIf(uHk1, "(BEARISH)Hook Reversal Pattern Possible, if Day High not violated !! "  , 
               WriteIf(dHk1, "(BULLISH)Hook Reversal Pattern Possible, if Day Low not violated !!", ""));

GfxSelectFont("Verdana", 8, 420, False ); 
GfxSetTextColor(colorDarkGreen);
GfxTextOut(not5Min + MaxProfit, 5 , 350);

GfxSetTextColor(colorRed);
GfxSelectFont("Verdana", 8, 400, False); 


GfxTextOut(PDHL, 250 , 78);


TotalVol =  Sum( V, SND+1 );
GfxSetTextColor(colorBlack);
Vix_Text = "VIX : " + WriteVal(Vix, 1.2)+ ",   %Chg " + WriteVal((Vix - VPrevClose)/VPrevClose*100, 1.2) +",   Vol Ratio :" + WriteVal(MAV_Value1, 1.2)
	 + ",  CDL Avg  " + WriteVal(Cdlavgrange, 1.1)  + ", Total Vol " + WriteVal(TotalVol, 1)  + ",  Premium " + WriteVal(C - Fu_C, 1.1)
  + WriteIf(LV AND Vix < 21, "  Caution Volatility is Very Low, Switch to 10min. or higher timeframe chart...,!!","")
 + WriteIf(LV AND Vix > 21, "  Caution Market Volatility is LOW, Trade Cautiously.. !!","");

GfxTextOut(Vix_Text, 5 , 15);








ErrorBuy = Buy1 AND uHk;
ErrorSell = Short1 AND dHk;
ErrorBuySellText = WriteIf(ErrorBuy AND NOT sBuy < sShort, "Buy Call Avoided", WriteIf(ErrorBuy AND sBuy < sShort, "Buy Call Re-entry (Check Day High)", 
                   WriteIf(ErrorSell AND NOT sBuy > sShort, "Sell Call Avoided", WriteIf(ErrorSell AND sBuy > sShort, "Sell Call Re-entry (Check Day Low)",  ""))));
//HiafterBuy - BuyPri ,  SellPri -LoafterSell
ClosePositionText = WriteIf(ClosePosition1 AND SellRunning, "Alert :: Very Close to Getting BUY, Advisable to Close Half of Short Position ", 
                    WriteIf(ClosePosition2 AND BuyRunning, "Alert :: Very Close to Getting SELL, Advisable to Close Half of Long Position ", ""));
ClosePositionText1 = WriteIf(CutLong AND sBuy < sShort, "(Test Program) Daily Trend WEAK, Advisable to Close Half of Overnight Long Position", 
						WriteIf(CutShort AND sBuy > sShort, "(Test Program) Daily Trend STRONG, Advisable to Close Half of Overnight Short Position", ""));
////////////////////////////////////////////////////////Message Listings/////////////////////////////////////////
HighsellVolume = MAV_Value1 >3 AND C < O;
HighBuyVolume = MAV_Value1 >3 AND C > O;
MSG1 = WriteIf(Vix == Ref(Vix, -1) AND Vix == Ref(Vix, -2) , "CAUTION:: No change in LIVE VIX data in last 10 min. !!!, Pls check ",
		WriteIf(MAV_Value1 < 0.1 AND Ref(MAV_Value1, -1) < 0.1, "Alert: This System is designed for Index Futures, Volume data is Missing...  ! ",
		WriteIf(HighsellVolume AND Ref(HHV(MAv_Value1, 6), -1) < 1, "Alert:: High SELL Volume is Happening !... but very low volume in previous few bars.. ",
		WriteIf(HighBuyVolume  AND Ref(HHV(MAv_Value1, 6), -1) < 1, "Alert:: High BUY Volume is Happening !... but very low volume in previous few bars..",
		WriteIf(HighsellVolume, "Alert:: High SELL Volume is Happening !... ",
		WriteIf(HighBuyVolume, "Alert:: High BUY Volume is Happening !... ", ""))))));

 

////////////////////////////////////////////////////////ERROR Listings/////////////////////////////////////////

Err0 = WriteIf(((Ref(HHV(MAv_Value1, 6), -1) < 1  AND MAv_Value1 < 3) OR ( MAv_Value1 < 1 )) AND Buy, "Error 0, Caution Raising with Very Low Volume... :(  , ", "");
Err1 = WriteIf(((Ref(HHV(MAv_Value1, 6), -1) < 1  AND MAv_Value1 < 3) OR ( MAv_Value1 < 1 )) AND Short, "Error 1, Caution Falling with Very Low Volume... :(  , ", "");
Err2 = WriteIf(L > PDC AND DayL > PDC AND (L - PDC) < C*0.0025 AND (Short OR Ref(Short, -1) ), "Error 2, Caution Trading Very Close to Previous Day Close.. (Support @ " + WriteVal(PDC, 1.1)+ "),   ", "");
Err3 =	WriteIf(L > PDH AND DayL > PDH  AND (L - PDH) < C*0.0025 AND (Short OR Ref(Short, -1)), "Error 3, Caution Trading Very Close to Previous Day High.. (Support @  " + WriteVal(PDH, 1.1)+ "),   ",  ""); 
Err4 = WriteIf(L > PDL AND DayL > PDL  AND (L - PDL) < C*0.0025 AND (Short OR Ref(Short, -1) ), "Error 4, Caution Trading Very Close to Previous Day Low.. (Support @ " + WriteVal(PDL, 1.1)+ "),   ", "");
Err5 = WriteIf(L > PDL2 AND DayL > PDL2  AND (L - PDL2) < C*0.0025 AND (Short OR Ref(Short, -1)), "Error 4, Caution Trading Very Close to Previous Day Low2.. (Support @ " + WriteVal(PDL2, 1.1)+ "),   ", "");
Err6 = WriteIf(L == DayL AND FU_L > FDL1, "Alert Spot Nifty has not yet broken Day Low... ", 
		WriteIf(L > DayL AND FU_L == FDL1, "Alert Spot Nifty has broken Day Low... ",
		WriteIf(H == DayH AND FU_H > FDH1, "Alert Spot Nifty has not yet broken Day High... ", 
		WriteIf(H > DayH AND FU_H == FDH1, "Alert Spot Nifty has broken Day High... ", ""))));
Err7 = WriteIf(H > Pk11 AND C < pk11 AND Buy,  "Alert, Immediate Res crossed but closing lower, Buy above " + WriteVal(H*1.0001, 1.1), 
 		WriteIf(H > Pk11 AND C < pk11 AND Buy,  "Alert, Immediate Sup crossed but closing higher, Sell Below " + WriteVal(L*0.999, 1.1), "" ));
Err8 = WriteIf((krs1 OR KRS2 OR Ref(krs2, -1)) AND BuyRunning, " Alert KeyReversal Detected (80% Accurate), **Book Profits & (Re-Enter on Dips or on Breakout)**",
		 WriteIf((krs1 OR KRS2 OR Ref(krs2, -1)) AND sellRunning, " Alert KeyReversal Detected (80% Accurate), **Short Re-entry can be taken**",

		WriteIf(RSIBearHD AND BuyRunning, " Alert -VE Hidden Divergence Detected, **Safe Traders exit Position and re-enter above recent high**",  
		WriteIf(RSIBearHD AND SellRunning, " Alert -VE Hidden Divergence Detected, **Re-entry to Short call can be taken**",
		WriteIf(RSIBearHD_1 AND Buy, " Alert -VE Hidden Divergence Detected, **Safe Traders Wait for next candle to complete and enter above recent High**", 
		
		WriteIf(RSIBullHD AND SellRunning, " Alert +VE Hidden Divergence Detected, **Safe Traders exit Position and re-enter above recent Low**",  
		WriteIf(RSIBullHD AND BuyRunning, " Alert +VE Hidden Divergence Detected, **Re-entry to Buy call can be taken**",
		WriteIf(RSIBullHD_1 AND Short, " Alert +VE Hidden Divergence Detected, **Safe Traders Wait for next candle to complete and enter Below recent Low**",""))))))));

Err12 = WriteIf(H < PDC AND DayH < PDC AND (PDC - H) < C*0.0025 AND (Buy OR Ref(Buy, -1)), "Error 12, Caution Trading Very Close to Previous Day Close.. (Res @  " + WriteVal(PDC, 1.1)+ "),   ", "");
Err13 =	WriteIf(H < PDH AND DayH < PDH  AND (PDH - H) < C*0.0025 AND (Buy OR Ref(Buy, -1)), "Error 13, Caution Trading Very Close to Previous Day High.. (Res @  " + WriteVal(PDH, 1.1)+ "),   ",  ""); 
Err14 = WriteIf(H < PDL AND DayH < PDL  AND (PDL - H) < C*0.0025 AND (Buy OR Ref(Buy, -1)), "Error 14, Caution Trading Very Close to Previous Day Low.. (Res @  " + WriteVal(PDL, 1.1)+ "),   ", "");
Err15 =	WriteIf(H < PDH2 AND DayH < PDH2  AND (PDH2 - H) < C*0.0025 AND (Buy OR Ref(Buy, -1)), "Error 13, Caution Trading Very Close to Previous Day High2.. (Res @  " + WriteVal(PDH2, 1.1)+ "),   ",  ""); 

///////////////Added From 3.9/////////////////
AvoidCall3 = (L > PDL AND DayL > PDL  AND (L - PDL) < C*0.0025 AND Short) OR ( H < PDH AND DayH < PDH  AND (PDH - H) < C*0.0025 AND Buy)  AND TimeNum() < 152000;
LowVol = (LongTail AND (Buy OR Short)) OR 
	((Ref(HHV(MAv_Value1, 6), -1) < 1  AND MAv_Value1 < 3) OR ( MAv_Value1 < 1 )) OR
	(((MAv_Value1 < 1) OR (Ref(HHV(MAv_Value1, 6), -1) < 1  AND MAv_Value1 < 3 ))AND ((Buy AND sVCXB > 15) OR (Short AND sVCXS > 15) )  AND TimeNum() < 152000);

RiskyBuy = (RiskyBuy2 OR RiskyBuy3) AND Buy;
RiskyShort = (RiskyShort1 OR RiskyShort2 OR RiskyShort3) AND Short;
Avoidcall1 = (VID1 ) AND (Buy OR Short)  AND TimeNum() < 152000;
AvoidCall2 = (AvoidBuy1 AND Buy) OR (AvoidShort1 AND Short)  AND TimeNum() < 152000;
AvoidBuyTemp = (H == DayH && H > PDH && Ref(H, -1) < PDH*1.0005 && (C-O) < C*0.004)
				
				|| (Short &&! Short1 && L == DayL)
				|| (Short && L < PDL && VixPer < 1)
				;
AvoidCall =(Avoidcall1 OR LowVol  OR AvoidCall2 OR RiskyBuy OR RiskyShort OR (AvoidCall3 AND TimeNum() < 152000)
			|| AvoidBuyTemp) &&!  MAV_Value1 > 3 ;//&&! (H > PDH && Ref(DayH, -1) < PDH*1.0005 && (MAV_Value1 < 4 || (C-O) < C*0.004));
////////////////////////End of 3.9 addition////////////


CallCheck = WriteIf(BuyRunning AND SellRunning3_6, "Alert : 3.6 Version is running Short Call.. See Interpretation for instruction ", 
				WriteIf(SellRunning AND BuyRunning3_6, "Alert : 3.6 Version is running Buy Call..  See Interpretation for instruction ", ""));
CallCheck1 = WriteIf(BuyRunning AND SellRunning3_6, "Alert : 3.6 Version is running Short Call.. Constant Monitoring of call is essential,"+ 
" Keep a watch on SELL VOLUME, Stoploss line, important PIVOT Levels, Past one hour high/Low Constantly trail stoploss till 3.6 enters into same direction, Profit booking also might be considered at 65EMA Level.", 
				WriteIf(SellRunning AND BuyRunning3_6, "Alert : 3.6 Version is running Buy Call..  Constant Monitoring of call is essential,"+ 
" Keep a watch on BUY VOLUME, Stoploss line, important PIVOT Levels, Past one hour high/Low, Constantly trail stoploss till 3.6 enters into same direction, Profit booking also might be considered at 65EMA Level. ", ""));

sVCXB = BarsSince(VCXB); sVCXS= BarsSince(VCXS);

Serial_ShortClimax = VCXB AND Ref(sVCXB, -1) < 24;
Serial_BuyClimax = VCXS AND Ref(sVCXS, -1) < 24;
ScaleoutText = WriteIf(sSE_11<6 AND (C > O OR H > Ref(H, -1)) AND Buyrunning, "**Buy Call Re-Entry can be Taken..**Possibility of Reversal, This Down move might end soon.. ",
				WriteIf(sBE_11<6 AND (C < O OR L < Ref(L, -1)) AND Sellrunning, "**Short Call Re-Entry can be Taken...**Possibility of Reversal, This UP move might end soon.. ",
				WriteIf(sSE_11<6 AND (C > O OR H > Ref(H, -1)), "Possibility of Reversal, This Down move might end soon..**Buy Call will come if Close is Above " + WriteVal(Sl, 1.1),
				WriteIf(sBE_11<6 AND (C < O OR L < Ref(L, -1)), "Possibility of Reversal, This UP move might end soon..**Short Call will come if Close is Below " + WriteVal(Sl, 1.1),
				WriteIf(VCXB AND Buyrunning, "Volume Climax, ***BuyCall RE-ENTRY can be taken***", 
				WriteIf(VCXS AND SELLrunning, "Volume Climax. ***ShortCall RE-ENTRY can be Taken***",
				WriteIf(Serial_ShortClimax, "**Caution** Serial Volume Climax, **, ScaleOut can be done.. ", 
				WriteIf(Serial_BuyClimax, "**Caution** Serial Volume Climax, ** ScaleOut can be done.. ",
				WriteIf(VCXB, "Volume Climax, This DOWN move might end soon.. **if close is above " + WriteVal(H, 1.1), 
				WriteIf(VCXS, "Volume Climax.., This UP move might end soon..**if close is below " + WriteVal(L, 1.1),""))))))))));
RallyMsg = 	WriteIf(UpRally1 AND RSI() > 40, "UP Rally1 Detected,  Reversal if Closes Below : "+ 
				WriteIf(C > sl,   WriteVal(sl, 1.1), WriteVal(DayL, 1.1)),

			WriteIf(Downrally1 AND RSI() < 60, "DOWN Rally1 Detected,  Reversal if Closes Above : "  + 
			WriteIf(C < sl,   WriteVal(sl, 1.1), WriteVal(DayH, 1.1)),
			WriteIf(uprally, "Strong UP Rally, Market expected to close at the Highest point of the day... Reversal if Closes Below : "+ 
				WriteIf(C > sl,   WriteVal(sl, 1.1), WriteVal(DayL, 1.1)),

			WriteIf(Downrally, "Strong DOWN Rally, Market expected to close at the Lowest point of the day... Reversal if Closes Above : "  + 
			WriteIf(C < sl,   WriteVal(sl, 1.1), WriteVal(DayH, 1.1)), "")))); 
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
GfxSetTextColor(colorDarkGreen);
GfxTextOut(ErrorBuySellText, 5 , 200);
GfxTextOut(ClosePositionText, 5 , 220);
GfxTextOut(ClosePositionText1, 5 , 235);


GfxSelectFont("Verdana", 8, 400, False); 
GfxTextOut(MSG1, 5 , 290);

//GfxSetBkMode( 1 ); 
GfxSetTextColor(colorBlack);
GfxTextOut(Error7  , 5 , 28);
GfxTextOut(CallCheck+CallNearBy , 140 , 180);
GfxTextOut(ScaleoutText, 140 , 90);
GfxSetTextColor(colorRed);
GfxTextOut(RallyMsg  , 150 , 45);
GfxSetTextColor(colorWhite);
GfxTextOut(HookReversal, 5 , 470);
GfxSetTextColor(colorGreen);


//GfxSetBkColor(colorRed);
breakout1 = WriteIf(C > T1 AND C > P1, " *** BULLISH BreakOut *** ",""); 
Breakout2 = WriteIf(C < T1 AND C < P1, " *** BEARISH BreakOut *** ","" );
GfxSelectFont("Verdana", 8, 700, False ); 
GfxTextOut(breakout1 , 480 , 28);
GfxSetTextColor(colorRed);
GfxTextOut(breakout2 , 480 , 28);
GfxSetBkMode( 2 );

GfxTextOut(Err8+Err0+Err1+Err2+Err3+Err4+Err5+Err6+Err7+Err12+Err13+Err14+Err15 , 5 , 280);


GfxSetTextColor(colorRed);


GfxSelectFont("Times New Roman", 10, 700, False );
EntryRule = LV;
BuySellText = WriteIf(Buy AND ( avoidcall), "Buy above " + WriteVal(H*1.0001, 1.1), 
				WriteIf(Short AND (avoidcall), "Sell below " + WriteVal(L*0.9999, 1.1), ""));
Buy3= C > sl; Short3 = C < sl; Buy3 = ExRem(Buy3, Short3); Short3 = ExRem(Short3, Buy3);
//Buyreentry = Buy3 AND (sl - dl) < C*0.002 AND BuyRunning AND NOT Buy; Shortreentry = (GapUpshort1) OR Short3 AND (dH - Sl) < C*0.002 AND SellRunning AND NOT Short;
Buyreentry = BuyRe_entry AND (sl - dl) < C*0.002 AND BuyRunning AND NOT Buy; Shortreentry = Shortre_entry AND (dH - Sl) < C*0.002 AND SellRunning AND NOT Short;
MSG2 = WriteIf(BuyReentry, "Buy Call Re-entry Point...  ", WriteIf(shortReentry, "Short Call Re-entry Point...  ",""));

OptionCall = WriteIf((Buy OR Ref(Buy, -1)) AND TimeNum() > 152000, "     Safe Traders are advised to Buy In-The-Money CALL Option... ", 
				WriteIf((Short OR Ref(Short, -1)) AND TimeNum() > 152000, "     Safe Traders are Advised to Buy In-The-Money PUT Option...", ""));
GfxTextOut(OptionCall, 190 , 200);
GfxTextOut(MSG2 + RunningCall + BuySellText, 5 , 200);

systemselection = WriteIf(System=="Option_Trading", "***Option Trading Selected***",
					WriteIf(System=="NiftyPro3.6", "***Nifty PRO 3.6 ver. Selected***",
					WriteIf(System=="NiftyPro3.5", "***Nifty PRO 3.5 ver. Selected***", "")));
GfxTextOut(systemselection, 150 , 58);

GfxSelectFont("Verdana", 8, 400, False);
GfxTextOut(CallWaiting, 5 , 215);


/////////////////New Functions /////////////////////

/////////////////New Functions /////////////////////

function GetSecondNum()
{
Time1 = Now( 4 );
Seconds = int( Time1 % 100 );
Minutes = int( Time1 / 100 % 100 );
Hours = int( Time1 / 10000 % 100 );
SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );
return SecondNum;
}

RequestTimedRefresh( 1 );
TimeFrame = Interval();
SecNumber = GetSecondNum();
Newperiod = SecNumber % TimeFrame == 0;
SecsLeft	 = SecNumber - int( SecNumber / TimeFrame ) * TimeFrame;

SecsToGo	 = (TimeFrame - SecsLeft) / 60;
SecstoGo1 = int( secstogo % 100);
GfxSelectFont("ARIAL", 11, 400, False);
GfxSetBkColor( colorDarkGreen ) ;
GfxSetTextColor(colorWhite);
GfxTextOut(Now(2) + ", " + WriteVal(C, 1.1), 5 , 45);

//GfxTextOut(WriteVal(SecsToGo, 1.2) + " Min.Left", 5 , 465);
//GfxTextOut(SecsToGo1 + " Min.Left", 5 , 485);


PlotShapes(shapeSmallCircle  * VCXB, colorBlue, 0, L, -5);
PlotShapes(shapeSmallCircle  * SHORTExit_11, colorBlack, 0, L, -10);
PlotShapes(shapeSmallCircle * BuyExit_11, colorBlack, 0, H, 10);
PlotShapes(shapeSmallCircle * VCXS, colorBlue, 0, H, 5);
PlotShapes(shapeSmallCircle  * Serial_ShortClimax, colorDarkRed, 0, L, -5);
PlotShapes(shapeSmallCircle * Serial_BuyClimax, colorDarkRed, 0, H, 5);
Buy3_6 = Buy AND NOT Buy1; Short3_6 = Short AND NOT Short1;
PlotShapes(shapeDigit6 * Buy3_6, colorBlack, 0, L, -5);
PlotShapes(shapeDigit6 * Short3_6, colorBlack, 0, H, 5);
PlotShapes(shapeSmallCircle * AlmostBuy, colorPlum, 0, L, 0);
PlotShapes(shapeSmallCircle * AlmostShort, colorPlum, 0, H, 0);


BuyArrow = Buy AND sbuy <= sSell;
ShortArrow = Short AND sShort <= sCover;
PlotShapes(shapeSquare * Buy , IIf(avoidcall, colorBlack, colorDarkGreen), 0, L, -20);
PlotShapes(shapeSquare * Buy , IIf(avoidcall, colorGrey50, colorLime), 0, L, -30);
PlotShapes(shapeUpArrow * Buy , colorWhite, 0, L, -25);

PlotShapes(shapeSquare * Short, IIf(avoidcall, colorBlack, colorRed), 0, H, 20);
PlotShapes(shapeSquare * Short, IIf(avoidcall, colorGrey50, colorOrange), 0, H, 30);
PlotShapes(shapeDownArrow * Short, colorWhite, 0, H, -25);

SellArrow = Sell AND NOT Short; CoverArrow =  Cover AND NOT Buy;
PlotShapes(shapeDownArrow *SellArrow , colorRed, 0, H, -5);
PlotShapes(shapeUpArrow *CoverArrow , colorRed, 0, L, -5);

PlotShapes(shapeHollowSmallUpTriangle * errorBuy , colorGreen, 0, L, -25);
PlotShapes(shapeHollowSmallDownTriangle * errorSell , colorRed, 0, H, -25);


PlotShapes(shapeSmallUpTriangle * BuyReentry , colorGreen, 0, L, -25);
PlotShapes(shapeSmallDownTriangle * Shortreentry , colorRed, 0, H, -25);

BullHd = RSIBullHD OR (RSIBullHD_1 AND Short);
BearHD = RSIBearHD OR (RSIBearHD_1 AND Buy);
PlotShapes(shapeSmallSquare  * BullHD, colorDarkGreen, 0, L, -5);
PlotShapes(shapeSmallSquare * BearHD, colorDarkGreen, 0, H, 5);

PlotShapes(shapeHollowDownArrow * KRS2, colorBlack, 0, H, -10);
PlotShapes(shapeHollowDownArrow * KRS1, colorBlack, 0, H, -10);
ClimaxSound = (VCXB OR VCXS OR AlmostBuy OR AlmostShort OR SHORTExit_11 OR BUYExit_11 OR KRS2 OR KRS1) AND NOT (Buy OR Short);

if (NOT AudioAlert) {
//AlertIf( Buy , "SOUND C:\\Windows\\Media\\Ding.wav",  " " ,  1);
//AlertIf( Short , "SOUND C:\\Windows\\Media\\Ding.wav",  " " ,  1);
noSignal = NOT Buy AND NOT Short AND NOT Cover AND NOT Sell AND TimeNum() < 152500;
AlertIf( Buy , "SOUND C:\\Windows\\Media\\Alert2.wav",  " " ,  1);
AlertIf( Short , "SOUND C:\\Windows\\Media\\Alert2.wav",  " " ,  2);
AlertIf( CoverArrow , "SOUND C:\\Windows\\Media\\Alert.wav",  " " ,  1);
AlertIf( SellArrow , "SOUND C:\\Windows\\Media\\Alert.wav",  " " ,  2);
AlertIf( HighBuyVolume AND nosignal, "SOUND C:\\Windows\\Media\\Tick.wav",  " " ,  1);
AlertIf( HighSellVolume AND noSignal, "SOUND C:\\Windows\\Media\\Tick.wav",  " " ,  2);
AlertIf( ClimaxSound , "SOUND C:\\Windows\\Media\\alert.wav",  " " ,  1);

}
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/



//Profit_Text = WriteIf(NOT NOTrade, Profit_text,"");
// Commentry output ....
EnableTextOutput(True);
printf("Analysing " + Time + " Min. Chart\n\n");
MSG1 + MSG2;
CallWaiting;
CallCheck1;

printf( "The last Automated Signal generated was a "+
WriteIf( sBuy < sShort, "BUY @ " + BuyPri, WriteIf( sBuy > sShort, "SELL @ " + SellPri, "" ))+ ", "+
WriteVal( Min( sBuy, sShort ) * time, 3.0 ) + " Min(s) ago,"  + " \n\n" +
WriteIf( sBuy < sShort AND NOT NOTrade, Long_Stoploss, WriteIf( sBuy > sShort AND NOT NOTrade, Short_Stoploss, ""))+ 
WriteIf( sBuy < sShort AND(C > BuyPri) AND NOT NOTrade, " running in Profit " + WriteVal((C - BuyPri) , 1.1) + " Pts." + MaxProfit, 
WriteIf( sBuy < sShort AND(C < BuyPri) AND NOT NOTrade, " running in Loss " + WriteVal((C - BuyPri) , 1.1) + " Pts. " + MaxProfit, 
WriteIf( sBuy > sShort AND(C < SellPri) AND NOT NOTrade, " running in Profit " + WriteVal((SellPri - C) , 1.1) + " Pts. " + MaxProfit, 
WriteIf( sBuy > sShort AND(C > SellPri) AND NOT NOTrade, " running in Loss " + WriteVal((SellPri - C) , 1.1) + " Pts. " + MaxProfit,   ""))))); 

"\n" ;
"Current Intraday Trend : " + TrendText;
"IB, NR7 or NR4 : " + IBNRText;
"\n";
if(Text_Display) 
{
"DYNAMIC Levels";
printf(RangeOut1);
"Res: " +WriteIf(DR2 > 0,  WriteVal(DR2, 1.1)+ " & " , "") +WriteIf(DR3 > 0,  WriteVal(DR3, 1.1), "");
"Sup: " +WriteIf(DS2 > 0,  WriteVal(DS2, 1.1)+ " & " , "") +WriteIf(DS3 > 0,  WriteVal(DS3, 1.1), "");;
"\n";
printf(Rule3_Text +  Normal_Text );
printf(ClosePositionText+TestRule3 + "\n");


WriteIf(BullishReversal AND ClosePosition1, "*** AVOID OVERNIGHT SHORT POSITIONS ***", 
WriteIf(BEARISHReversal AND ClosePosition2, "*** AVOID OVERNIGHT LONG POSITIONS ***", "")) ;
HookReversal;
EngulfingPattern;
}

EnableTextOutput(False);
/////////////////////////////////////////MarketMatrix/////////////////////////////////////////////////////
SellVolume = ((MAV_Value1 >= 1.1 AND L > DayL ) OR (MAV_Value1 > 3))AND C < O;
BuyVolume = ((MAV_Value1 >= 1.1 AND H < DayH) OR (MAV_Value1 > 3)) AND C > O;
Scond_101 = BarsSince(VCXS) < 12;
SCond_102 = BarsSince(SellVolume) < 12 AND BarsSince(SellVolume) < BarsSince(BuyVolume)  ;
SCond_103 = BarsSince(VixNegDiv) < 12;
Scond_104 = 0;//NegDivNum >=3;
Scond_105 = downRally;
SCond_106 = Ref(sl, -2) == Ref(sl, -12) AND C < O  AND L < Ref(L, -1);
Scond_107 = (DayH - DayL) > C*0.02 AND C > (H+L)/2  AND C < O; 
Scond_108 = ((DayH < PDH) AND (DayH == DH1 OR (PDH -DayH) < C*0.002)  AND C < O AND ((L - DayL) > C*0.002 OR L == DayL OR MAV_Value1 > 1.2) )
				|| (SND > 20 && DayH > DH1 && (DayH - DH1) < C*0.002 && C < O && (H-DayL) < C*0.012);

BCond_101 = sVCXB < 12;
BCond_102 = BarsSince(BuyVolume) < 12 AND BarsSince(SellVolume) > BarsSince(BuyVolume);
BCond_103 = BarsSince(VixPosDiv) < 12;
BCond_104 = C > O && (sVixDiv < 14 || sVixDiv1 < 14);
BCond_105 = UpRally;
BCond_106 =  Ref(sl, -2) == Ref(sl, -12)  AND C > O  AND H > Ref(H, -1);
BCond_107 = (DayH - DayL) > C*0.02  AND C < (H+L)/2  AND C > O;
bcond_108 = ((DayL > PDL) AND (DayL == DL1 OR (DayL - PDL)<C*0.002) AND C > O  AND ((DayH - H) > C*0.002 OR H == DayH OR MAV_Value1 > 1.2))
 			|| (SND > 20 && DayL < DL1 && (DL1 - DayL) < C*0.002 && C > O && (DayH-L) < C*0.012);

UpMatrix = BCond_101+BCond_102+BCond_103+BCond_104+BCond_105+BCond_106+BCond_107+BCond_108;
downMatrix = Scond_101+Scond_102+Scond_103+Scond_104+Scond_105+Scond_106+Scond_107+Scond_108;

Text1 = WriteIf(Scond_101, " 1 ", "");
Text2 =  WriteIf(SCond_102, " 2 ","");
Text3 = WriteIf(SCond_103, " 3 ","");
Text4 = WriteIf(Scond_104, " 4 ", "");
Text5 = WriteIf(Scond_105, " 5 ", "");
Text6 = WriteIf(Scond_106, " 6 ", "");
text7 = WriteIf(sCond_107, " 7 ","");
Text8 = WriteIf(Scond_108, " 8 ", "");

Text9 = WriteIf(BCond_101, " 1 ", "");
Text10 = WriteIf(Bcond_102, " 2 ", "");
Text11 = WriteIf(BCond_103, " 3 ", "");
Text12 = WriteIf(BCond_104, " 4 ", "");
Text13 = WriteIf(BCond_105, " 5 ", "");
Text14 = WriteIf(BCond_106, " 6 ", "");
Text15 = WriteIf(BCond_107, " 7 ", "");
Text16 = WriteIf(bcond_108, " 8 ", "");
/*
Text1 = " 1 ";
Text2 = " 1 ";
Text3 = " 1 ";
Text4 = " 1 ";
Text5 = " 1 ";
Text6 = " 1 ";
Text7 = " 1 ";
Text8 = " 1 ";

Text9 = " 1 ";
Text10 = " 1 ";
Text11 = " 1 ";
Text12 = " 1 ";
Text13 = " 1 ";
Text14 = " 1 ";
Text15 = " 1 ";
Text16 = " 1 ";
*/
//GfxSetBkMode(2);
//GfxSetOverlayMode(2); 
GfxSelectPen( colorBlack, 1 ); 
GfxRectangle( 3 , 65, 128, 190 );//115/240
GfxSelectFont("Tahoma", 8 );
GfxTextOut("Market Matrix", 35 , 122);
GfxSelectFont("Aerial", 14, 700, False );
GfxSetBkColor( colorRed ) ;  
GfxSetTextColor(colorWhite);
GfxTextOut(text1, 10 , 70);//GfxTextOut(text1, 30 , 120);
GfxTextOut(text2, 40 , 70);
GfxTextOut(text3, 70 , 70);
GfxTextOut(text4, 100 , 70);
GfxTextOut(text5, 10 , 100);
GfxTextOut(text6, 40 , 100);
GfxTextOut(text7, 70 , 100);
GfxTextOut(text8, 100 , 100);


GfxSetBkColor( colorDarkGreen ) ;
//GfxSetTextColor(colorGreen);
GfxTextOut(text9, 10 , 135);
GfxTextOut(text10, 40 , 135);
GfxTextOut(text11, 70 , 135);
GfxTextOut(text12, 100 , 135);
GfxTextOut(text13, 10 , 165);
GfxTextOut(text14, 40 , 165);
GfxTextOut(text15, 70 , 165);
GfxTextOut(text16, 100 , 165);


/////////////////////////////////////////End of MarketMatrix/////////////////////////////////////////////////////




printf("\n\n\n\n\n\n");


printf("\nwww.Dhavin.com this commentary is automatically generated which is for information purpose only & not a recommendation to Buy or Sell. Use at your own risk.\n\n");


" ";
EnableTextOutput(False);


Title_X	=	EncodeColor(colorWhite) +  StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g ", O, H, L, C, SelectedValue( ROC( C, 1.2 ) ) );

Plot( C, "Close", ParamColor("Candel Color", colorBlack), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
SetChartBkGradientFill( colorWhite,ParamColor("Background Bottom", bgbtmcolor), colorDarkGrey);


PlotOHLC(0,IIf(x>=XT1 & RT1 &NOT T1==0,T1,-1e10),IIf(x>=XP1 & RP1 &NOT P1==0,P1,-1e10),0,"Current Range",ParamColor("Current Range", colorTan),2048+styleCloud+styleNoTitle);
//PlotOHLC(0,IIf(x>=XT1 & RT1 &NOT T1==0,T1,-1e10),IIf(x>=XP1 & RP1 &NOT P1==0,P1,-1e10),0,"Current Range",ParamColor("HiLight Color", colorGrey40),2048+styleCloud+styleNoTitle);


Title =  EncodeColor(colorBrightGreen) + "Nifty PRO 4.2 P  " + EncodeColor(colorWhite)+Title_X +
          EncodeColor(colorBrightGreen)  + ", Rsi : " +  WriteVal(RSI(14), 1.1) +EncodeColor(colorOrange)+ RSI_Level +EncodeColor(colorPink);//+DataStopped ;

GraphXSpace = 5;





_SECTION_BEGIN("Backtest Option");


PositionSize1 = ParamToggle("Fixed Lot Size", "On|Off");
LotSize =Param("Quantity", 100, 50, 500, 50);
if (PositionSize1) {
SetPositionSize( LotSize, spsShares ); // 50 shares by default 

}
_SECTION_END();
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
EnableTextOutput(False);


/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
_SECTION_END();

i searched on net and got this afl but its showing syntax errors in amibrokers .

please help
 

Relish

Well-Known Member
#15
Even if its free ,its not ok.

Chart reading is the only method to earn consistently.

It needs a minimum of 5 years real time trading.:thumb:
Can u give example of chart reading? thank's
 

Similar threads