Signals not coming though conditions met!

hi,
i am new in afl coding.please help me in the following code.
i have camrilla afl with buy sell signals.
when close cross h1 ...buy
when close goes bello l1...sell.
when ever price cross h1 or equal h1 then buy arrow must come.
tgts should be ploted as
as tgt1 -h2
tgt2-h3
tgt3-44
when ever price goes bellow l1 or equal to l1 sell arrow must come.
that means exemrem should not be used.
tgts should be ploted
as tgt1 -l2
tgt2-l3
tgt3-l4
like that.
waiting for for coders help.
advance thanks.

If you expect help, read this. It applies to you:

1 Like

hi,
here is my code!

RequestTimedRefresh(0);
       TimeFrameRestore();

     grid_day = Day()!=Ref(Day(),-1); 
Plot(grid_day,"",colorlightGrey,styleHistogram|styleThick|styleNoLabel|styleOwnScale);
Plot( C, "Regular candles " + Name(), colorBlack, stylenoline );

      //TimeFrameSet( inDaily ); 
//Plot( C, "Close", colorWhite,styleCandle);
      //TimeFrameSet( inDaily ); 
//Plot( C, "Close", colorWhite,styleCandle);
HaClose = (O+H+L+C)/4; 
HaOpen = AMA( Ref( HaClose, -1 ), 0.3 ); 
HaHigh = Max( H, Max( HaClose, HaOpen ) ); 
HaLow = Min( L, Min( HaClose, HaOpen ) ); 
xDiff = (HaHigh - Halow) * IIf(StrFind(Name(),"JPY"),100,10000);
barcolor = IIf(HaClose >= HaOpen,colorGreen,colorRed);
if( ParamToggle("Plot Heikin-Ashi", "No,Yes", 1 ) )
   PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "Heikin Ashi " + Name(), colorWhite, styleCandle );
else
Plot( C, "Regular candles " + Name(), colorWhite, styleCandle );
//PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "", barcolor, styleCandle ); 
//BUYSL = Ref(HALOW,-1);
//SELLSL = Ref(HAHIGH,-1);
//Plot(BUYSL,"BUYSL",styleNOLine,colorAqua);
_SECTION_END();
/////Day OHLC
TODAYH  = TimeFrameGetPrice("H", inDaily);	
TODAYL  = TimeFrameGetPrice("L", inDaily);	
TODAYO  = TimeFrameGetPrice("O", inDaily);
Ldc = TimeFrameGetPrice("C", inDaily, -1); // yesterdays Sclose
Ldccol = IIf(C>Ldc,colorGreen,colorRed);
dr = todayh-todayl;
GfxSelectFont("Trebuchet MS",12,500);
//GfxSelectFont( "Script MT Bold", 12, 100, False );

///
GfxSetBkColor(colorBlue);
GfxSetTextColor(colorBlack);
GfxTextOut(" D_H : "+TODAYH+" ", 270 ,27);
GfxSetTextColor(colorBlack);
GfxSetBkColor(colorRed);
GfxTextOut(" D_L : "+TODAYL+" ", 409 ,27);
GfxSetBkColor(colorGrey40);
GfxTextOut(" D_O : "+TODAYO+" ", 155 ,27);
GfxSetBkColor(8);
//GfxTextOut(" RANGE : "+DR+" ", 470 ,98);

//GfxSetTextColor(1);
           GfxSetBkColor(14);

GfxTextOut(" RANGE: "+WriteVal(DR,format=1.4)+" ", 255 ,46);
            GfxSetTextColor(ColorRGB(8,244,255));
nc = Close-Ldc;
GfxSetBkColor(colorBlack);
GfxSelectFont("Trebuchet MS", 15,500, False ); 
GfxTextOut(" LTP : "+WriteVal(C,format=1.4)+" ", 251 ,71);
ldcCol = IIf( Close > Ldc, colorGreen, colorRed ); ////GfxSetBkColor(color);
GfxSetBkColor( LastValue(Ldccol));
GfxTextOut(" "+WriteVal(nC,format=1.4)+" " , 469 ,71);

GfxSelectSolidBrush(ColorRGB(125,158,192));
GfxRoundRect( 3, 300, 151, 420, 20, 20 ); 
GfxSetBkColor(0);
GfxSelectFont("Trebuchet M", 13, 700, True, True, 0);
/////GfxSelectFont("Trebuchet MS",13,500);
GfxSetTextColor(colorBlack);
GfxTextOut(" O"+": "+WriteVal(O,format=1.4)+" ", 9,320 );
GfxTextOut(" H"+": "+WriteVal(H,format=1.4)+" ", 9, 340 );
GfxTextOut(" L"+": "+WriteVal(L,format=1.4)+" ", 9, 360 );
GfxTextOut(" C"+": "+WriteVal(C,format=1.4)+" ", 9, 380 );
GfxSelectFont("CALBRI",13,500);
GfxSelectPen( colorIndigo, 3 ); 
_SECTION_BEGIN("Background Color");
BKswitch = ParamToggle("Background Color","On,Off");
 OUTcolor = ParamColor("Outer Panel Color",colorLightBlue);
INUPcolor = ParamColor("Inner Panel Upper", ColorRGB(210,180,140));///tan color 
INDNcolor = ParamColor("Inner Panel Lower",ColorRGB(210,180,140));
TitleColor = ParamColor("Title Color ",ColorRGB(210,180,140));
 if (NOT BKswitch)
{
SetChartBkColor(OUTcolor);
SetChartBkGradientFill(INUPcolor,INDNcolor,TitleColor); // color of inner panel
}
 DDate = WriteVal( (DateTime() ), formatDateTime );
           //GfxTextOut(ddate,83, 299 );
           /////banladesh
                Ribbon1=IIf( EMA( Close , 10 )>EMA( Close , 20 ) ,colorGreen, IIf(EMA( Close , 20 )>EMA( Close , 10 ), colorRed,colorYellow));
Plot(6, "Ribbon", Ribbon1, styleOwnScale| styleArea| styleNoLabel,-1.97,100);

_SECTION_BEGIN("Niftytiger Camarilla Levels");

// Background color

SetChartBkGradientFill( ParamColor("BgTop", colorDarkGrey),
ParamColor("BgBottom", colorDarkGrey),ParamColor("titleblock",colorDarkGrey ));



//---- BUY SELL FORMULA

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);
R6 = (DayH / DayL) * DayC * 1.09;
H5 = (DayH / DayL) * 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;
CH1 = ( ( (DayH / DayL) + 10) / 11) * DayC;
 
CL1 = (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 = (2-( DayH / DayL)) * DayC;
S6 = (2-( DayH / DayL)) * DayC * 0.998;
   cambuy = (l3+l4)/2;
      camsell = (h3+h4)/2;
               TimeFrameSet(inDaily);
      sbuy = ch1;//TimeFrameExpand( ch1, inDaily ); // expand for display 
       ssell = cl1;//TimeFrameExpand( cl1, inDaily ); // expand for display 
       TimeFrameRestore();
       
Buy=  C>=CH1;///Cross(C,sbuy) AND C>sbuy AND TimeNum()>091400 AND TimeNum()<235900;//Cross(C,sbuy );/// OR C<intrab;
Sell = C<=CL1;////Cross(ssell,C) AND C<ssell AND TimeNum()>091400 AND TimeNum()<235900;//Cross(C,ssell);    
        //BuyPrice = ValueWhen( Buy, SBUY);
        //SellPrice = ValueWhen( Sell, SSELL);
  Buy[BarCount-1]=Null;                             
Sell[BarCount-1]=Null;                
Buy = Cover=ExRem(Buy, Sell);
 Sell = Short=ExRem(Sell, Buy);
//   dist = 3*ATR(20);         OVER=
//dist1 = 3*ATR(20);
//for( i = 0; i < BarCount; i++ ) 
//{ 
// if( Buy[i] ) 
// {
//  PlotText( "\nBuy:" + CH1+  "\nSL= " + CL1, i, L[ i ]-dist[i], colorWhite, colorBlue );
// }
// if( Sell[i] )
// {
//  PlotText( "Sell:" + CL1 + "\nSL= " + CH1, i, H[ i ]+dist1[i], colorWhite, colorRed ); 
// }
//}
  ///plot buy sell text
     Version(6.20);

fntsize = 9;// font size
dist = 109;// y-offset

bi = Barindex();
fvb = FirstVisiblevalue( bi );
lvb = LastVisiblevalue( bi );
dt = DateTime();
dtformat = "\n%Y-%m-%d\n%H:%M:%S:";
bkcolor = colorDARKRed;// text background color, -1 means default color (transparent)

PlotTextSetFont( "", "CANBRI", fntsize, BarCount-1, 0, -1 );

for ( i = fvb; i <= lvb; i++ ) {
    if( Buy[i] || Sell[i] )	{
		var = "\n" + CH1[i] +"\n"+"SL:   "+ "\n"+CL1[i]+ DateTimeFormat(dtformat, dt[i]);
		var1 = "\n@" + CL1[i]+ "\n"+"SL:   "+ "\n"+CH1[i]+ DateTimeFormat(dtformat, dt[i]);
		if( Buy[i] )  PlotText( "Buy" + var, i, L[i], colorWhite, 6, -dist+3*fntsize );
		if( Sell[i] ) PlotText( "Sell" + var1, i, H[i], colorWhite, colorDARKRed, dist+58 );
    }
}
PlotShapes( IIf( Buy, shapeUpArrow, shapeNone ), colorBrightGreen, layer = 0,yposition = HaLow, offset = -19);
     PlotShapes( IIf( Sell, shapeDownArrow, shapeNone ), colorYellow, layer = 0,yposition = HaLow, offset = -88);
 ///buy sell ends

ShowH5 = ParamToggle("H5", "No|Yes");
H5Color=ParamColor( "H5Color", colorGold );
ShowH4 = ParamToggle("H4", "No|Yes");
H4Color=ParamColor( "H4Color", colorDarkRed );
ShowH3 = ParamToggle("H3", "No|Yes");
H3Color=ParamColor( "H3Color", colorRed );
ShowH2 = ParamToggle("H2", "No|Yes");
H2Color=ParamColor( "H2Color", colorOrange );
ShowCH1 = ParamToggle("CH1", "No|Yes");
CH1Color=ParamColor( "CH1Color", colorYellow );

ShowCL1 = ParamToggle("CL1", "NO|YES"); 
CL1Color=ParamColor( "CL1Color", colorYellow);
ShowL2 = ParamToggle("L2","No|Yes");
L2Color=ParamColor( "L2Color", colorOrange );
ShowL3 = ParamToggle("L3", "No|Yes");
L3Color=ParamColor( "L3Color", colorGreen );
ShowL4 = ParamToggle("L4", "No|Yes");
L4Color=ParamColor( "L4Color", colorDarkRed );
ShowL5 = ParamToggle("L5", "No|Yes");
L5Color=ParamColor( "L5Color", colorGold );

//Shadowcolor = ParamColor("Shadow",ColorRGB(40,30,20));
//ShadowcoloCH1 = ParamColor("Shadow1",ColorRGB(20,30,20));
//ShadowcoloH2 = ParamColor("Shadow2",ColorRGB(30,40,0));

//style = styleDots | styleThick + styleNoRescale ; 
style = styleNoLine ; 

if(ShowH5 == False)
Plot(H5, "H5",H5Color,style);
if(ShowH4 == False) 
Plot(H4, "H4",H4Color,Style);
if(ShowH3 == False)
Plot(H3, "H3",H3Color,style);
if(ShowH2 == False) 
Plot(H2, "H2",H2Color,stylenoline);
if(ShowCH1 == False)
Plot(CH1, "CH1",CH1Color,stylenoline);

if(ShowCL1 == False)
Plot(CL1, "CL1",CL1Color,stylenoline);
if(ShowL2 == False)
Plot(L2, "L2",L2Color,stylenoline);
if(ShowL3 == False)
Plot(L3, "L3",L3Color,style,0);
if(ShowL4 == False) 
Plot(L4, "L4",L4Color,style);
if(ShowL5 == False) 
Plot(L5, "L5",L5Color,style); 

ToolTip=StrFormat("Open: %g\nHigh: %g\nLow: %g\nClose: %g (%.1f%%)\nVolume: "+NumToStr( V, 1 ), O, H, L, C, SelectedValue( ROC( C, 1)));
TimeFrameRestore();
SHOWLEVLES=ParamToggle("Show Buy Sell levels","Yes|No",0);
if     (SHOWLEVLES){
Title = EncodeColor(colorWhite)+ "NIFTYTIGER CAMARILLA LEVELS" + " - " +  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(colorAqua)+   "\n csell: "+ EncodeColor(colorYellow)+camsell

+ EncodeColor(colorWhite)+   "\n H5 (TGT): "+ EncodeColor(colorWhite)+H5
+ EncodeColor(colorWhite)+   "\n H4 (SL&buy): "+ EncodeColor(colorWhite)+H4
+ EncodeColor(colorRed)+   "\n H3 (SHORT): "+ EncodeColor(colorRed)+H3
+ EncodeColor(colorWhite)+   "\n H2: "+ EncodeColor(colorWhite)+H2
+ EncodeColor(colorWhite)+   "\n H1: "+ EncodeColor(colorWhite)+CH1
+ EncodeColor(colorWhite)+   "\n L1: "+ EncodeColor(colorWhite)+CL1
+ EncodeColor(colorWhite)+   "\n L2: "+ EncodeColor(colorWhite)+L2
+ EncodeColor(colorBrightGreen)+   "\n L3 (LONG): "+ EncodeColor(colorBrightGreen)+L3
+ EncodeColor(colorWhite)+   "\n L4 (SL&SELL): "+ EncodeColor(colorWhite)+L4
+ EncodeColor(colorWhite)+   "\n L5 (Tgt): "+ EncodeColor(colorWhite)+L5
+ EncodeColor(colorAqua)+   "\n cbuy: "+ EncodeColor(colorYellow)+cambuy;
}
     showpl=ParamToggle("Show price line","On,Off",0);
    if (showpl==1){
    _SECTION_BEGIN("Price Line");
dp= Param("dps",3,0,1000,1);
PriceLineColor=ParamColor("PriceLineColor",ColorRGB(82,82,82));
PriceLevel = ParamField("PriceField", field = 3 ); 
PriceLeve2 = ParamField("PriceField", field = dp );
Daysback    = Param("Bars Back",1,10,500,1); 
FirstBar    = BarCount - DaysBack; 
YY          = IIf(BarIndex() >= Firstbar,EndValue(PriceLevel),Null); 

//Plot(YY,"Current Price",PriceLineColor,ParamStyle("LineStyle",styleLine|styleDashed|styleNoTitle|styleNoLabel|styleThick,maskAll)); 

PC=TimeFrameGetPrice( "C", inDaily, -1 ); 
//Plot(pc,"Current Price",PriceLineColor,ParamStyle("LineStyle",styleLine|styleDashed|styleNoTitle|styleNoLabel|styleThick,maskAll)); 

side = Param("side",1,0,1000,1);

dist = 0; 

for( i = 0; i < BarCount; i++ ) 
{ 
 if(i+side== BarCount) PlotText( "\n         Ltp:   " + PriceLevel[ i ], i, YY[ i ]+1, colorWhite );
//if(i+side== BarCount) PlotText( "\n    " + Pc[ i ], i, pc[ i ]-dist[i], colorLightBlue ); 
} 
    }
_SECTION_END();

_SECTION_END();
    //---- heikin ashi
    //---- heikin ashi
    /////LTP STARTS
    
         //}
//



_SECTION_BEGIN("Heikin Ashi Trading System");

SetOption( "InitialEquity", 200000);
SetTradeDelays( 1, 1, 1, 1 );
SetOption("FuturesMode" ,True);
SetOption("MinShares",1);
SetOption("CommissionMode",2);
SetOption("CommissionAmount",50);
SetOption("AccountMargin",10);
SetOption("RefreshWhenCompleted",True);
SetPositionSize(120,spsShares);
SetOption( "AllowPositionShrinking", True );

BuyPrice=Open;
SellPrice=Open;
ShortPrice=Open;
CoverPrice=Open;

SetChartOptions(0,chartShowArrows|chartShowDates);
//_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C ));
 
HaClose = (O + H + L + C)/4; 
HaOpen = AMA( Ref( HaClose, -1 ), 0.3 ); 
HaHigh = Max( H, Max( HaClose, HaOpen ) ); 
HaLow = Min( L, Min( HaClose, HaOpen ) ); 

barcolor = IIf(HaClose >= HaOpen,colorGreen,colorRed);

//PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "", barcolor, styleCandle );

printf("\nHaOpen : " + HaOpen );  
printf("\nHaHigh : " + HaHigh );  
printf("\nHaLow : " + HaLow );  
printf("\nHaClose : " + HaClose );  

Candles=param("Candles",1,1,5,1);
periods=param("periods",40,10,200,10);

Buy = Sum(HaClose >= HaOpen,Candles)==Candles AND HaOpen==HaLow;//AND C>EMA(C,periods);
Sell= Sum(HaClose <= HaOpen,Candles)==Candles AND HaOpen=HaHigh;/// AND C<EMA(C,periods);
//Sell=Short OR C<EMA(C,periods);
//Cover=Buy OR C>EMA(C,periods);

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

printf("\nBuy : " + Buy );  
printf("\nSell : " + Sell );  
//printf("\nShort : " + Short );  
//printf("\nCover : " + Cover );  

Stoploss=param("SL",1,1,5,1);

ApplyStop(Type=0,Mode=1,Amount=StopLoss);

for( i = 0; i < BarCount; i++ )
{                      
x = SelectedValue( BarIndex() );
y = Close[ x ];

PlotTextSetFont("", "tahoma", 9, x, y, colorGreen, colorDefault, -48 );
if( Buy[i] ) PlotText( "Buyn@" +"\n"+ C[ i ], i, L[ i ]-78, colorGreen,colorLightYellow );
if( Sell[i] ) PlotText( "Selln@"+"\n" + C[ i ], i, H[ i ]+118, colorRed, colorYellow );
}

//PlotShapes( Buy * shapeUpArrow + Sell * shapeDownArrow, IIf( Buy, colorGreen, colorRed ) );
/* Plot Buy and Sell Signal Arrows */
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-25);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-35);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-32);
//PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
//PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
//PlotShapes(IIf(Cover, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
//PlotShapes(IIf(Short, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
//PlotShapes(IIf(Short, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
//PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);


_SECTION_END();
GfxSetTextColor(colorWhite);
GfxSetBkColor(colorBlack);
GfxSelectFont("Audiowide", 38,500, False );                
GfxTextOut(" LTP :"+WriteVal(C,format=1.4)+" ",140,423);

when ever price cross h1 or equal h1 then buy arrow must come.
tgts should be ploted as
as tgt1 -h2
tgt2-h3
tgt3-44
when ever price goes bellow l1 or equal to l1 sell arrow must come.
that means exemrem should not be used.
tgts should be ploted
as tgt1 -l2
tgt2-l3
tgt3-l4
like that.
waiting for for coders help.
advance thanks.

Moderator comment: Added REQUIRED code tags

Your post is NOT following forum rules and advice on how to write good question.
Specifically your post missed required CODE TAGS.
I added code tags myself to your post but still your request is missing on many fronts and is not something anyone can answer.

1 Like

thanks a lot for your help.
i am very new to post a help...so mistakes done in posting my message!
kindly understand and suggest a solution for my issue!
waiting for help on my told issue!
once again thanks.