And another question guys:
Although not usually effective, in my manual testing and trading of a system I have evidence that a wide trailing stop is effective at getting me out at the end of a move. When I have tried to implement trailing stops in the past I have gotten very strange backtesting results in AB. I ran an extensive optimisation and the most profitable settings (by far) was trailing stop set at "0%".
Can anyone shed any light on exactly how AB executes a trailing stop set at 0%?
The way I see trailing stops is if you set it at say 5%, if your stock drops 5%after you buy it, you sell, and if you stock rises 20%, then drops 5% you sell, locking in 15% profit.
The stops are set to execute intraday but buy and sell signals are on the open.
Not sure how AB executes with a 0% trailing stop?
Thanks.
Hi guys,
I want to have a buy condition in my system of:
Only buy if the sector EMA of a stock is rising.
Any ideas on how to code that in AFL? Best I can do is foreign in a sector index like XMJ and only backtest on materials stocks, is there a way to reference to the sector the stock belongs to?
I have premium data.
Call = Foreign("XMJ", "Close");
XMJema = EMA(Call, 12);
BuyQ = XMJema > Ref(XMJema, - 1); //Open long stock position
Buy = Ref(C>O, -1) & BuyQ;
PHP:Call = Foreign("XMJ", "Close"); XMJema = EMA(Call, 12); BuyQ = XMJema > Ref(XMJema, - 1); //Open long stock position Buy = Ref(C>O, -1) & BuyQ;
Trouble is the reference period. Greater than yesterday could be 1 day in a down ward trend. Greater than 10 days ago could be a short rally in a downward trend.
Greater than 50 days ago could be at the top of an up trend. Shorter or longer there is no guarantee that a rising sector EMA is the right time to enter a stock purchase. Let me know if you have a magic rising period.
//Sector EMA
Sector = SectorID(0);
S1 = Foreign("XDK","C",True);
IIf(Sector == 1, SectorArray = S1, 0);
S2 = Foreign("XFDK","C",True);
IIf(Sector == 2, SectorArray = S2, 0);
S3 = Foreign("XENK","C",True);
IIf(Sector == 3, SectorArray = S3, 0);
S4 = Foreign("XENK","C",True);
IIf(Sector == 4, SectorArray = S4, 0);
S5 = Foreign("XHCK","C",True);
IIf(Sector == 5, SectorArray = S5, 0);
S6 = Foreign("XKI","C",True);
IIf(Sector == 6, SectorArray = S6, 0);
S7 = Foreign("XIK","C",True);
IIf(Sector == 7, SectorArray = S7, 0);
S8 = Foreign("XMJ","C",True);
IIf(Sector == 8, SectorArray = S8, 0);
S9 = Foreign("XTEK","C",True);
IIf(Sector == 9, SectorArray = S9, 0);
S10 = Foreign("XUK","C",True);
IIf(Sector == 10, SectorArray = S10, 0);
SectorEMA = EMA(SectorArray, 40);
Sector_EMA_direction = SectorEMA > Ref(SectorEMA , -1) AND Ref(SectorEMA , -1) > Ref(SectorEMA , -2) AND Ref(SectorEMA , -2) > Ref(SectorEMA , -3) ;
//Long Term EMA
//LTEMAP = Optimize("LTEMA Period", 60, 40, 100, 5);
LTEMAP = 60;
LTema = EMA(C, LTEMAP);
//At least 3 days of EMA rising in a row required
EMA_direction = LTema > Ref(Ltema, -1) AND Ref(LTema, -1) > Ref(LTema, -2) AND Ref(LTema, -2) > Ref(LTema, -3) ;
I simply scan stock in the sector of interest, not the whole ASX. Energy stocks, Material stocks, Industrial stocks etc.Hmmm the problem with that code is it does not adjust to the sector ema of the specific security. This is what I came up with for the sector EMA, not efficient but works:
Went down that path of testing for several weeks and came out none the wiser. Good luck with it.And to overcome your problem of picking a point in time to determine EMA slope, I just make a contingent string of EMA refs!
You need some way to back fill quotes too. Like from your last quotes when Amibroker was opened.
I advertised on Freelancer.com for a DDE server script like the set up with Forex Meta Trader platform but received no takers. I tried QuoteTracker but it updates prices every 20 seconds one at a time so not live and the more stocks (over 100) the slower it is.
It can't be that hard surely to connect to real time (instant) price data for the whole exchange. I believe even Interactive Brokers throttles backfill such ...
and limited to 100 stocks. What the.
My simple direct data exchange (or Plug-in) requirements to Amibroker =
a) The whole ASX list
b) Real time, live, instant feed
c) At least 1 week of 1 minute backfill for the whole ASX list reasonably fast (don't want to have to log in 2 hours before market opens to backfill)
Some clever computer technician could make a business from this as there would be many Amibroker users that would buy the setup or pay a small monthly fee.
Favourites from these alerts can be easily created in AB and the exploration or scan set to 1 second for constant scanning of the ASX. Day traders dream ticket.Me too, surely it cant be to hard, ive also had a look on free lancer for amibroker past jobs, hopeing someone had already dealt with this, i might have to go with IB i really only need my list of 40ish stocks that i can run alerts on
_SECTION_BEGIN("GRID");
gridINCR = Param("incr",.50,0,1,0.0001);
if( ParamToggle("show custom grid", "NO|YES", 1) AND Interval()==60)
{
SetChartOptions(1,chartShowArrows|chartShowDates, 0);
firstbarvisible = BarIndex()==1 OR (Status("barvisible") AND NOT Ref(
Status("barvisible"), -1));
GridMIN = LastValue( LowestSince( firstbarvisible, round((Low-10)/10)*10 ) );
GridMAX = LastValue( HighestSince( firstbarvisible, round((High+10)/10)*10 ) );
steps = (GridMAX - GridMIN)/ gridINCR ;
for(i=0;i < steps;i++)
PlotGrid(GridMIN+i*gridINCR, ParamColor("Color", colorBlack) );
}
else
SetChartOptions(1,chartShowArrows|chartShowDates);
_SECTION_END();
I know what you mean now. On this screen shot I have created a separate chart for weekly ADX line. As can be seen, the ADX line (time frame expanded) on the daily chart displays the ADX line for that period in weekly.However, checking the stock this scan returns I've noticed that so called "Weekly ADX value" does not match the actual weekly ADX indicator value plotted below price graph.
Why is this happening?
Thanks in advance
This can be overcome by creating a separate chart as I have done. File -> New -> Blank Chart
Yes different.Hey Wysiwyg,
As you can see they are close, almost identical in shape, by the values are different.
Do you get the same?
Folks,
The PlotShape function provides a subfunction called offset that one can use to offset shapes where offset is measure in pixels. My code reads something like this:
PlotShapes(IIf((Bull AND L<KS),shapeHollowSmallUpTriangle,shapeNone),colorBlue);
However when I put offset after color selection my shapes disappear from screen.
What am I doing wrong?
Top chart: plot( c, "", colorblack, stylebar);
Bottom chart: plot( c, "", colorblack, stylecandle ); and then change the up and down candle color in preferences >> colors
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?