NF Swing Trading using Fractal AFL

Though i have given correct path & tested in bar replay cant hear sound
Regards
Post the alert code what you have added in afl.
Also try below code after Buy and Sell are set in your AFL.

Code:
if (SelectedValue(Buy)==1) Say("BUY Signal Now ");
if (SelectedValue(Sell)==1) Say("Sell Signal Now");
 

oldtrader

Well-Known Member
Also try below code after Buy and Sell are set in your AFL.

Code:
if (SelectedValue(Buy)==1) Say("BUY Signal Now ");
if (SelectedValue(Sell)==1) Say("Sell Signal Now");
hi hmp,

the code by ankur07090 is better than the previous code. pls remove the previous code and add the new code. it is better if you add these lines at the end of the AFL. if still having problem pls paste the code here, i will check it.
 

hmp

Well-Known Member
Also try below code after Buy and Sell are set in your AFL.

Code:
if (SelectedValue(Buy)==1) Say("BUY Signal Now ");
if (SelectedValue(Sell)==1) Say("Sell Signal Now");
Thanks Ankurji for your efforts.Meanwhile if oldtraderji permits us can we tweak this code to avoid whipsawing trade to some extent?
Condition will be as follows.
1)Execute buy or sell signal on any candle in which price crosses 0.2% of high/low of candle which one is showing crossover arrow.
 
Last edited:

hmp

Well-Known Member
hi hmp,

the code by ankur07090 is better than the previous code. pls remove the previous code and add the new code. it is better if you add these lines at the end of the AFL. if still having problem pls paste the code here, i will check it.
Yes Oldtrader ji. Here is the code.
Code:
_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, V, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
SetChartBkGradientFill( ParamColor("Inner panel upper",colorWhite),ParamColor("Inner panel lower",colorLightYellow));

_SECTION_END();

_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[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 Signal Now ");
if (SelectedValue(Sell)==1) Say("Sell Signal Now");
_SECTION_END();
 
Thanks Ankurji for your efforts.Meanwhile if oldtraderji permits us can we tweak this code to avoid whipsawing trade to some extent?
Condition will be as follows.
1)Execute buy or sell signal on any candle in which price crosses 0.2% of high/low of candle which one is showing crossover arrow.
Means you want to trigger the signal when prices crosses the high of signal candle (+ some filter say 5 points in nifty) and same for short.

In backtesting I don't know how to add these filter but in algo trading it can be done I suppose.

But there will be one drawback. suppose buy signal came around 3-3:30 PM and we wait for price to cross the high of signal candle but same day it not happened and next day it opened gap up then in this case we are cutting the profit.
But on the other way, we are cutting the loosing trade that would be more important I suppose. Let other members share their views.
 
Last edited:
Yes Oldtrader ji. Here is the code.
Do below(red colored) path really exist in your local machine. If not then replace original path with the red colored.

Code:
AlertIf( Buy,"SOUND [B][COLOR="Red"]C:\\Windows\\Media\\Chord.wav[/COLOR][/B]", "Audio alert", 2 );
AlertIf( Sell,"SOUND [B][COLOR="red"]C:\\Windows\\Media\\Ding.wav[/COLOR][/B]", "Audio alert", 2 );
 

hmp

Well-Known Member
Do below(red colored) path really exist in your local machine. If not then replace original path with the red colored.

Code:
AlertIf( Buy,"SOUND [B][COLOR="Red"]C:\\Windows\\Media\\Chord.wav[/COLOR][/B]", "Audio alert", 2 );
AlertIf( Sell,"SOUND [B][COLOR="red"]C:\\Windows\\Media\\Ding.wav[/COLOR][/B]", "Audio alert", 2 );
Checked, yes i am having like this C:\Windows\Media\Chord.wav
instead of 2 slashes one slash(\) is there.Does it mater?
 

hmp

Well-Known Member
Means you want to trigger the signal when prices crosses the high of signal candle (+ some filter say 5 points in nifty) and same for short.

In backtesting I don't know how to add these filter but in algo trading it can be done I suppose.

But there will be one drawback. suppose buy signal came around 3-3:30 PM and we wait for price to cross the high of signal candle but same day it not happened and next day it opened gap up then in this case we are cutting the profit.
But on the other way, we are cutting the loosing trade that would be more important I suppose. Let other members share their views.
Yes Ankurji your guessing is correct. In future i am planning to implement it for algo.But only after backtesting.
 

Similar threads