[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: AFL buy and sell signals



PureBytes Links

Trading Reference Links

I dont know whether we are allowed to post this code as it is in the 
members only area, so I guess not.

Anyway, I don't think one would need buy and sell arrows for this 
system.  

The red and green bands on the bottom indicate the uptrend or 
downtrend and accordingly trade continuation of trend signals or 
reversals depending on what signal one gets using other trading 
systems, for e.g., 10 day pullback system or stoRSI system, but it is 
quite straightforward to add buy and sell arrows:

/* Your buy/sell rules here */

Buy = ExRem(Buy,Sell);

Sell = ExRem(Sell,Buy);

Short = ExRem(Short,Cover);

Cover = ExRem(Cover,Short);

shape = Buy * shapeUpArrow + Sell * shapeDownArrow;

PlotShapes(IIf
(Buy,shapeUpArrow,shapeNone) ,colorBrightGreen,0,Graph0,-15); 

PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorRed,0,Graph0,-15); 

It should work for daily as well as real-time Intra-day timeframes, I 
would think.

rgds, Pal


--- In amibroker@xxxxxxxxxxxxxxx, "Hans Veger" <hvgistel@xxxx> wrote:
> From: Hans Veger <mailto:hvgistel@x...> 
> 
> Date: zondag 14 december 2003 17:56:50
> 
> To:  <mailto:amibroker@xxxxxxxxxxxxxxx> amibroker@xxxxxxxxxxxxxxx
> 
> Subject: AFL - buy and sell signals
> 
>  
> 
> 
> 
> 
>  Hello
> 
>  
> 
>  Can somebody help me with this???
> 
>  
> 
>  
> 
> Im new for amibroker and I try to use the AFL in a trading system
> 
>  
> 
>  
> 
> I have seen a indicator as shown below in:
> 
>  
> 
>  <http://www.amibroker.com/members/traders/01-2004.html>
> http://www.amibroker.com/members/traders/01-2004.html
> 
>  
> 
>  
> 
> Please could you help me to make the AFL compatible for realtime 
trading
> with for example QQQ and BRCD.
> 
>  
> 
> At this moment I can see the results but there are no buy or sell 
signals (
> arrows in green and red ) visible?
> 
>  
> 
> Thanks in advance for your help.
> 
>  
> 
> With kind regards
> 
>  
> 
> Hans Veger
> 
> Netherlands
> 
>  
> 
>  <mailto:hvgistel@x...> hvgistel@xxxx
> 
>  
> 
>  
> 
>  
> 
>  
> 
>  
> 
>  
> 
> //--Indicator-End--
> 
> // Above line instructs the parser that the code
> 
> // below is only for commentary/interpretation window
> 
> // This provides significant performance improvement
> 
> //
> 
> // (C)2002 amibroker.com
> 
> movshort = MA( C, Prefs(4) );
> 
> movmed = MA( C, Prefs(6) );
> 
> movlong = MA( C, Prefs(28) );
> 
> btop = BBandTop( C, Prefs( 4 ), Prefs(8)/100 );
> 
> bbot = BBandBot( C, Prefs(4), Prefs(8)/100 );
> 
> width = btop - bbot;
> 
> lslop = LinRegSlope( C, 30 ) + 100;
> 
> lslo = LLV( lslop, 90 );
> 
> lshi = HHV( lslop, 90 );
> 
> lswidth = lshi - lslo;
> 
> trend = 100*( lslop - lslo )/lswidth;
> 
> mawidth = MA( width, 100 );
> 
> relwidth = 100*(width - mawidth)/mawidth;
> 
> _N( tname = Name()+"("+FullName()+")" );
> 
> Buy = Close < Ref(C,-1) AND Ref(Close,-1) < Ref(Close,-2) AND Ref
(Close,-2)
> < Ref(Close,-3)AND Ref(Close,-3) < Ref(Close,-4) AND Ref(Close,-4) <
> Ref(Close,-5) ; 
> 
> Sell = 
> 
> Close > Ref(C,-1) AND Ref(Close,-1) > Ref(Close,-2) AND Ref(Close,-
2) >
> Ref(Close,-3)AND Ref(Close,-3) > Ref(Close,-4) AND Ref(Close,-4) >
> Ref(Close,-5) ; 
> 
>  
> 
> "Price and moving averages:";
> 
> tname + " has closed " + WriteIf( C > movshort, "above" , "below" ) 
+ " its
> short time moving average. ";
> 
> "Short time moving average is currently " + WriteIf( movshort > 
movmed,
> "above", "below") + " mid-time, and " + WriteIf( movshort > movlong,
> "above", "below" ) + " long time moving averages.";
> 
> "The relationship between price and moving averages is: "+
> 
> WriteIf( C > movshort AND movshort > movmed, "bullish",
> 
> WriteIf( C < movshort AND movshort < 
movmed, "bearish", "neutral" ) ) + " in
> short-term, and "+
> 
> WriteIf( movshort > movmed AND movmed > movlong , "bullish",
> 
> WriteIf( movshort < movmed AND movmed < 
movlong, "bearish", "neutral" ) ) +
> " in mid-long term. ";
> 
> "\nBollinger Bands:";
> 
> tname+ " has closed " + 
> 
> WriteIf( C < bbot, "below the lower band by " +
> 
> WriteVal( 100 *( bbot-C )/ width, 1.1 ) + "%. " +
> 
> WriteIf( trend < 30, " This combined with the steep downtrend can 
suggest
> that the downward trend in prices has a good chance of continuing. 
However,
> a short-term pull-back inside the bands is likely.",
> 
> WriteIf( trend > 30 AND trend < 70, "Although prices have broken 
the lower
> band and a downside breakout is possible, the most likely scenario 
for
> "+tname+" is to continue within current trading 
range.", "" ) ), "" ) +
> 
> WriteIf( C > btop, "above the upper band by " +
> 
> WriteVal( 100 *( C- btop )/ width, 1.1 ) + "%. " +
> 
> WriteIf( trend > 70, " This combined with the steep uptrend 
suggests that
> the upward trend in prices has a good chance of continuing. 
However, a
> short-term pull-back inside the bands is likely.",
> 
> WriteIf( trend > 30 AND trend < 70, "Although prices have broken 
the upper
> band and a upside breakout is possible, the most likely scenario for
> "+tname+" is to continue within current trading 
range.", "" ) ), "" ) +
> 
> WriteIf( C < btop AND ( ( btop - C ) / width ) < 0.5, 
> 
> "below upper band by " +
> 
> WriteVal( 100 *( btop - C )/ width, 1.1 ) + "%. ", 
> 
> WriteIf( C < btop AND C > bbot , "above bottom band by " +
> 
> WriteVal( 100 *( C - bbot )/ width, 1.1 ) + "%. ", "" ) );
> 
> WriteIf( ( trend > 30 AND trend < 70 AND ( C > btop OR C < bbot ) ) 
AND
> abs(relwidth) > 40,
> 
> "This picture becomes somewhat unclear due to the fact that 
Bollinger Bands
> are currently",
> 
> "Bollinger Bands are " )+ 
> 
> WriteVal( abs( relwidth ), 1.1 ) + "% " +
> 
> WriteIf( relwidth > 0, "wider" , "narrower" ) +
> 
> " than normal.";
> 
> WriteIf( abs( relwidth ) < 40, "The current width of the bands 
(alone) does
> not suggest anything conclusive about the future volatility or 
movement of
> prices.","")+
> 
> WriteIf( relwidth < -40, "The narrow width of the bands suggests low
> volatility as compared to " + tname + "'s normal range. Therefore, 
the
> probability of volatility increasing with a sharp price move has 
increased
> for the near-term. "+
> 
> "The bands have been in this narrow range for " +
> WriteVal(BarsSince(Cross(-40,relwidth)),1.0) + " bars. The 
probability of a
> significant price move increases the longer the bands remain in 
this narrow
> range." ,"")+
> 
> WriteIf( relwidth > 40, "The large width of the bands suggest high
> volatility as compared to " + tname + "'s normal range. Therefore, 
the
> probability of volatility decreasing and prices entering (or 
remaining in) a
> trading range has increased for the near-term. "+
> 
> "The bands have been in this wide range for " +
> WriteVal(BarsSince(Cross(relwidth,40)),1.0) + " bars.The 
probability of
> prices consolidating into a less volatile trading range increases 
the longer
> the bands remain in this wide range." ,"");
> 
> Buy=Cross(MACD(), Signal());
> 
> Sell=Cross(Signal(), MACD());
> 
> shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
> 
> Plot( Close, "Price", colorBlue
> 
> , styleCandle );
> 
> PlotShapes( shape, IIf( Buy, colorGreen, colorRed ), 0, IIf( Buy, 
Low, High
> ) );
> 
> GraphXSpace = 5;
> 
> Y=5;
> 
> X=5;
> 
> ApplyStop( 0, 1, Y, 1 ); // max loss stop y%
> 
> ApplyStop( 1, 1, X, 1 ); // profit target stop x%
> 
> five_days_down = IIf(Close < Ref(Close, -1) AND
> 
> (Ref(Close, -1) < Ref(Close, -2)) AND
> 
> (Ref(Close, -2) < Ref(Close, -3)) AND
> 
> (Ref(Close, -3) < Ref(Close, -4)) AND
> 
> (Ref(Close, -4) < Ref(Close, -5)), 1, 0);
> 
> five_days_up = IIf(Close > Ref(Close, -1) AND
> 
> (Ref(Close, -1) > Ref(Close, -2)) AND
> 
> (Ref(Close, -2) > Ref(Close, -3)) AND
> 
> (Ref(Close, -3) > Ref(Close, -4)) AND
> 
> (Ref(Close, -4) > Ref(Close, -5)), 1, 0);
> 
> Buy = five_days_down;
> 
> Sell = five_days_up; 
> 
> Buy = Sum( ROC( Close, 1 ) > 0, 5 ) == 5;
> 
> Sell = Sum( ROC( Close, 1 ) < 0, 5 ) == 5;
> 
> Buy = High == LastValue( Highest( High ) ); 
> 
> Buy = High == HHV( High, 20 ) AND Ref( HHVBars( High, 20 ), -1 ) 
>=4; 
> 
> Buy = Cross( MACD(), 0 ); 
> 
> Sell = Cross( 0, MACD() );
> 
> Buy = Cross( EMA( Close, 9 ), EMA( Close, 15 ) ); 
> 
> Sell = Cross( EMA( Close, 15 ), EMA( Close, 9 ) );
> 
> Buy = Cross( RSI(), 30 );
> 
> Sell = Cross( 70, RSI() );
> 
> Buy = Cross( Ultimate(), 50 );
> 
>  
> 
>  
> 
> 
> 
> 
> 
> 
>  
> 
> 
>  
> 
> 
>  
> 
> 
> Send BUG REPORTS to bugs@xxxx
> Send SUGGESTIONS to suggest@xxxx
> -----------------------------------------
> Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
> (Web page:  <http://groups.yahoo.com/group/amiquote/messages/)>
> http://groups.yahoo.com/group/amiquote/messages/)
> --------------------------------------------
> Check group FAQ at:
> <http://groups.yahoo.com/group/amibroker/files/groupfaq.html>
> http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
> 
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
> <http://docs.yahoo.com/info/terms/> .


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/