Simple Coding Help - No Promise.

kumudhan

Well-Known Member


afl....

_SECTION_BEGIN("BW Fractal");

UpFractal= ValueWhen(
(Ref(H,-2) > Ref(H, -4)) AND
(Ref(H,-2) > Ref(H, -3)) AND
(Ref(H,-2) > Ref(H, -1)) AND
(Ref(H,-2) > H), Ref(H,-2));

DownFractal= ValueWhen(
(Ref(L,-2) <= Ref(L, -4)) AND
(Ref(L,-2) <= Ref(L, -3)) AND
(Ref(L,-2) <= Ref(L, -1)) AND
(Ref(L,-2) <= L), Ref(L,-2));

//== Added Crash crashandburn59 [at] hotmail.com solution
Plot(Ref(UpFractal,2), "Up Fractal", colorGreen,styleDots,styleThick);
Plot(Ref(DownFractal,2), "Down Fractal",colorRed, styleDots,styleThick);
Plot(C,"",colorWhite,styleCandle);

//Plot(Max(HHV(H,3),Ref(UpFractal,2)), "Up Fractal", ParamColor("Up Fractal Color",colorRed), ParamStyle("Up Fractal Style", styleDashed));
//Plot(Max(HHV(H,3),Ref(UpFractal,2)), "Down Fractal",ParamColor("Down FractalColor",colorBlue), ParamStyle("Down Fractal Style", styleDashed));
_SECTION_END();

_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
_SECTION_END();

_SECTION_BEGIN("MA");
Len = IIf(Interval() > 300, 30, 60);
Disp = WriteIf(Interval() > 300, "MA30", "MA60");
Av = MA(C, Len);
ColorShow = IIf(Av > Ref(Av,-1) AND C > Av, colorGreen, IIf(Av < Ref(Av,-1) AND C < Av, colorRed, colorBlue));
Plot(Av, Disp, ColorShow ,styleLine+styleDots,styleThick,styleDots);
_SECTION_END();

ToolTip = "High = " + H + "\nOpen = " + O + "\nRange = " + (High-Low) +"\nTRUERange = " + (C-O) +"\nMID ="+((High+Low)/2)+ "\nClose = " + C + "\nLow = " + L;
_SECTION_BEGIN("Title");
Title = "";
HoD = TimeFrameGetPrice("H",inDaily);
LoD = TimeFrameGetPrice("L",inDaily);
Rng = HoD - LoD;
Mid = LoD + Rng/2;
//Draw the Panel Box
GfxSelectPen( colorBlack,1 );
GfxMoveTo(2,2);
GfxLineTo(2,30);
GfxLineTo(1044,30);
GfxLineTo(1044,2);
GfxLineTo(2,2);
GfxMoveTo(140,2);
GfxLineTo(140,30);
GfxMoveTo(430,2);
GfxLineTo(430,30);
GfxMoveTo(530,2);
GfxLineTo(530,30);
GfxSelectFont("Comic Sans MS Bold", 9, 800);
GfxSetTextColor(colorBlack);
GfxDrawText(Name(), 10, 3, 77, 20,0);
GfxDrawText(NumToStr(Interval()/60,2.0) + " Min", 82, 3, 140, 20,0);
GfxSelectFont("Comic Sans MS Bold", 7, 800);
GfxDrawText(Date(), 10, 18, 140, 30,0);
GfxSelectFont("Comic Sans MS Bold", 10, 800);
GfxSetTextColor(colorBlue);
GfxDrawText(" HoD:" + NumToStr(HoD,3.0), 148, 7, 240, 30,0);
GfxSetTextColor(colorRed);
GfxDrawText(" LoD:" + NumToStr(LoD,3.0), 242, 7, 340, 30,0);
GfxSetTextColor(colorBlack);
GfxDrawText(" Mid:" + NumToStr(Mid,3.0), 342, 7, 500, 30,0);
GfxDrawText(" Range:" + NumToStr(Rng,3.0), 437, 7, 620, 30,0);
GfxDrawText("Open: " + NumToStr(O,3.0), 537, 7, 740, 30,0);
GfxSetTextColor(colorBlue);
GfxDrawText("Hi: " + NumToStr(H,3.0), 647, 7, 740, 30,0);
GfxSetTextColor(colorRed);
GfxDrawText("Lo: " + NumToStr(L,3.0), 740, 7, 860, 30,0);
GfxSetTextColor(colorBlack);
GfxDrawText("Close: " + NumToStr(C,3.0), 840, 7, 980, 30,0);
GfxSetTextColor(colorBlack);
GfxDrawText("Volume: " + NumToStr(V,3.0), 940, 7, 1080, 30,0);
_SECTION_END();
GfxSetOverlayMode(1);
GfxSelectFont("Comic Sans MS Bold", Status("pxheight")/25 );
GfxSetTextAlign( 6 );// center alignment
GfxSetTextColor( ColorRGB( 160, 160, 160 ) );
GfxSetTextColor( ColorHSB( 160, 0, 151 ) );
GfxSetBkMode(0); // transparent
GfxTextOut( "EARLY EXIT AND SHORTING", Status("pxwidth")/2, Status("pxheight")/3 ); // it will be visible now



and another afl is here...

_SECTION_BEGIN("fractals");
acc = Param("Acceleration", 0.019, 0, 1, 0.001 );
accm = Param("Max. acceleration", 0.019, 0, 1, 0.001 );
Plot( SAR( acc, accm ), _DEFAULT_NAME(), ParamColor( "Color", colorYellow ),
ParamStyle("Style", styleLine | styleLine, maskDefault | styleLine | styleLine )
);
Buy = Cross(Open, SAR(acc,accm));
Sell = Cross(SAR(acc,accm), Open );
Short=Sell;
Cover=Buy;
Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );

AlertIf( Buy,"SOUND C:\\Windows\\Media\\Chord.wav", "Audio alert", 2 );
AlertIf( Sell,"SOUND C:\\Windows\\Media\\Ding.wav", "Audio alert", 2 );

PlotShapes(IIf(Buy,shapeUpArrow,shapeNone), colorBrightGreen, 0, Low, Offset=-15);
PlotShapes(IIf(Sell, shapeDownArrow,shapeNone), colorPink, 0, High,
Offset=-15);
dist = 2*ATR(2);
for( i = 0; i < BarCount; i++ )
{
if( Buy ) PlotText( "" + C[ i ], i, H[ i ]+dist, colorWhite );
if( Sell ) PlotText( "" + C[ i ], i, L[ i ]-dist, colorAqua );
}
t1= Flip(Buy,Sell);
t2= Flip(Sell,Buy);
Filter = Buy OR Sell;
AddColumn( Buy, "Buy", 1);
AddColumn( Sell, "Sell", 1);
if (SelectedValue(Buy)==1) Say("BUY Now ");
if (SelectedValue(Sell)==1) Say("Sell Now");
_SECTION_END();


now what i need is this buy now and sell now audio alerts which are in the second afl to be heard in the firtst afl at the points arrowmarked, that is when the candle breaches the green line and red line as the case maybe..thank you for your kind help...


seniors, help this problem..happy sir seems so busy...so others pl help ..
 

amitrandive

Well-Known Member


afl....

_SECTION_BEGIN("BW Fractal");

UpFractal= ValueWhen(
(Ref(H,-2) > Ref(H, -4)) AND
(Ref(H,-2) > Ref(H, -3)) AND
(Ref(H,-2) > Ref(H, -1)) AND
(Ref(H,-2) > H), Ref(H,-2));

...........
now what i need is this buy now and sell now audio alerts which are in the second afl to be heard in the firtst afl at the points arrowmarked, that is when the candle breaches the green line and red line as the case maybe..thank you for your kind help...

Try this and next time use the code # for pasting codes.


Code:
_SECTION_BEGIN("BW Fractal");

UpFractal= ValueWhen(
(Ref(H,-2) > Ref(H, -4)) AND
(Ref(H,-2) > Ref(H, -3)) AND
(Ref(H,-2) > Ref(H, -1)) AND
(Ref(H,-2) > H), Ref(H,-2));

DownFractal= ValueWhen(
(Ref(L,-2) <= Ref(L, -4)) AND
(Ref(L,-2) <= Ref(L, -3)) AND
(Ref(L,-2) <= Ref(L, -1)) AND
(Ref(L,-2) <= L), Ref(L,-2));

//== Added Crash crashandburn59 [at] hotmail.com solution
Plot(Ref(UpFractal,2), "Up Fractal", colorGreen,styleDots,styleThick);
Plot(Ref(DownFractal,2), "Down Fractal",colorRed, styleDots,styleThick);
Plot(C,"",colorWhite,styleCandle);

//Plot(Max(HHV(H,3),Ref(UpFractal,2)), "Up Fractal", ParamColor("Up Fractal Color",colorRed), ParamStyle("Up Fractal Style", styleDashed));
//Plot(Max(HHV(H,3),Ref(UpFractal,2)), "Down Fractal",ParamColor("Down FractalColor",colorBlue), ParamStyle("Down Fractal Style", styleDashed));
_SECTION_END();

_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
_SECTION_END();

_SECTION_BEGIN("MA");
Len = IIf(Interval() > 300, 30, 60);
Disp = WriteIf(Interval() > 300, "MA30", "MA60");
Av = MA(C, Len);
ColorShow = IIf(Av > Ref(Av,-1) AND C > Av, colorGreen, IIf(Av < Ref(Av,-1) AND C < Av, colorRed, colorBlue));
Plot(Av, Disp, ColorShow ,styleLine+styleDots,styleThick,styleDots);
_SECTION_END();

ToolTip = "High = " + H + "\nOpen = " + O + "\nRange = " + (High-Low) +"\nTRUERange = " + (C-O) +"\nMID ="+((High+Low)/2)+ "\nClose = " + C + "\nLow = " + L;
_SECTION_BEGIN("Title");
Title = "";
HoD = TimeFrameGetPrice("H",inDaily);
LoD = TimeFrameGetPrice("L",inDaily);
Rng = HoD - LoD;
Mid = LoD + Rng/2;
//Draw the Panel Box
GfxSelectPen( colorBlack,1 );
GfxMoveTo(2,2);
GfxLineTo(2,30);
GfxLineTo(1044,30);
GfxLineTo(1044,2);
GfxLineTo(2,2);
GfxMoveTo(140,2);
GfxLineTo(140,30);
GfxMoveTo(430,2);
GfxLineTo(430,30);
GfxMoveTo(530,2);
GfxLineTo(530,30);
GfxSelectFont("Comic Sans MS Bold", 9, 800);
GfxSetTextColor(colorBlack);
GfxDrawText(Name(), 10, 3, 77, 20,0);
GfxDrawText(NumToStr(Interval()/60,2.0) + " Min", 82, 3, 140, 20,0);
GfxSelectFont("Comic Sans MS Bold", 7, 800);
GfxDrawText(Date(), 10, 18, 140, 30,0);
GfxSelectFont("Comic Sans MS Bold", 10, 800);
GfxSetTextColor(colorBlue);
GfxDrawText(" HoD:" + NumToStr(HoD,3.0), 148, 7, 240, 30,0);
GfxSetTextColor(colorRed);
GfxDrawText(" LoD:" + NumToStr(LoD,3.0), 242, 7, 340, 30,0);
GfxSetTextColor(colorBlack);
GfxDrawText(" Mid:" + NumToStr(Mid,3.0), 342, 7, 500, 30,0);
GfxDrawText(" Range:" + NumToStr(Rng,3.0), 437, 7, 620, 30,0);
GfxDrawText("Open: " + NumToStr(O,3.0), 537, 7, 740, 30,0);
GfxSetTextColor(colorBlue);
GfxDrawText("Hi: " + NumToStr(H,3.0), 647, 7, 740, 30,0);
GfxSetTextColor(colorRed);
GfxDrawText("Lo: " + NumToStr(L,3.0), 740, 7, 860, 30,0);
GfxSetTextColor(colorBlack);
GfxDrawText("Close: " + NumToStr(C,3.0), 840, 7, 980, 30,0);
GfxSetTextColor(colorBlack);
GfxDrawText("Volume: " + NumToStr(V,3.0), 940, 7, 1080, 30,0);
_SECTION_END();
GfxSetOverlayMode(1);
GfxSelectFont("Comic Sans MS Bold", Status("pxheight")/25 );
GfxSetTextAlign( 6 );// center alignment
GfxSetTextColor( ColorRGB( 160, 160, 160 ) );
GfxSetTextColor( ColorHSB( 160, 0, 151 ) );
GfxSetBkMode(0); // transparent
GfxTextOut( "EARLY EXIT AND SHORTING", Status("pxwidth")/2, Status("pxheight")/3 ); // it will be visible now

Buy = Cross(C, UpFractal);
Sell = Cross(DownFractal,C);
Short=Sell;
Cover=Buy;
Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );

AlertIf( Buy,"SOUND C:\\Windows\\Media\\Chord.wav", "Audio alert", 2 );
AlertIf( Sell,"SOUND C:\\Windows\\Media\\Ding.wav", "Audio alert", 2 );

PlotShapes(IIf(Buy,shapeUpArrow,shapeNone), colorBrightGreen, 0, Low, Offset=-15);
PlotShapes(IIf(Sell, shapeDownArrow,shapeNone), colorPink, 0, High,
Offset=-15);
dist = 2*ATR(2);
for( i = 0; i < BarCount; i++ )
{
if( Buy[i] ) PlotText( "" + C[ i ], i, H[ i ]+dist[i], colorWhite );
if( Sell[i] ) PlotText( "" + C[ i ], i, L[ i ]-dist[i], colorAqua );
}
t1= Flip(Buy,Sell);
t2= Flip(Sell,Buy);
Filter = Buy OR Sell;
AddColumn( Buy, "Buy", 1);
AddColumn( Sell, "Sell", 1);
if (SelectedValue(Buy)==1) Say("BUY Now ");
if (SelectedValue(Sell)==1) Say("Sell Now");
_SECTION_END();
 

amitrandive

Well-Known Member
pl help me creating afl:
when price goes above 66 ema +10=buy
when price goes down 66ema -10= sell
Try this , modify the price filter from the parameters of Exploration

Code:
_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();

Buy_f = Param("Buy Filter",5,0,20,0.1);
Sell_f = Param( "Sell Filter",5,0,20,1);

Plot(C,"Price",IIf(O>C,colorRed,colorGreen),styleBar);
Plot(EMA(Close,66),"66-EMA",colorBlue,styleThick);
Buy=Cross(C,EMA(C,66));
Sell=Cross(EMA(C,66),C);
Short = Sell;
Cover = Buy; 

BuyPrice=ValueWhen(Buy,C+Buy_f,1);
SellPrice=ValueWhen(Sell,C-Sell_f,1);
ShortPrice=ValueWhen(Sell,C-Sell_f,1);
CoverPrice=ValueWhen(Buy,C+Buy_f,1);

GraphXSpace = 5;
dist = 2.5*ATR(10);
for( i = 0; i < BarCount; i++ )
{
if( Buy[i] ) PlotText( "Buy\n" + (C[ i ]+Buy_f), i, L[ i ]-dist[i], colorGreen );
if( Sell[i] ) PlotText( "sell\n" + (C[ i ]-Sell_f), i, L[ i ]+dist[i], colorRed);
}
PlotShapes (IIf(Buy,shapeUpArrow,shapeNone),colorBlue,0,Graph0,-15);
PlotShapes (IIf(Sell,shapeDownArrow,shapeNone),colorCustom12,0,Graph0,-15);
Filter=Buy OR Sell; 
 
AddColumn(IIf(Buy,BuyPrice,Null)," Buy Signal ", 6.2,1.2,colorGreen); 
AddColumn(IIf(Sell,SellPrice,Null)," Sell Signal ",6.2,1.2,colorOrange);
 

vijkris

Learner and Follower
SHould I write section bigins and section ends (sorry I am totally novice abt AFL)
IF u r writing a lengthy and separate calculation then section begin,end can be used.
i assuming u just want to add 2 lines of alertif.
so scroll down to the end of the afl and simply add these two lines. without section begin etc.
:thumb:
 

bapu4

Well-Known Member
IF u r writing a lengthy and separate calculation then section begin,end can be used.
i assuming u just want to add 2 lines of alertif.
so scroll down to the end of the afl and simply add these two lines. without section begin etc.
:thumb:
Hi,
I tried in an AFL, in that it say BUY and SELL used without initialising ,how to initialise it ?
This Ami Is most Unfiendly programme I ever seen.
 
Hi,
I tried in an AFL, in that it say BUY and SELL used without initialising ,how to initialise it ?
This Ami Is most Unfiendly programme I ever seen.
Have your AFL have buy sell variables like...
Suppose u want to buy when price close above ema 20 then ur code will be
BUY= close > EMA(Close, 20);

Now u have BUY variable then u can use in sound code.
 
Last edited:

bapu4

Well-Known Member
Then Amibroker is saying if you don't have a variable then why r u using or define first then use :)
Hi,
Thats what precisely I was asking,"How to Intialise them" Pardon me but I am DUMB in matter of AFL thats why asking for guidence,I think we can Initialise but I dont have its Knowledge.... so.....
 

Similar threads