My visual effect afl collection.

yasu222

Active Member
RDX Indicator -

PHP:
_SECTION_BEGIN("RDX");
SetChartOptions(0,chartShowArrows|chartShowDates);
SetChartOptions(2, chartWrapTitle|chartHideQuoteMarker);
grid_day = Day()!=Ref(Day(),-1);
Plot(grid_day,"",colorLightGrey,styleHistogram|styleDashed|styleNoLabel|styleOwnScale);

NO1 = Param("GR",5,1,90,1);

C1 = IIf((C>O) AND Ref(H,-1)<H,1,IIf((C<O) AND Ref(L,-1)>L,-1,0));
C2 = IIf((C>O) AND Ref(H,-1)>H,-1,IIf((C<O) AND Ref(L,-1)<L,1,0));

BU = Sum(C1,NO1);
BE = Sum(C2,NO1);
RDX = MA((BU-BE),NO1);

Plot(BU,"BU",colorBrightGreen,styleDashed);
Plot(BE,"BE",colorRose,styleDashed);
Plot(RDX,"ADX",colorLightGrey,styleLine|styleThick);
 

yasu222

Active Member
May Be useful

PHP:
_SECTION_BEGIN("GaNN Square of Nine");
SetChartOptions(2, chartWrapTitle|chartHideQuoteMarker);
BarsToday = 1 + BarsSince( Day() != Ref(Day(), -1));

StartBar =Open;

TodayVolume = Sum(V,BarsToday);
GT = Param("Gann_Time",092000,091500,235500,100);

RefOpen = ValueWhen(TimeNum() == GT, Open,1);

BaseNum = (int(sqrt(RefOpen))-1);
sBelow = BaseNum + BaseNum;
sBelowI = 1;

//Calculate levels for GANN Square of Nine

for( i = 1; i < 50; i++ )
{
VarSet( "GANN"+i, (BaseNum * BaseNum) );
BaseNum = BaseNum + 0.125;
sBelowI = IIf( VarGet("GANN"+i)< RefOpen, i, sBelowI);
bAboveI = sBelowI + 1;
sBelow = round(VarGet("GANN"+sBelowI));
bAbove = round(VarGet("GANN"+bAboveI));
}

// Resistance Levels (or Targets for Buy trade)
BTgt1 = round(0.9995 * VarGet("Gann"+(bAboveI+1)));
BTgt2 = round(0.9995 * VarGet("Gann"+(bAboveI+2)));
BTgt3 = round(0.9995 * VarGet("Gann"+(bAboveI+3)));
BTgt4 = round(0.9995 * VarGet("Gann"+(baboveI+4)));
BTgt5 = round(0.9995 * VarGet("Gann"+(bAboveI+5)));
BTgt6 = round(0.9995 * VarGet("Gann"+(baboveI+6)));
// Support Levels (or Targets for Short trade)
STgt1 = round(1.0005 * VarGet("Gann"+(sBelowI-1)));
STgt2 = round(1.0005 * VarGet("Gann"+(sBelowI-2)));
STgt3 = round(1.0005 * VarGet("Gann"+(sBelowI-3)));
STgt4 = round(1.0005 * VarGet("Gann"+(sbelowI-4)));
STgt5 = round(1.0005 * VarGet("Gann"+(sBelowI-5)));
STgt6 = round(1.0005 * VarGet("Gann"+(sBelowI-6)));

Sstop= round(babove-((babove-sbelow)/3)) ;
Bstop= round(sbelow+((babove-sbelow)/3)) ;

BuySignal = TimeNum()>GT AND Cross(C,babove);
ShortSignal = TimeNum()>GT AND Cross(Sbelow,C);

BuySignal = ExRem(BuySignal,ShortSignal);
ShortSignal = ExRem(ShortSignal,BuySignal);

ShortProfitStop= (STgt1 AND L<=Stgt1 AND C>Stgt1) OR (STgt2 AND L<=Stgt2 AND C>Stgt2) OR (STgt3 AND L<=Stgt3 AND C>Stgt3) OR (STgt4 AND L<=Stgt4 AND C>Stgt4) OR (STgt5 AND L<=Stgt5 AND C>Stgt5) OR (STgt6 AND L<=Stgt6 AND C>Stgt6);

BuyProfitStop= (Btgt1 AND H>=btgt1 AND C<Btgt1) OR (Btgt2 AND H>=Btgt2 AND C<btgt2) OR (Btgt3 AND H>=Btgt3 AND C<btgt3) OR (Btgt4 AND H>=Btgt4 AND C<btgt4) OR (Btgt5 AND H>=Btgt5 AND C<btgt5) OR (Btgt6 AND H>=Btgt6 AND C<btgt6);

Buy = BuySignal;
Sell = C<Bstop ;
Short = ShortSignal;
Cover = C>SStop ;

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

Sstop= round(babove) ;
Bstop= round(sbelow) ;
_SECTION_BEGIN("Background text");
SetChartBkColor(colorBlack);
strWeekday = StrMid("---SUNDAY---MONDAY--TUESDAYWEDNESDAY-THURSDAY--FRIDAY--SATURDAY", SelectedValue(DayOfWeek())*9,9);
GraphXSpace=Param("GraphXSpace",0,-55,200,1);
C13=Param("fonts",14,10,30,1 );
C14=Param("left-right",2.1,1.0,5.0,0.1 );
C15=Param("up-down",12,1,20,1 );
Miny = Status("axisminy");
Maxy = Status("axismaxy");
lvb = Status("lastvisiblebar");
fvb = Status("firstvisiblebar");
pxwidth = Status("pxwidth");
pxheight = Status("pxheight");
YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);
GfxSetBkMode(transparent=1);
GfxSetOverlayMode(1);
GfxSelectFont("Candara", Status("pxheight")/C13 );
GfxSetTextAlign( 6 );
GfxSetTextColor( ColorRGB (217,217,213));
GfxTextOut( Name(), Status("pxwidth")/C14, Status("pxheight")/C15+240);
GfxSelectFont("Tahoma", Status("pxheight")/C13*0.5 );
GfxSetTextColor(ColorRGB (217,217,213));
GfxTextOut( "L.T.P. : "+ C +"", Status("pxwidth")/C14, Status("pxheight")/C15*2+240 );
GfxSelectFont("Candara", Status("pxheight")/C13*0.5 );
GfxSetTextColor( ColorRGB (103,103,103));
GfxTextOut( ""+DD+ " ( "+xx+"%)", Status("pxwidth")/C14, Status("pxheight")/C15*2.5+250);
GfxSelectFont("Candara", Status("pxheight")/C13*0.5 );
GfxSetTextColor( ColorRGB (0,265,0));
GfxTextOut( "Buy Above :"+sstop+"", Status("pxwidth")/C14-450, Status("pxheight")/C15*6);
GfxSetTextColor( ColorRGB (265,0,0));
GfxTextOut( "Buy S/L :"+Bstop+"", Status("pxwidth")/C14-350, Status("pxheight")/C15*7);
GfxSetTextColor( ColorRGB (265,0,0));
GfxTextOut( "Sell Below :"+bstop+"", Status("pxwidth")/C14+450, Status("pxheight")/C15*6);
GfxSetTextColor( ColorRGB (0,265,0));
GfxTextOut( "Sell S/L :"+sstop+"", Status("pxwidth")/C14+350, Status("pxheight")/C15*5);
GfxSetTextColor( ColorRGB (0,265,0));
GfxTextOut( "Buy TGT 1 : "+BTgt1+"", Status("pxwidth")/C14-350, Status("pxheight")/C15*5);
GfxTextOut( "Buy TGT 6 : "+BTgt6+"", Status("pxwidth")/C14+225, Status("pxheight")/C15*4);
GfxTextOut( "Buy TGT 2 : "+BTgt2+"", Status("pxwidth")/C14-225, Status("pxheight")/C15*4);
GfxTextOut( "Buy TGT 5 : "+BTgt5+"", Status("pxwidth")/C14+125, Status("pxheight")/C15*3);
GfxTextOut( "Buy TGT 3 : "+BTgt3+"", Status("pxwidth")/C14-125, Status("pxheight")/C15*3);
GfxTextOut( "Buy TGT 4 : "+BTgt4+"", Status("pxwidth")/C14, Status("pxheight")/C15*2);
GfxSetTextColor( ColorRGB (265,0,0));
GfxTextOut( "Sell TGT 1 : "+STgt1+"", Status("pxwidth")/C14+350, Status("pxheight")/C15*7);
GfxTextOut( "Sell TGT 6 : "+STgt6+"", Status("pxwidth")/C14-225, Status("pxheight")/C15*8);
GfxTextOut( "Sell TGT 2 : "+STgt2+"", Status("pxwidth")/C14+225, Status("pxheight")/C15*8);
GfxTextOut( "Sell TGT 5 : "+STgt5+"", Status("pxwidth")/C14-125, Status("pxheight")/C15*9);
GfxTextOut( "Sell TGT 3 : "+STgt3+"", Status("pxwidth")/C14+125, Status("pxheight")/C15*9);
GfxTextOut( "Sell TGT 4 : "+STgt4+"", Status("pxwidth")/C14, Status("pxheight")/C15*10);

_SECTION_END();

_SECTION_BEGIN("Title");

DODay = TimeFrameGetPrice("O", inDaily);
DHiDay = TimeFrameGetPrice("H", inDaily);
DLoDay = TimeFrameGetPrice("L", inDaily);
Title = EncodeColor(colorWhite)+EncodeColor(colorWhite)+ "Gann_Square_9"+
"\n" + Interval(2) + ", " + Date() + " - "+strWeekday + " - " +
EncodeColor(colorWhite) + "\nOpen " + EncodeColor(colorWhite) + O +

", High : " + H +
", Low : " + L +
", Close : " + C +
"\n"+EncodeColor(colorWhite)+ " Day-Open : " +DODay + " Day-High : " +DHiDay + " Day-Low : " + DLoDay
;
 

Attachments

Last edited:

yasu222

Active Member
PHP:
_SECTION_BEGIN("LINTRA_CHANNEL");
SetBarsRequired( 10000, 10000);
SetChartOptions(2, chartWrapTitle|chartHideQuoteMarker);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
NO1 = Param("WMA",3,2,100,1);
NO2 = Param("ATR",2,1,10,0.1);
NO3 = Param("STD.DEV",7,2,50,1);
Derived=WMA(((H+L)/2)+(O-C),NO1);
i=WMA(Derived,3);
Upper=(Derived+StDev(Derived,NO3))+ATR(NO2)/1.5;
Lower=(Derived-StDev(Derived,NO3))-ATR(NO2)/1;
color=IIf(BarsSince(Cross(Lower,C))>
BarsSince(Cross(C,Upper)), colorBrightGreen,colorRed);
Plot(C,"",Color,64);
Plot(Upper,"upper band",colorBrightGreen,styleDashed);
Plot(Lower,"lower band",colorRose,styleDashed);

/* Buy or Sell Condition */
Buy = Cross(Close,Upper);
Sell = Cross(Lower,Close);
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);

Filter = Buy OR Sell;
/* Exploration Parameters */
AddTextColumn( FullName(), "Company Name" );
AddColumn( Buy, "Buy", 1 );
AddColumn( Sell, "Sell", 1 );
AddColumn( C, "Close", 1.3 );
AddColumn( H, "High", 1.3 );
AddColumn( Lower, "Lower Band", 1.3 );
AddColumn( Upper, "Upper Band", 1.3 );

PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);                    
PlotShapes(IIf(Buy, 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);
_SECTION_END();
 

yasu222

Active Member
PHP:
_SECTION_BEGIN("Darvas Box");
SetChartOptions(0,chartShowArrows|chartShowDates); 
box1=0;
box2=0;
SetBarsRequired(10000,10000);
procedure fillDarvas(start,end,swap,top, bottom )
{
   for ( j = start; j < end; j++)
   {
       if( box1[j] == swap)
  box1[j]= top ;
else
box1[j]= bottom;

       if(box2[j] == swap)
  box2[j]= bottom ;
else
box2[j]= top;
   }
}

BoxArr1 = 0;
BoxArr2 = 0;
StateArray = 0;
DBuy = 0;
DSell = 0;
TopArray = 0;
BotArray = 0;
tick=0;

BoxTop = High[0];
BoxBot = Low[0];
swap=0;
state = 0;
BoxStart = 0;

for (i=0; i<BarCount; i++)
{
 if (state==5)
 {
  TopArray[i]=BoxTop;
  BotArray[i]=BoxBot;
  if (Low[i]<(BoxBot*(1-tick/100)) || High[i]>(BoxTop*(1+tick/100)))
  {
fillDarvas(BoxStart,i,swap,BoxTop,BoxBot);

  state = 1;
  swap =  !swap;
  BoxTop = High[i];
  BoxStart = i;
  }
 }
 else
 {
  if (High[i]<BoxTop)
  {
      if ((state<3) || (Low[i]>BoxBot))
      {
   state++;
   }
      else
   {
      state=3;
   }
      if (state==3)
      BoxBot=Low[i];
  }
  else
  {
      state=1;
      BoxTop=High[i];
  }
 }
 StateArray[i] = state;
}

fillDarvas(BoxStart,BarCount,swap,BoxTop,BoxBot);
Buy=Cover=H>Ref(box1,-1) AND H>Ref(box2,-1) AND Ref(statearray,-1)==5;
Short=Sell=L<Ref(box1,-1) AND L<Ref(box2,-1) AND Ref(statearray,-1)==5;

//Plot( box1, " RESI " , colorLime, styleLine );
//Plot( box2, " SUPP" , colorOrange, styleLine );

Plot( box1,"\n"+ "RESI " , colorLime, styleDashed );
Plot( box2, " SUPP" , colorOrange, styleDashed);

_SECTION_END();
 

Nikhil Dogra

Well-Known Member
I find this AFL very useful in short term trading. This plots live intra day "new high/low"

PHP:
//GraphXSpace = 5 ;
//SetChartOptions(0,chartShowArrows|chartShowDates);
//Plot( C, "Close", colorBlack, styleNoTitle | ParamStyle("Style") | GetPriceStyle() );

_SECTION_BEGIN("Hi and LO of the day");
TLH = ParamToggle("Days Hi Lo","Off|On",1);
if (TLH==1) {
  Hodcolorsheme=ParamColor("High of day color",colorBlue);
  LodColorscheme=ParamColor("Low of day color",colorGreen);
  tempnum = TimeNum();
  temphi[0] = H[0];
  temphiColor[0] = Hodcolorsheme;
  templo[0] = L[0];
  temploColor[0] = LodColorscheme;
  for( i = 1; i < BarCount; i++ )
  {
  if(tempnum[i] - tempnum[i-1] > Interval())
  {
  if(H[i] > temphi[i-1])
  {
  temphi[i] = H[i];
  temphiColor[i] = Hodcolorsheme;
  }
  else
  {
  temphi[i] = temphi[i-1];
  temphiColor[i] = Hodcolorsheme;
  }
  if(L[i] < templo[i-1])
  {
  templo[i] = L[i];
  temploColor[i] = LodColorscheme;
  }
  else
  {
  templo[i] = templo[i-1];
  temploColor[i] = LodColorscheme;
  }
  }
  else
  {
  temphi[i] = H[i];
  temphiColor[i] = Hodcolorsheme;
  templo[i] = L[i];
  temploColor[i] = LodColorscheme;
  }
  }
  Plot(temphi,"", temphiColor,styleBar);
  Plot(templo,"", temploColor,styleBar);
}
_SECTION_END();
 

yasu222

Active Member
PHP:
_SECTION_BEGIN("Multi Pivots");

//chart colors
SetChartBkColor(ParamColor("Outer panel",colorBlack));
SetChartBkGradientFill(
ParamColor("Inner panel upper",colorBlack),
ParamColor("Inner panel lower",colorBlack)
,ParamColor("TitleBlock",colorLightGrey));
SetChartOptions(0,chartShowDates|chartShowArrows|chartLogarithmic|chartWrapTitle);

//basic price plotting
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );

T_F =ParamList("Pivot T_F","iDay|Hourly|2_Hrs|3_Hrs|4_Hrs|EOD|Weekly|Mo n thly");

if (T_F=="iDay")
{
H_1 = TimeFrameGetPrice( "H", inDaily, -1 );
L_1 = TimeFrameGetPrice( "L", inDaily, -1 );
C_1 = TimeFrameGetPrice( "C", inDaily, -1 );
O = TimeFrameGetPrice("O", inDaily); // current day's open
}
else if (T_F == "Hourly")
{
H_1 = TimeFrameGetPrice( "H", inHourly, -1 );
L_1 = TimeFrameGetPrice( "L", inHourly, -1 );
C_1 = TimeFrameGetPrice( "C", inHourly, -1 );
O = TimeFrameGetPrice( "O", inHourly );
}
else if (T_F == "2_Hrs")
{
H_1 = TimeFrameGetPrice( "H", inHourly*2, -1 );
L_1 = TimeFrameGetPrice( "L", inHourly*2, -1 );
C_1 = TimeFrameGetPrice( "C", inHourly*2, -1 );
O = TimeFrameGetPrice( "O", inHourly*2);
}
else if (T_F == "3_Hrs")
{
H_1 = TimeFrameGetPrice( "H", inHourly*3, -1 );
L_1 = TimeFrameGetPrice( "L", inHourly*3, -1 );
C_1 = TimeFrameGetPrice( "C", inHourly*3, -1 );
O = TimeFrameGetPrice( "O", inHourly*3);
}
else if (T_F == "4_Hrs")
{
H_1 = TimeFrameGetPrice( "H", inHourly*4, -1 );
L_1 = TimeFrameGetPrice( "L", inHourly*4, -1 );
C_1 = TimeFrameGetPrice( "C", inHourly*4, -1 );
O = TimeFrameGetPrice( "O", inHourly*4 );

}
else if (T_F == "EOD")
{
H_1 = TimeFrameGetPrice( "H", inDaily, 0 );
L_1 = TimeFrameGetPrice( "L", inDaily, 0 );
C_1 = TimeFrameGetPrice( "C", inDaily, 0 );
O = TimeFrameGetPrice( "O", inDaily );

}
else if (T_F == "Weekly")
{
H_1 = TimeFrameGetPrice( "H", inWeekly, -1 );
L_1 = TimeFrameGetPrice( "L", inWeekly, -1 );
C_1 = TimeFrameGetPrice( "C", inWeekly, -1 );
O = TimeFrameGetPrice( "O", inWeekly );
}
else if (T_F == "Monthly")
{
H_1 = TimeFrameGetPrice( "H", inMonthly, -1 );
L_1 = TimeFrameGetPrice( "L", inMonthly, -1 );
C_1 = TimeFrameGetPrice( "C", inMonthly, -1 );
O = TimeFrameGetPrice( "O", inMonthly );
}

// To calculate the Pivot Levels

R = H_1 - L_1; // Range
_N(Pivot =ParamList("Pivot Type ", "Classical|Woodies|Fibonacci|WF"));

if (Pivot =="Classical" )
{
PP = (H_1 + L_1 + C_1) / 3;
r1 = (2 * PP) - L_1 ;
s1 = (2 * PP) - H_1 ;
r2 = PP - s1 + r1;
s2 = PP - (r1 - s1) ;
r3 = 2 * (PP - L_1) + H_1 ;
s3 = L_1 - (2 * (H_1 - PP));
r4 = Null;
s4 = Null;
}
else if(Pivot =="Woodies" )
{
PP = (H_1 + L_1 + C_1 + O) / 4;
r1 = (2 * PP) - L_1;
r2 = PP + R;
r3 = H_1 + 2 * (PP - L_1);
r4 = r3 + R;
s1 = (2 * PP) - H_1;
s2 = PP - R;
s3 = L_1 - 2 * (H_1 - PP);
s4 = S3 - R;
}

else if(Pivot =="Fibonacci" )
{
PP = (H_1 + L_1 + C_1) / 3;
r3 = PP + 1.000 * R;
r2 = PP + 0.618 * R;
r1 = PP + 0.382 * R;
s1 = PP - 0.382 * R;
s2 = PP - 0.618 * R;
s3 = PP - 1.000 * R;
r4 = Null;
s4 = Null;
}
else if (Pivot == "WF")
{
PP = (H_1 + L_1 + O + O) / 4;
s1 = PP - (R * 0.38);
s2 = PP - (R * 0.62);
s3 = PP - (R * 1.272);
r1 = PP + (R * 0.38);
r2 = PP + (R * 0.62);
r3 = PP + (R * 1.272);
r4 = Null;
s4 = Null;
}

//Defining TF on charts
procedure AddT_fParam(defaultvalue)
{
global T_F;
T_F = ParamList("Time Frame", List = "iDay|Hourly|2_Hrs|3_Hrs|4_Hrs|EOD|Weekly|Mont hly" , defaultvalue);

if(T_F == "iDay") T_F = inDaily;
else if(T_F == "Hourly")    T_F = inHourly;
else if(T_F == "2_Hrs")    T_F = inHourly*2;
else if(T_F == "3_Hrs")    T_F = inHourly*3;
else if(T_F == "4_Hrs")    T_F = inHourly*4;
else if(T_F == "EOD") T_F = inDaily;
else if(T_F == "Weekly") T_F = inWeekly;
else if(T_F == "Montly") T_F = inMonthly;
}

//    Plot Pivot Levels in the charts

Plot (PP,"PP",colorLightOrange,styleDots,styleThick,1);
Plot (r1,"R1",colorRed,styleLine,styleThick,1);
Plot (r2,"R2",colorRed,styleLine,styleThick,1);
Plot (r3,"R3",colorRed,styleLine,styleThick,1);
Plot (s1,"S1",colorbrightGreen,styleLine,styleThick,1);
Plot (s2,"S2",colorbrightGreen,styleLine,styleThick,1);
Plot (s3,"S3",colorbrightGreen,styleLine,styleThick,1);
Plot (r4,"R4",colorDarkRed,styleLine,styleThick,1);
Plot (s4,"S4",colorbrightGreen,styleLine,styleThick,1);


//    Add Pivot levels on charts as text
Title = Title + EncodeColor(colorDarkTeal)+
"\n,Pivot T_F = "+T_F + " \n " +
EncodeColor(colorRed)+"R4 = "+ r4 +"\n"+
EncodeColor(colorRed)+"R3 = "+ r3 +"\n"+
EncodeColor(colorRed)+"R2 = "+ r2 + "\n"+
EncodeColor(colorRed)+"R1 = "+ r1 + "\n"+ "\n"+
EncodeColor(colorViolet)+"PP = "+ PP + "\n"+ "\n" +
EncodeColor(colorGreen)+"S1 = "+ s1 + "\n"+
EncodeColor(colorGreen)+"S2 = "+ s2 + "\n"+
EncodeColor(colorGreen)+"S3 = "+ s3 + "\n"+
EncodeColor(colorGreen)+"S4 = "+ s4 + " \n" ;

_SECTION_END();
 
Last edited:
Dear Ami experts,
please a small help..

how to " trim" "horizontal line " like "extended ray line" have a property of "left/right extended" option ...



Happy trading
 

yasu222

Active Member
PHP:
_SECTION_BEGIN("!MARKET_PROFILE");

GraphXSpace=Param("GraphXSpace",50,-10,100,1);
SetChartOptions(2, chartWrapTitle|chartHideQuoteMarker);//|CHARTSHOWDATES);
grid_day = Day()!=Ref(Day(),-1); 
Plot(grid_day,"",colorWhite,styleHistogram|styleDashed|styleNoLabel|styleOwnScale);
SetBarsRequired( 10000, 10000);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

marketstarttime = 091500;
IBendtime = 101500;
tradestarttime =  124500;
tradeendtime = 144500;
sqofftime = 144500;

SetPositionSize(1,spsShares);

IBup = Null;
IBdn= Null;

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

DayOpen = TimeFrameGetPrice("O",inDaily);
DayHigh = TimeFrameGetPrice("H",inDaily);
DayLow = TimeFrameGetPrice("L",inDaily);

ORBH = IIf(TimeNum() < IBendtime, Null ,ValueWhen(TimeNum() == IBendtime,HighestSince(newday and TimeNum() < IBendtime,H)));
ORBL = IIf(TimeNum() < IBendtime, Null, ValueWhen(TimeNum() == IBendtime,LowestSince(newday and TimeNum() < IBendtime,L)));

color = IIf(ORBH - DayOpen > DayOpen - ORBL, colorGreen,IIf(ORBH - DayOpen < DayOpen - ORBL, colorRed,colorGrey40)); 

IBup = TimeNum() > 101500 AND ORBH - DayOpen > DayOpen - ORBL;
IBdn = TimeNum() > 101500 AND ORBH - DayOpen < DayOpen - ORBL;

OTbuy = Ref(H,-4)>= Ref(H,-3) AND Ref(H,-3)>= Ref(H,-2) AND Ref(H,-2)>= Ref(H,-1);
OTsell = Ref(L,-4)<= Ref(L,-3) AND Ref(L,-3)<= Ref(L,-2) AND Ref(L,-2)<= Ref(L,-1);        

SetTradeDelays(0,0,0,0);        

Buy = IBup AND OTbuy AND TimeNum() >= tradestarttime AND TimeNum() <=tradeendtime;
BuyTarget = HighestSince(newday,H);
Sell = TimeNum() >= sqofftime OR Cross(H,Ref(BuyTarget,-1));

Short = IBdn AND OTsell  AND TimeNum() >= tradestarttime AND TimeNum() <=tradeendtime;
ShortTarget = LowestSince(newday,L);
Cover  = TimeNum() >= sqofftime OR Cross(Ref(ShortTarget,-1),L);

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

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

BuyPrice = Open;
SellPrice = Open;

SellPrice = open;
CoverPrice = open;

C1 = IIf(Buy,1,IIf(Sell,-1,0));
C2=0;
Plot(C2," ",colorLIGHTGrey,styleLine|styleDashed,width = 2);

Histogram_color = IIf(C1>0,ParamColor("Hist Up Color",colorBrightGreen),ParamColor("Hist Down Color",ColorRGB(255,128,128)));
Plot(C1,"Market Profile",Histogram_color,styleNoTitle|styleHistogram|styleThick);

_SECTION_END();
 

niftytaurus

Well-Known Member
Hi Friends
Can anybody please provide AFL for exploration for stocks which are opened COMPLETE GAP UP & GAP DOWN..i.e which can give me the list of selected stocks where TODAYS OPEN >YESTERDAYS HIGH- GAP UP
TODAYS OPEN<YESTERDAY LOW -GAP DOWN
IN EXPLORATION- gap up stocks shows green colour & gap down stocks show red color
Thanks
 
the formula is not correct and looking forward in the specifics in the targets ,
BuyPrice = Open;
SellPrice = Open;

SellPrice = open; //here we must correct to shortprice=open;
CoverPrice = open;
Sell = TimeNum() >= sqofftime OR Cross(H,Ref(BuyTarget,-1));//yeah AMERICA !!!! looking forward correct to:ref(Cross(H,Ref(BuyTarget,-1)),-1);
Cover = TimeNum() >= sqofftime OR Cross(Ref(ShortTarget,-1),L);//yeah AMERICA !!! looking forward, correct to ref(Cross(Ref(ShortTarget,-1),L),-1)

not very good in summary
 

Similar threads