Simple Coding Help - No Promise.

amitrandive

Well-Known Member
hello guys, my knowledge in coding/AFL is zero. please, convert my excel formula into an AFL. thanks in advance.

Trding Calculator.xlsx

This should work for plotting levels


Code:
 BT = ParamTime ("Open Breakout Time", "09:15");
afterbreakout0 = Cross(TimeNum(),BT);
afterbreakout1 = TimeNum()>=BT;
NewDay = Day()!= Ref(Day(), -1);
highestoftheday = HighestSince(newday,H,1);
Lowestoftheday =LowestSince(newday,L,1);
Closeoftheday=valuewhen(timenum()==093000,C);
ORBH = ValueWhen(afterbreakout0,highestoftheday,1);
ORBL = ValueWhen(afterbreakout0,lowestoftheday,1);
ORBC = Closeoftheday;
Range=2*ORBH-(ORBL+ORBC);
R1=ORBL+(Range/2);
R2=R1+(Range/3);
R3=R1+(Range/2);
R4=R1+Range;
S1=ORBH-(Range/1.75);
S2=S1-(Range/4);
S3=S1-(Range/2);
S4=S1-Range;
Plot(ORBH,"",colorGreen,styleDots);
Plot(R1,"",colorBlue,styleDots);
Plot(R2,"",colorBlue,styleDots);
Plot(R3,"",colorBlue,styleDots);
Plot(R4,"",colorBlue,styleDots);
Plot(S1,"",colorOrange,styleDots);
Plot(S2,"",colorOrange,styleDots);
Plot(S3,"",colorOrange,styleDots);
Plot(S4,"",colorOrange,styleDots);
Plot(ORBL,"",colorYellow,styleDots);
//Plot(ORBC, "", colorAqua, styleDots);
Plot ( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
 

PUCHU_2500

Well-Known Member
Dear this link shows file deleted.
i tried with fourshared
Thank you extremist for your showing kind help. Now I am giving you a snap shot of my simple formula, hope this will be enough to make an AFL. I am again appreciating for your extended helping hand......



disclaimer: this is not valid formula that can be used as trading profit. I will not be any way responsible for any loss or trading damage by using this formula.
 
Last edited:

extremist

Well-Known Member
Thank you extremist for your showing kind help. Now I am giving you a snap shot of my simple formula, hope this will be enough to make an AFL. I am again appreciating for your extended helping hand......



disclaimer: this is not valid formula that can be used as trading profit. I will not be any way responsible for any loss or trading damage by using this formula.
i hope u got ur code...
Plz refer the code posted by Amit Randive in post #3330.

To see the result u seek plz go to parameter of the code and change the timing to 9:30 as per ur need.
 

PUCHU_2500

Well-Known Member

This should work for plotting levels


Code:
 BT = ParamTime ("Open Breakout Time", "09:15");
afterbreakout0 = Cross(TimeNum(),BT);
afterbreakout1 = TimeNum()>=BT;
NewDay = Day()!= Ref(Day(), -1);
highestoftheday = HighestSince(newday,H,1);
Lowestoftheday =LowestSince(newday,L,1);
Closeoftheday=valuewhen(timenum()==093000,C);
ORBH = ValueWhen(afterbreakout0,highestoftheday,1);
ORBL = ValueWhen(afterbreakout0,lowestoftheday,1);
ORBC = Closeoftheday;
Range=2*ORBH-(ORBL+ORBC);
R1=ORBL+(Range/2);
R2=R1+(Range/3);
R3=R1+(Range/2);
R4=R1+Range;
S1=ORBH-(Range/1.75);
S2=S1-(Range/4);
S3=S1-(Range/2);
S4=S1-Range;
Plot(ORBH,"",colorGreen,styleDots);
Plot(R1,"",colorBlue,styleDots);
Plot(R2,"",colorBlue,styleDots);
Plot(R3,"",colorBlue,styleDots);
Plot(R4,"",colorBlue,styleDots);
Plot(S1,"",colorOrange,styleDots);
Plot(S2,"",colorOrange,styleDots);
Plot(S3,"",colorOrange,styleDots);
Plot(S4,"",colorOrange,styleDots);
Plot(ORBL,"",colorYellow,styleDots);
//Plot(ORBC, "", colorAqua, styleDots);
Plot ( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
Many thanks to you amit, gr8.....:clap::clap::clap:
 

Nehal_s143

Well-Known Member
Hi

I came across this image on web


print screen windows xp

This chart is made by using flycandle which is type of candle like Japanese candle etc, fly candles show same open high low close, but removes market noise, please dont get confused thinking this candles as heiken ashi.

seniors please help to set fly candles in amibroker
 

amitrandive

Well-Known Member

josh1

Well-Known Member
Hi friends,

I want to plot previous day High, Low and today Hi, Low.
However, Hi defined as Highest Open or Close of previous day whichever is higher.
and Lo defined as Lowest of open or close of previous day whichever is lower.
Same logic for current day

edit -- on 3 min time frame
For previous day H/L use this, afl courtesy from TJ.

Hi Steve,

I am using the same AFL. However, I do not want High/low of the candle/ wick to be treated as H/L.
See the lines marked in yellow colour. That is what I want.

For previous day H/L use this, afl courtesy from TJ.

Hi Steve,

I am using the same AFL. However, I do not want High/low of the candle/ wick to be treated as H/L.
See the lines marked in yellow colour. That is what I want.

Hi Josh1,

I do not have that afl, some of the coders here may help.
Hi Steve,

I did it. Made some changes in the AFL earlier given by L.V. Gandhi.
Code:
_SECTION_BEGIN("PreDHLCDayHLRN");
x=LastVisibleValue(DateNum());
Hor0 = Param("Hor0",900,0,1368,1);
Ver0 = Param("Ver0",30,0,768,1);

Cond=BarsSince(DateNum()<x);
y=Ref(DateNum(),-Cond);
Cond1=BarsSince(DateNum()<LastValue(y));
z=Cond1-Cond;
Hi0=IIf(HHV(C,Cond)> HHV(C,Cond),HHV(C,Cond),HHV(O,Cond));
Hi0bar=HHVBars(Hi0,Cond);

x20=BarCount-LastValue(Cond);
x21=BarCount-1;
y20=LastVisibleValue(Hi0);
y21=y20;
Line2 = LineArray( x20, y20, x21, y21, 1 );
Plot( Line2, "day high line", colorOrange,styleThick|styleNoTitle,0,0,5);

//Li0=LLV(L,Cond);
Li0=IIf(LLV(C,Cond)< LLV(O,Cond),LLV(C,Cond),LLV(O,Cond));
Li0bar=LLVBars(Li0,Cond);

x30=BarCount-LastValue(Cond);
x31=BarCount-1;
y30=LastVisibleValue(Li0);
y31=y30;
Line3 = LineArray( x30, y30, x31, y31, 1 );
Plot( Line3, "day low line", colorTurquoise,styleThick|styleNoTitle,0,0,5 );

//Hi=Ref(HHV(H,z),-Cond);
Hi=IIf(Ref(HHV(C,z),-Cond) > Ref(HHV(O,z),-Cond), Ref(HHV(C,z),-Cond), Ref(HHV(O,z),-Cond));

Hibar=Ref(HHVBars(Hi,z),-Cond)+Cond;
x0=BarCount-1-LastValue(Hibar);
x1=BarCount-1;
y0=LastValue(Hi);
y1=y0;
Line = LineArray( x0, y0, x1, y1, 1 );
Plot( Line, "high line", ParamColor("high line", colorGreen),styleThick|styleNoTitle );

pc=Ref(Close,-Cond);

x10=BarCount-1-LastValue(Cond);
x11=BarCount-1;
y10=LastValue(pc);
y11=y10;

Line1=LineArray( x10, y10, x11, y11, 1 );
Plot( Line1, "Close line", ParamColor("close line", colorWhite),styleThick|styleNoTitle );

//Lo=Ref(LLV(L,z),-Cond);
Lo=IIf(Ref(LLV(C,z),-Cond) < Ref(LLV(O,z),-Cond), Ref(LLV(C,z),-Cond), Ref(LLV(O,z),-Cond));
Lobar=Ref(LLVBars(Lo,z),-Cond)+Cond;

x00=BarCount-1-LastValue(Lobar);
x01=BarCount-1;
y00=LastValue(Lo);
y01=y00;

Line11=LineArray(x00,y00,x01,y01,1);
Plot(Line11,"Low Line",ParamColor("Low line", colorBlue),styleThick|styleNoTitle);

yh = int(Max(y0,y20)/50)*50;
yl = int(Min(y00,y30)/50)*50;

i=yl;
while( i>= yl AND i<=yh )
{i1 = i;
Linex=LineArray(x0,i,x1,i1);
Plot(Linex,"",colorGold,styleThick|styleNoTitle);
i=i+50;
}
_SECTION_END();

_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();
 
Can this be another version of Fly candles ???

Code:
_SECTION_BEGIN("HA");
a=20;
GraphXSpace=5;
p=30;
p = Param("p",30,2,100,1);
Om=DEMA(O,p);
hm=DEMA(H,p);
lm=DEMA(L,p);
Cm=DEMA(C,p);
HACLOSE=(Om+Hm+Lm+Cm)/4;
HaOpen = AMA( Ref( HaClose, -1), 1);
HaHigh = Max( Hm, Max( HaClose, HaOpen ) );
HaLow = Min( Lm, Min( HaClose, HaOpen ) );
slope = Param("slope",2,2,100,1);
Color20= IIf(LinRegSlope(MA(HaClose,a),slope)<0,colorRed,colorBlue);
Color=IIf(Haclose>MA(HaClose,a),colorBlue, colorRed);
PlotOHLC( HaOpen, HaOpen, HaClose, HaClose, "" + Name(), color, styleCandle);

Buy=Cover= Cross(Haclose,MA(HaClose,a));
Sell=Short= Cross(MA(HaClose,a),Haclose);

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


_SECTION_BEGIN("KPL Swing with N&M Swing");
SetBarsRequired(200,0);

GraphXSpace = 5;
SetChartOptions(0,chartShowArrows|chartShowDates);
k = Optimize("K",Param("K",3,0.25,5,0.25),0.25,5,0.25) ;
Per= Optimize("atr",Param("atr",10,3,20,1),3,20,1);
HACLOSE=(O+H+L+C)/4;
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
j=Haclose;

// set background gradient colours
SetChartBkGradientFill( ParamColor("BgTop", colorDarkGrey),ParamColor("BgBottom", colorLightGrey ),ParamColor("titleblock",colorWhite));
GraphXSpace = 5;

//================================================== ================================================== ===================
//=========================Indicator================ ================================================== ============================
f=ATR(15);

rfsctor = WMA(H-L, Per);

revers = k * rfsctor;

Trend = 1;
NW[0] = 0;
NW[BarCount-1] = Null;


for(i = 1; i < BarCount-1; i++)
{
if(Trend[i-1] == 1)
{
if(j[i] < NW[i-1])
{
Trend[i] = -1;
NW[i] = j[i] + Revers[i];
}
else
{
Trend[i] = 1;
if((j[i] - Revers[i]) > NW[i-1])
{
NW[i] = j[i] - Revers[i];
}
else
{
NW[i] = NW[i-1];
}
}
}
if(Trend[i-1] == -1)
{
if(j[i] > NW[i-1])
{
Trend[i] = 1;
NW[i] = j[i] - Revers[i];
}
else
{
Trend[i] = -1;
if((j[i] + Revers[i]) < NW[i-1])
{
NW[i] = j[i] + Revers[i];
}
else
{
NW[i] = NW[i-1];
}
}
}
}

//===============system================

//Plot(NW, "", IIf(Trend == 1, 27, 4), 4);
//Buy=NW<HACLOSE;
//Sell=NW>HACLOSE;
//SellPrice=ValueWhen(Sell,C,1);
//BuyPrice=ValueWhen(Buy,C,1);
//Buy=ExRem(Buy,Sell);
//Sell=ExRem(Sell,Buy );

//Short=Sell;
//Cover=Buy;


//NMAB= NW<HACLOSE;
//NMAS= NW>HACLOSE;
AlertIf( Buy, "SOUND C:\\Windows\\Media\\buy.wav", "Audio alert", 1,1+1 );
AlertIf( Sell, "SOUND C:\\Windows\\Media\\sell.wav", "Audio alert", 2,1+1 );

//NMA_status= WriteIf(NMAB, "BUY MODE", WriteIf(NMAS, "SELL MODE", "NEUTRAL"));
//NMAS_Col=IIf(NMAB, colorGreen, IIf(NMAS, colorRed, colorLightGrey));
Filter=1;
//AddColumn( NW[BarCount-1], "SAR", 1.2 );
//AddColumn( HACLOSE, "HA Close", 1.2 );
//AddColumn( C, "Close", 1.2 );
//AddTextColumn(NMA_status, "MODE", 1, colorWhite, NMAS_Col);
//AddColumn( DateTime(), "Date / Time", formatDateTime );
_SECTION_END();

_SECTION_BEGIN("Title");
if( Status("action") == actionIndicator )
(
Title = EncodeColor(colorBlack)+ " - " + Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorBlack) +
" - " + Date() +" - "+"\n" +EncodeColor(colorBlack) +"Op-"+O+" "+"Hi-"+H+" "+"Lo-"+L+" "+
"Cl-"+C+" "+ "Vol= "+ WriteVal(V)+"\n"+
EncodeColor(colorLime)+
WriteIf (Buy , " GO LONG / Reverse Signal at "+C+" ","")+
WriteIf (Sell , " EXIT LONG / Reverse Signal at "+C+" ","")+"\n"+EncodeColor(colorWhite)+
WriteIf(Sell , "Total Profit/Loss for the Last Trade Rs."+(C-BuyPrice)+"","")+
WriteIf(Buy , "Total Profit/Loss for the Last trade Rs."+(SellPrice-C)+"",""));
//WriteIf(Long AND NOT Buy, "Trade : Long - Entry price Rs."+(BuyPrice),"")+
//WriteIf(shrt AND NOT Sell, "Trade : Short - Entry price Rs."+(SellPrice),"")+"\n"+
//WriteIf(Long AND NOT Buy, "Current Profit/Loss Rs."+(C-BuyPrice)+"","")+
//WriteIf(shrt AND NOT Sell, "Current Profit/Loss Rs."+(SellPrice-C)+"",""));
//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);

GraphXSpace=5;


for(i=BarCount-1;i>1;i--)
{
if(Buy[i] == 1)
{
entry = C[i];
sig = "BUY";
sl = Ref(NW,-1);
tar1 = entry + (entry * .0050);
tar2 = entry + (entry * .0092);
tar3 = entry + (entry * .0179);

bars = i;
i = 0;
}
if(Sell[i] == 1)
{
sig = "SELL";
entry = C[i];
sl = Ref(NW,-1);
tar1 = entry - (entry * .0060);
tar2 = entry - (entry * .0120);
tar3 = entry - (entry * .0220);


bars = i;
i = 0;
}
}
Offset = 20;
//Clr = IIf(sig == "BUY", colorLime, colorRed);
//ssl = IIf(bars == BarCount-1, NW[BarCount-1], Ref(NW, -1));
//sl = ssl[BarCount-1];

//Plot(LineArray(bars-Offset, tar1, BarCount, tar1,1), "", Clr, styleLine|styleDots, Null, Null, Offset);
//Plot(LineArray(bars-Offset, tar2, BarCount, tar2,1), "", Clr, styleLine|styleDots, Null, Null, Offset);
//Plot(LineArray(bars-Offset, tar3, BarCount, tar3,1), "", Clr, styleLine|styleDots, Null, Null, Offset);



messageboard = ParamToggle("Message Board","Show|Hide",1);
if (messageboard == 1 )
{
GfxSelectFont( "Tahoma", 13, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );

if ( sig =="BUY")
{
GfxSelectSolidBrush( colorDarkGreen ); // this is the box background color
}
else
{
GfxSelectSolidBrush( colorDarkRed ); // this is the box background color
}
pxHeight = Status( "pxchartheight" ) ;
xx = Status( "pxchartwidth");
Left = 1100;
width = 310;
x = 5;
x2 = 290;

y = pxHeight;

GfxSelectPen( colorGreen, 1); // broader color
GfxRoundRect( x, y - 163, x2, y , 7, 7 ) ;
GfxTextOut( (" Amibroker trading System "),33,y-165);
GfxTextOut( (" "),27,y-160);
GfxTextOut( ("" + WriteIf(sig =="Long",sig + " at ",sig + " @") + " : " + entry), 13, y-120);
//GfxTextOut( ("Trailing SL : " + sl + " (" + WriteVal(IIf(sig == "SELL",entry-sl,sl-entry), 2.2) + ")"), 13, y-100);
//GfxTextOut( ("TGT:1 : " + tar1), 13, y -80);
//GfxTextOut( ("TGT:2 : " + tar2), 13,y-60);
//GfxTextOut( ("TGT:3 : " + tar3), 13,y-40);
GfxTextOut( ("Current Profit : " + WriteVal(IIf(sig == "BUY",(C-entry),(entry-C)),2.2)+" Points"), 13, y-100);;

}
_SECTION_END();




_SECTION_BEGIN("Background text");
C11=ParamColor("up panel",colorBlack );
C12=ParamColor("dn panel",colorBlack );
C13=Param("fonts",20,10,30,1 );
C14=Param("left-right",2.1,1.0,5.0,0.1 );
C15=Param("up-down",8,1,30,1 );
Miny = Status("axisminy");
Maxy = Status("axismaxy");
lvb = Status("lastvisiblebar");
fvb = Status("firstvisiblebar");
pxwidth = Status("pxwidth");
pxheight = Status("pxheight");
GfxSetBkMode( 0 );
GfxSelectFont("Tahoma", 12, 500, False, False, 0);
GfxSetTextColor(colorCustom12);
GfxSetTextAlign( 6 );
GfxSelectFont("Tahoma", 15, 600, False, False, 0);
GfxSetTextColor(colorWhite);
GfxSetTextAlign( 6 );
GfxTextOut( "LTP "+WriteVal(C,1.2), Status("pxwidth")/C14, Status("pxheight")/C15);
GfxSelectFont("Tahoma", 12, 400, False, False, 0);
GfxSetTextColor(colorBrightGreen);
GfxSelectFont("Tahoma", 12, 400, False, False, 0);
GfxSetTextColor(colorRed);
GfxSelectFont("Tahoma", 12, 400, False, False, 0);
GfxSetTextColor(colorYellow);
GfxSelectFont("Tahoma", 12, 400, False, False, 0);
GfxSetTextColor(colorGreen);

pricechange=(C-Ref(C,-1))*100/Ref(C,-1);
changeponit=C-Ref(C,-1);
Vlp=Param("Volume lookback period",15,10,300,10);
Vrg=MA(V,Vlp);
St = StDev(Vrg,Vlp);
Vp3 = Vrg + 3*st;
Vp2 = Vrg + 2*st;;
Vp1 = Vrg + 1*st;;
Vn1 = Vrg -1*st;
Vn2 = Vrg -2*st;

x=Param("xposn",1,0,1000,1);
y=Param("yposn",1,0,1000,1);

/*GfxGradientRect( 1, 1, 1400, 40, colorGrey50, colorDarkGrey);
GfxSetBkMode(0);
GfxSelectFont( "Tahoma", 16, 800, False );
GfxSetTextColor( colorGold );
GfxTextOut( Name(), x+100, y+10 );
GfxSelectFont( "Century Gothic", 15, 100, False );
GfxSetTextColor( colorWhite );
GfxTextOut( Date(), x+600, y+10 );
GfxSelectFont( "Comic Sans MS", 15, 500, False );
GfxSetTextColor( colorYellow );
GfxTextOut( Interval(2), x+275, y+10 );
GfxSelectFont( "Georgia", 18, 800, False );
GfxSetTextColor( colorWhite );
GfxTextOut( "Amibroker Trading System ", x+1000, y+10 );
*/
//------------------------------------------------------------ H, L, O, C----------------------
GfxGradientRect( 1, 40, 1400, 55, colorGrey50, colorDarkGrey );
GfxSetBkMode(0);
GfxSelectFont( "Areal", 9, 200, False );
GfxSetTextColor( colorWhite );
GfxTextOut( "Open:"+WriteVal(O,1.2), x+100, y+40 );
GfxSelectFont( "Areal", 9, 200, False );
GfxSetTextColor( colorWhite );
GfxTextOut( "High:"+WriteVal(H,1.2), x+200, y+40 );
GfxSelectFont( "Areal", 9, 200, False );
GfxSetTextColor( colorWhite );
GfxTextOut( "Low:"+WriteVal(L,1.2), x+300, y+40 );
GfxSelectFont( "Areal", 9, 200, False );
GfxSetTextColor( colorWhite );
GfxTextOut( "Close:"+WriteVal(C,1.2), x+400, y+40 );
GfxSelectFont( "Script MT Bold", 12, 100, False );
GfxSetTextColor( colorWhite );
GfxTextOut( "By Amibroker Trading System ", x+1000, y+39 );
//-----------------------------------------------------------Valume-------------------------------
GfxSelectFont( "Tahoma", 9, 200, False );
GfxSetTextColor( colorWhite );
GfxTextOut( "Volume="+WriteVal(V,1.2), x+500, y+40 );
GfxSelectFont( "Tahoma", 9, 200, False );
GfxSetTextColor( colorLime );
GfxTextOut( WriteIf(V>Vp2,"Very High",""), x+600, y+40 );
GfxSelectFont( "Tahoma", 9, 200, False );
GfxSetTextColor( colorLime );
GfxTextOut( WriteIf(V>Vp1," High",""), x+600, y+40 );
GfxSelectFont( "Tahoma", 9, 200, False );
GfxSetTextColor( colorLime );
GfxTextOut( WriteIf(V>Vrg,"Above Average",""), x+600, y+40 );
GfxSelectFont( "Tahoma", 9, 200, False );
GfxSetTextColor( colorRed );
GfxTextOut( WriteIf(V<Vrg AND V>Vn1,"Less than Average",""), x+600, y+40 );
GfxSelectFont( "Tahoma", 9, 200, False );
GfxSetTextColor( colorRed );
GfxTextOut( WriteIf(V<Vn1,"Low",""), x+600, y+40 );

Title = " ";

//Settings for exploration
Value1 = V;
Value2 = V*(H-L);
Value3 = V/(H-L);

Climax = (Value2 == HHV(Value2,10));

VolumeBlast = V > Ref(V, -1) AND Climax AND V > 2*WMA( V, 8 );
Filter=Buy OR Short;
AddColumn( IIf( Buy, 66 , 83 ), "Signal", formatChar, colorDefault, IIf( Buy , colorGreen, colorRed ) );
AddColumn(Close,"Entry Price",1.4, colorDefault, IIf( Buy , colorGreen, colorRed ));
//AddColumn(dtsl,"Stop Loss",1.4, colorDefault, IIf( Buy , colorGreen, colorRed ));
AddColumn(tar1,"Target 1",1.4, colorDefault, IIf( Buy , colorGreen, colorRed ));
AddColumn(tar2,"Target 2",1.4, colorDefault, IIf( Buy , colorGreen, colorRed ));
AddColumn(tar3,"Target 3",1.4, colorDefault, IIf( Buy , colorGreen, colorRed ));
 

Nehal_s143

Well-Known Member
Can this be another version of Fly candles ???

Code:
_SECTION_BEGIN("HA");
a=20;
GraphXSpace=5;
p=30;
p = Param("p",30,2,100,1);
Om=DEMA(O,p);
hm=DEMA(H,p);
lm=DEMA(L,p);
Cm=DEMA(C,p);
HACLOSE=(Om+Hm+Lm+Cm)/4;
HaOpen = AMA( Ref( HaClose, -1), 1);
HaHigh = Max( Hm, Max( HaClose, HaOpen ) );
HaLow = Min( Lm, Min( HaClose, HaOpen ) );
slope = Param("slope",2,2,100,1);
Color20= IIf(LinRegSlope(MA(HaClose,a),slope)<0,colorRed,colorBlue);
Color=IIf(Haclose>MA(HaClose,a),colorBlue, colorRed);
PlotOHLC( HaOpen, HaOpen, HaClose, HaClose, "" + Name(), color, styleCandle);

Buy=Cover= Cross(Haclose,MA(HaClose,a));
Sell=Short= Cross(MA(HaClose,a),Haclose);

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


_SECTION_BEGIN("KPL Swing with N&M Swing");
SetBarsRequired(200,0);

GraphXSpace = 5;
SetChartOptions(0,chartShowArrows|chartShowDates);
k = Optimize("K",Param("K",3,0.25,5,0.25),0.25,5,0.25) ;
Per= Optimize("atr",Param("atr",10,3,20,1),3,20,1);
HACLOSE=(O+H+L+C)/4;
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
j=Haclose;

// set background gradient colours
SetChartBkGradientFill( ParamColor("BgTop", colorDarkGrey),ParamColor("BgBottom", colorLightGrey ),ParamColor("titleblock",colorWhite));
GraphXSpace = 5;

//================================================== ================================================== ===================
//=========================Indicator================ ================================================== ============================
f=ATR(15);

rfsctor = WMA(H-L, Per);

revers = k * rfsctor;

Trend = 1;
NW[0] = 0;
NW[BarCount-1] = Null;


for(i = 1; i < BarCount-1; i++)
{
if(Trend[i-1] == 1)
{
if(j[i] < NW[i-1])
{
Trend[i] = -1;
NW[i] = j[i] + Revers[i];
}
else
{
Trend[i] = 1;
if((j[i] - Revers[i]) > NW[i-1])
{
NW[i] = j[i] - Revers[i];
}
else
{
NW[i] = NW[i-1];
}
}
}
if(Trend[i-1] == -1)
{
if(j[i] > NW[i-1])
{
Trend[i] = 1;
NW[i] = j[i] - Revers[i];
}
else
{
Trend[i] = -1;
if((j[i] + Revers[i]) < NW[i-1])
{
NW[i] = j[i] + Revers[i];
}
else
{
NW[i] = NW[i-1];
}
}
}
}

//===============system================

//Plot(NW, "", IIf(Trend == 1, 27, 4), 4);
//Buy=NW<HACLOSE;
//Sell=NW>HACLOSE;
//SellPrice=ValueWhen(Sell,C,1);
//BuyPrice=ValueWhen(Buy,C,1);
//Buy=ExRem(Buy,Sell);
//Sell=ExRem(Sell,Buy );

//Short=Sell;
//Cover=Buy;


//NMAB= NW<HACLOSE;
//NMAS= NW>HACLOSE;
AlertIf( Buy, "SOUND C:\\Windows\\Media\\buy.wav", "Audio alert", 1,1+1 );
AlertIf( Sell, "SOUND C:\\Windows\\Media\\sell.wav", "Audio alert", 2,1+1 );

//NMA_status= WriteIf(NMAB, "BUY MODE", WriteIf(NMAS, "SELL MODE", "NEUTRAL"));
//NMAS_Col=IIf(NMAB, colorGreen, IIf(NMAS, colorRed, colorLightGrey));
Filter=1;
//AddColumn( NW[BarCount-1], "SAR", 1.2 );
//AddColumn( HACLOSE, "HA Close", 1.2 );
//AddColumn( C, "Close", 1.2 );
//AddTextColumn(NMA_status, "MODE", 1, colorWhite, NMAS_Col);
//AddColumn( DateTime(), "Date / Time", formatDateTime );
_SECTION_END();

_SECTION_BEGIN("Title");
if( Status("action") == actionIndicator )
(
Title = EncodeColor(colorBlack)+ " - " + Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorBlack) +
" - " + Date() +" - "+"\n" +EncodeColor(colorBlack) +"Op-"+O+" "+"Hi-"+H+" "+"Lo-"+L+" "+
"Cl-"+C+" "+ "Vol= "+ WriteVal(V)+"\n"+
EncodeColor(colorLime)+
WriteIf (Buy , " GO LONG / Reverse Signal at "+C+" ","")+
WriteIf (Sell , " EXIT LONG / Reverse Signal at "+C+" ","")+"\n"+EncodeColor(colorWhite)+
WriteIf(Sell , "Total Profit/Loss for the Last Trade Rs."+(C-BuyPrice)+"","")+
WriteIf(Buy , "Total Profit/Loss for the Last trade Rs."+(SellPrice-C)+"",""));
//WriteIf(Long AND NOT Buy, "Trade : Long - Entry price Rs."+(BuyPrice),"")+
//WriteIf(shrt AND NOT Sell, "Trade : Short - Entry price Rs."+(SellPrice),"")+"\n"+
//WriteIf(Long AND NOT Buy, "Current Profit/Loss Rs."+(C-BuyPrice)+"","")+
//WriteIf(shrt AND NOT Sell, "Current Profit/Loss Rs."+(SellPrice-C)+"",""));
//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);

GraphXSpace=5;


for(i=BarCount-1;i>1;i--)
{
if(Buy[i] == 1)
{
entry = C[i];
sig = "BUY";
sl = Ref(NW,-1);
tar1 = entry + (entry * .0050);
tar2 = entry + (entry * .0092);
tar3 = entry + (entry * .0179);

bars = i;
i = 0;
}
if(Sell[i] == 1)
{
sig = "SELL";
entry = C[i];
sl = Ref(NW,-1);
tar1 = entry - (entry * .0060);
tar2 = entry - (entry * .0120);
tar3 = entry - (entry * .0220);


bars = i;
i = 0;
}
}
Offset = 20;
//Clr = IIf(sig == "BUY", colorLime, colorRed);
//ssl = IIf(bars == BarCount-1, NW[BarCount-1], Ref(NW, -1));
//sl = ssl[BarCount-1];

//Plot(LineArray(bars-Offset, tar1, BarCount, tar1,1), "", Clr, styleLine|styleDots, Null, Null, Offset);
//Plot(LineArray(bars-Offset, tar2, BarCount, tar2,1), "", Clr, styleLine|styleDots, Null, Null, Offset);
//Plot(LineArray(bars-Offset, tar3, BarCount, tar3,1), "", Clr, styleLine|styleDots, Null, Null, Offset);



messageboard = ParamToggle("Message Board","Show|Hide",1);
if (messageboard == 1 )
{
GfxSelectFont( "Tahoma", 13, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );

if ( sig =="BUY")
{
GfxSelectSolidBrush( colorDarkGreen ); // this is the box background color
}
else
{
GfxSelectSolidBrush( colorDarkRed ); // this is the box background color
}
pxHeight = Status( "pxchartheight" ) ;
xx = Status( "pxchartwidth");
Left = 1100;
width = 310;
x = 5;
x2 = 290;

y = pxHeight;

GfxSelectPen( colorGreen, 1); // broader color
GfxRoundRect( x, y - 163, x2, y , 7, 7 ) ;
GfxTextOut( (" Amibroker trading System "),33,y-165);
GfxTextOut( (" "),27,y-160);
GfxTextOut( ("" + WriteIf(sig =="Long",sig + " at ",sig + " @") + " : " + entry), 13, y-120);
//GfxTextOut( ("Trailing SL : " + sl + " (" + WriteVal(IIf(sig == "SELL",entry-sl,sl-entry), 2.2) + ")"), 13, y-100);
//GfxTextOut( ("TGT:1 : " + tar1), 13, y -80);
//GfxTextOut( ("TGT:2 : " + tar2), 13,y-60);
//GfxTextOut( ("TGT:3 : " + tar3), 13,y-40);
GfxTextOut( ("Current Profit : " + WriteVal(IIf(sig == "BUY",(C-entry),(entry-C)),2.2)+" Points"), 13, y-100);;

}
_SECTION_END();




_SECTION_BEGIN("Background text");
C11=ParamColor("up panel",colorBlack );
C12=ParamColor("dn panel",colorBlack );
C13=Param("fonts",20,10,30,1 );
C14=Param("left-right",2.1,1.0,5.0,0.1 );
C15=Param("up-down",8,1,30,1 );
Miny = Status("axisminy");
Maxy = Status("axismaxy");
lvb = Status("lastvisiblebar");
fvb = Status("firstvisiblebar");
pxwidth = Status("pxwidth");
pxheight = Status("pxheight");
GfxSetBkMode( 0 );
GfxSelectFont("Tahoma", 12, 500, False, False, 0);
GfxSetTextColor(colorCustom12);
GfxSetTextAlign( 6 );
GfxSelectFont("Tahoma", 15, 600, False, False, 0);
GfxSetTextColor(colorWhite);
GfxSetTextAlign( 6 );
GfxTextOut( "LTP "+WriteVal(C,1.2), Status("pxwidth")/C14, Status("pxheight")/C15);
GfxSelectFont("Tahoma", 12, 400, False, False, 0);
GfxSetTextColor(colorBrightGreen);
GfxSelectFont("Tahoma", 12, 400, False, False, 0);
GfxSetTextColor(colorRed);
GfxSelectFont("Tahoma", 12, 400, False, False, 0);
GfxSetTextColor(colorYellow);
GfxSelectFont("Tahoma", 12, 400, False, False, 0);
GfxSetTextColor(colorGreen);

pricechange=(C-Ref(C,-1))*100/Ref(C,-1);
changeponit=C-Ref(C,-1);
Vlp=Param("Volume lookback period",15,10,300,10);
Vrg=MA(V,Vlp);
St = StDev(Vrg,Vlp);
Vp3 = Vrg + 3*st;
Vp2 = Vrg + 2*st;;
Vp1 = Vrg + 1*st;;
Vn1 = Vrg -1*st;
Vn2 = Vrg -2*st;

x=Param("xposn",1,0,1000,1);
y=Param("yposn",1,0,1000,1);

/*GfxGradientRect( 1, 1, 1400, 40, colorGrey50, colorDarkGrey);
GfxSetBkMode(0);
GfxSelectFont( "Tahoma", 16, 800, False );
GfxSetTextColor( colorGold );
GfxTextOut( Name(), x+100, y+10 );
GfxSelectFont( "Century Gothic", 15, 100, False );
GfxSetTextColor( colorWhite );
GfxTextOut( Date(), x+600, y+10 );
GfxSelectFont( "Comic Sans MS", 15, 500, False );
GfxSetTextColor( colorYellow );
GfxTextOut( Interval(2), x+275, y+10 );
GfxSelectFont( "Georgia", 18, 800, False );
GfxSetTextColor( colorWhite );
GfxTextOut( "Amibroker Trading System ", x+1000, y+10 );
*/
//------------------------------------------------------------ H, L, O, C----------------------
GfxGradientRect( 1, 40, 1400, 55, colorGrey50, colorDarkGrey );
GfxSetBkMode(0);
GfxSelectFont( "Areal", 9, 200, False );
GfxSetTextColor( colorWhite );
GfxTextOut( "Open:"+WriteVal(O,1.2), x+100, y+40 );
GfxSelectFont( "Areal", 9, 200, False );
GfxSetTextColor( colorWhite );
GfxTextOut( "High:"+WriteVal(H,1.2), x+200, y+40 );
GfxSelectFont( "Areal", 9, 200, False );
GfxSetTextColor( colorWhite );
GfxTextOut( "Low:"+WriteVal(L,1.2), x+300, y+40 );
GfxSelectFont( "Areal", 9, 200, False );
GfxSetTextColor( colorWhite );
GfxTextOut( "Close:"+WriteVal(C,1.2), x+400, y+40 );
GfxSelectFont( "Script MT Bold", 12, 100, False );
GfxSetTextColor( colorWhite );
GfxTextOut( "By Amibroker Trading System ", x+1000, y+39 );
//-----------------------------------------------------------Valume-------------------------------
GfxSelectFont( "Tahoma", 9, 200, False );
GfxSetTextColor( colorWhite );
GfxTextOut( "Volume="+WriteVal(V,1.2), x+500, y+40 );
GfxSelectFont( "Tahoma", 9, 200, False );
GfxSetTextColor( colorLime );
GfxTextOut( WriteIf(V>Vp2,"Very High",""), x+600, y+40 );
GfxSelectFont( "Tahoma", 9, 200, False );
GfxSetTextColor( colorLime );
GfxTextOut( WriteIf(V>Vp1," High",""), x+600, y+40 );
GfxSelectFont( "Tahoma", 9, 200, False );
GfxSetTextColor( colorLime );
GfxTextOut( WriteIf(V>Vrg,"Above Average",""), x+600, y+40 );
GfxSelectFont( "Tahoma", 9, 200, False );
GfxSetTextColor( colorRed );
GfxTextOut( WriteIf(V<Vrg AND V>Vn1,"Less than Average",""), x+600, y+40 );
GfxSelectFont( "Tahoma", 9, 200, False );
GfxSetTextColor( colorRed );
GfxTextOut( WriteIf(V<Vn1,"Low",""), x+600, y+40 );

Title = " ";

//Settings for exploration
Value1 = V;
Value2 = V*(H-L);
Value3 = V/(H-L);

Climax = (Value2 == HHV(Value2,10));

VolumeBlast = V > Ref(V, -1) AND Climax AND V > 2*WMA( V, 8 );
Filter=Buy OR Short;
AddColumn( IIf( Buy, 66 , 83 ), "Signal", formatChar, colorDefault, IIf( Buy , colorGreen, colorRed ) );
AddColumn(Close,"Entry Price",1.4, colorDefault, IIf( Buy , colorGreen, colorRed ));
//AddColumn(dtsl,"Stop Loss",1.4, colorDefault, IIf( Buy , colorGreen, colorRed ));
AddColumn(tar1,"Target 1",1.4, colorDefault, IIf( Buy , colorGreen, colorRed ));
AddColumn(tar2,"Target 2",1.4, colorDefault, IIf( Buy , colorGreen, colorRed ));
AddColumn(tar3,"Target 3",1.4, colorDefault, IIf( Buy , colorGreen, colorRed ));
Thank you for afl this one looks very much similar to the image posted :thumb:
 

Similar threads