Eger sitemize yaptığınız ilk ziyaretiniz ise, Lütfen öncelikle Yardım kriterlerini okuyunuz. Forumumuzda bilgi alışverişinde bulunabilmeniz için öncelikle Kayıt olmalısınız. Üye olmayanlar forumumuzda hiçbir şekilde aktivite uygulayamaz; Konu açamaz, Mesaj yazamaz, Eklenti indiremez, Özel mesajlasamaz. Forumumuzu tam anlamıyla kullanmak için üye olabilirsiniz...
Code 1:
This code is for MIDAS to plot on the daily charts in MetaStock in the way originally
conceived by Paul Levine. Users will be requested to input a year, month, and day
corresponding to an appropriate swing high or low.
{User defined input}
sm:=Input("starting month",1,12,1);
sd:=Input("starting day of month",1,31,1);
sy:=Input("starting year",1980,2100,2000);
start:= sd=DayOfMonth() AND sm=Month() AND sy=Year();
{mid price}
pv:=MP()*V;
{Midas calculation}
denom:= If(Cum(V)-
ValueWhen(1,start,Cum(V))=0,1,Cum(V)-ValueWhen(1,start,Cum(V)));
If(BarsSince(start),(Cum(pv)-ValueWhen(1,start,Cum(pv)))/ denom,MP())
Code 2:
This code is for I-MIDAS to plot on any intraday chart in MetaStock Pro. Users will
also be requested to input the hour and minute. Speed can be an issue when a number of
M curves are plotted in MetaStock and MetaStock Pro. This is an area currently being
worked on by the author.
{User defined input}
sm:=Input("starting month",1,12,1);
sd:=Input("starting day of month",1,31,1);
sy:=Input("starting year",1980,2100,2000);
sh:=Input("hour", 1,24,1);
se:=Input("minute",0,60,0);
start:= sd=DayOfMonth() AND sm=Month() AND sy=Year() AND sh=Hour() AND se=Minute();
{mid price}
pv:=MP()*V;
{Midas calculation}
denom:= If(Cum(V)-
ValueWhen(1,start,Cum(V))=0,1,Cum(V)-ValueWhen(1,start,Cum(V)));
If(BarsSince(start),(Cum(pv)-ValueWhen(1,start,Cum(pv)))/ denom,MP())
Trailing Resistance and Support Stops" by Sylvain Vervoort.
Support trailing stop
I define a pivot support point in an up move when there is a low price that is equal or
lower than the two prices preceding and following this low price. You can use the
following MetaStock expression for this:
support:=If(L>=Ref(L,-2) AND Ref(L,-1)>=Ref(L,-2) AND Ref(L,-3)>=Ref(L,-2) AND
Ref(L,-4)>= Ref(L,-2),Ref(L,-2),{else}
We know that gaps or windows in an uptrend provide support. The low side of the window
is the lowest support level. In the next step, I will add code to detect gaps and make
use of the gap window support. My tests showed that requiring a minimum window size or
setting the stop lower than the previous high only slightly influences the final profit,
but it seems to bring down the number of trades by about 3%. Therefore, I set a minimum
gap requirement of 0.13% and placed the stop 0.55% below the previous high.
If(L>Ref(H,-1)*1.0013,Ref(H,-1)*0.9945,{else}
Price can move up for a number of days without creating a pivot or gap window support.
In such circumstances, to avoid the trailing stop moving too far away from the price
action, I enforced a maximum allowable loss. For example, if I allowed a maximum loss
of 10%, the previous stop level will move up by half that amount, or 5% higher.
If(L>PREV*1.1,PREV*1.05,{else}
To create the Tr&nds trailing stop for an uptrend, I will use the same setup as I did
with the other trailing-stop methods. I am referencing a "_resistance" formula here to
be able to switch from an up to a down move. We will see later how this _resistance
formula is created.
resistance:=Fml("_resistance");
support:=If(L>=Ref(L,-2) AND Ref(L,-1)>=Ref(L,-2) AND Ref(L,-3)>=Ref(L,-2) AND
Ref(L,-4)>= Ref(L,-2),Ref(L,-2),If(L>Ref(H,-1)*1.0013,Ref(H,-1)*0.9945,
If(L>PREV*1.1,PREV*1.05,PREV)));
trail:=If(H>PREV AND Ref(H,-1)>PREV,Max(PREV,support),If(H< PREV AND Ref(H,-1)< PREV,
Min(PREV,resistance),If(C>PREV,support,resistance) ));
trail
Resistance trailing stop
To complete Tr&nds, it is necessary to define the formula for the downtrend move. One
possibility is to use the same rules for the downtrend as for the uptrend. Now, do we
want a very close trailing stop for the downtrend, considering we only want to trade
long positions?
Making money during medium- and longer-term downtrends, trading only long positions, is
very unlikely. We probably are much better off just staying out of long trades during
the medium-term downtrends.
The short-term up reactions will create buy signals and if we used a closer-tracking
trailing stop, we will surely lose money. So I prefer to use the modified ATR trailing
stop to keep me out of the trade as long as the price is in a medium-term downtrend.
The "_resistance" formula then becomes:
{_resistance formula}
period:=Input("ATR Period :",1,100,10);
atrfact:=Input("ATR multiplication :",1,10,2.8);
HiLo:=If(H-L<1.5*Mov(H-L,period,S),H-L, 1.5*Mov(H-L,period,S));
Href:=If(L<=Ref(H,-1),H-Ref(C,-1),(H-Ref(C,-1))-(L-Ref(H,-1))/2);
Lref:=If(H>=Ref(L,-1),Ref(C,-1)-L,(Ref(C,-1)-L)-(Ref(L,-1)-H)/2);
diff1:=Max(HiLo,Href);
diff2:=Max(diff1,Lref);
ATRmod:=Wilders(diff2,period);
loss:=atrfact*ATRmod;
resistance:= C + loss;
Bringing it all together in one formula results in the Tr&nds trailing-stop function:
{SVE_TRENDS_Trail trailing stop function}
atrfact:=Input("ATR multiplication :",1,10,2.8);
period:=Input("ATR Period :",1,100,10);
HiLo:=If(H-L<1.5*Mov(H-L,period,S),H-L, 1.5*Mov(H-L,period,S));
Href:=If(L<=Ref(H,-1),H-Ref(C,-1),(H-Ref(C,-1))-(L-Ref(H,-1))/2);
Lref:=If(H>=Ref(L,-1),Ref(C,-1)-L,(Ref(C,-1)-L)-(Ref(L,-1)-H)/2);
diff1:=Max(HiLo,Href);
diff2:=Max(diff1,Lref);
ATRmod:=Wilders(diff2,period);
loss:=atrfact*ATRmod;
resistance:= C + loss;
support:=If(L>=Ref(L,-2) AND Ref(L,-1)>=Ref(L,-2) AND Ref(L,-3)>=Ref(L,-2) AND
Ref(L,-4)>= Ref(L,-2),Ref(L,-2),If(L>Ref(H,-1)*1.0013,Ref(H,-1)*0.9945,
If(L>PREV*1.1,PREV*1.05,PREV)));
trends:=If(H>PREV AND Ref(H,-1)>PREV,Max(PREV,support),If(H< PREV AND Ref(H,-1)< PREV,
Min(PREV,resistance),If(H>=PREV,support,resistance )));
trends
The SVE_Trends_Trail_Date formula can be found in the sidebar "SVE Trends Trail Date"
as follows:
SVE Trends Trail Date for MetaStock
{TR&NDS trailing stop from start date: SVE_Trends_Trail_Date}
InpMonth:=Input("Month",1,12,8);
InpDay:=Input("Day",1,31,16);
InpYear:=Input("Year",1800,2050,2004);
InitStop:=Input("Initial Stop Price",0.1,10000,9);
Support:=If(L>=Ref(L,-2) AND Ref(L,-1)>=Ref(L,-2) AND Ref(L,-3)>=Ref(L,-2) AND
Ref(L,-4)>= Ref(L,-2),Ref(L,-2), If(L>Ref(H,-1)*1.0013,Ref(H,-1)*0.9945,
If(L>PREV*1.1,PREV*1.05, PREV)));
Entry:= InpYear=Year() AND InpMonth=Month() AND InpDay=DayOfMonth();
StopLong:=ExtFml("AdvancedStop.StopLong",Entry,Ini tStop,0,Support-(H-L),0,0,0,0);
StopLong
ATR-based trailing stop value on the closing price.
{Get the required ATR period;}
period:=Input("ATR Period :",1,100,5);
{Calculate the biggest difference based on the true range concept;}
diff1:=Max(H-L,Abs(H-Ref(C,-1)));
diff2:=Max(diff1,Abs(L-Ref(C,-1)));
{Use Wilders' moving average method to calculate the Average True Range;}
Mov(diff2,period*2-1,E)
Sidebar code from page 35 of the June 2009 issue:
ATR TRAILING STOP
{SVE_Stop_trail_ATR}
atrper:=Input("ATR period :",1,100,5);
atrfact:=Input("ATR multiplication :",1,10,3.5);
loss:=atrfact*ATR(atrper);
trail:=
If(C>PREV AND Ref(C,-1)>PREV,
Max(PREV,C-loss),
If(C < PREV AND Ref(C,-1) < PREV,
Min(PREV,C+loss),
If(C>PREV,C-loss,C+loss)));
Trail
Code from page 36 of the June 2009 issue:
Long position: SVE_StopLong_Trail_ATR_Date.
{SVE_StopLong_Trail_ATR_Date - ATR trailing stop long from date}
InpMonth:=Input("Month",1,12,1);
InpDay:=Input("Day",1,31,1);
InpYear:=Input("Year",1800,2050,2009);
InitStop:=Input("Initial Stop Price",0.1,10000,10);
atrper:=Input("ATR period :",1,100,5);
atrfact:=Input("ATR multiplication :",1,10,3.5);
loss:=atrfact*ATR(atrper);
Entry:= InpYear=Year() AND InpMonth=Month() AND InpDay=DayOfMonth();
StopLong:=ExtFml( "AdvancedStop.StopLong", Entry,InitStop,0,C-Loss,0,0,0,0);
StopLong
Short position: SVE_StopShort_Trail_ATR_Date.
{SVE_StopShort_Trail_ATR_Date - ATR trailing stop short from date}
InpMonth:=Input("Month",1,12,1);
InpDay:=Input("Day",1,31,1);
InpYear:=Input("Year",1800,2050,2009);
InitStop:=Input("Initial Stop Price",0.1,10000,10);
atrper:=Input("ATR period :",1,100,5);
atrfact:=Input("ATR multiplication :",1,10,3.5);
loss:=atrfact*ATR(atrper);
Entry:= InpYear=Year() AND InpMonth=Month() AND InpDay=DayOfMonth();
StopShort:=ExtFml("AdvancedStop.StopShort",Entry,
InitStop,0,C+Loss,0,0,0,0);
StopShort
MODIFIED ATR WITH TRAILING STOPS
{SVE_Stop_Trail_ATR_Mod}
period:=Input("ATR period :",1,100,5);
atrfact:=Input("ATR multiplication :",1,10,3.5);
HiLo:=If(H-L<1.5*Mov(H-L,period,S),H-L, 1.5*Mov(H-L,period,S));
Href:=If(L<=Ref(H,-1),H-Ref(C,-1),(H-Ref(C,-1))-(L-Ref(H,-1))/2);
Lref:=If(H>=Ref(L,-1),Ref(C,-1)-L,(Ref(C,-1)-L)-(Ref(L,-1)-H)/2);
diff1:=Max(HiLo,Href);
diff2:=Max(diff1,Lref);
atrmod:=Wilders(diff2,period);
loss:=atrfact*atrmod;
trail:=
If(C>PREV AND Ref(C,-1)>PREV,
Max(PREV,C-loss),
If(C < PREV AND Ref(C,-1) < PREV,
Min(PREV,C+loss),
If(C>PREV,C-loss,C+loss)));
Trail
Sidebar code from page 40 of the June 2009 issue:
Modified ATR trailing stop from start date
Since you are using your own trading method to finding entry points, you certainly want
to be able to use your own entry date. So again, since the number of input parameters in
MetaStock is limited to six, we have to create separate formulas for a long or a short
position:
AUD intermarket Bollinger band divergence system
To recreate the tests, click on Enhanced System Tester, click on "New system,"
and paste in the buy, sell, short, and buy-to-cover code [shown below].
To run the test, click on "New simulation," add securities, and select the
Australian dollar (AUD/USD). Then select "Periodicity: Daily." Click on "Next,"
and select a transaction cost and initial equity of 100,000. Click on "Trade
execution," uncheck "Realistic market prices," select "Buy price and sell price
at close with no delay," and fill in the slippage of 0.0002 (two pips) per
transaction.
Interest rates for the USD and the AUD fluctuated considerably during the test
duration, so I had to calculate debit and credit interest manually using
historical data from Oanda
(http://fxtrade.oanda.com/tools/stati...st_rates.shtml).
You will also need to change the first four lines of the code to point to the
appropriate folder in your hard drive where the XAU, the CRB index, and 90-day
bank bill futures (YBA) are located.
If you wish to replicate the test, keep in mind that for the test to begin
producing any signals, the indicators used should be calculated first, and this
requires at least 55 extra bars to be loaded.
Buy
SEC2:=Security("C:\Metastock Data\REUTERSINDEX\.XAU",C);
SEC3:=Security("C:\Metastock Data\REUTERSINDEX\.CRB",C);
SEC5:=100-Security("C:\Metastock Data\REUTERSFOREX\@:YBAc1",C);
sec1BOL:= 1+((C Mov(C,30,S)+2*Stdev(C,30))/(4*Stdev(C,30)+.0001));
sec2BOL:=1+((SEC2-mov(SEC2,30,S)+2*Stdev(SEC2,30))/(4*Stdev(SEC2,30)+.0001));
sec3BOL:=1+((SEC3- Mov(SEC3,30,S)+2*Stdev(SEC3,30))/(4*Stdev(SEC3,30)+.0001));
DIV2:=(sec2BOL-sec1BOL)/sec1bol*100;
DIV3:=(sec3BOL-sec1BOL)/sec1bol*100;
DIV1:=MAX(DIV2,DIV3);
(HHV(DIV1,3)>10 AND DIV1< REF(DIV1,-1) AND ROC(C,2,%)>0
AND C>(1+.7/100)*LLV(L,4)
AND (MOV(SEC4,40,S)> REF(MOV(SEC4,40,S),-1)
OR MOV(SEC5,40,S)> REF(MOV(SEC5,40,S),-1)) )
OR (DIV1>40 AND DIV2+DIV3>80 AND DIV1< REF(DIV1,-1)
AND C>REF(C,-1) AND C>(1+.7/100)*LLV(L,4) )
OR {MA Crossover} (CROSS(MOV(C,15,S),MOV(C,50,S))
AND MOV(SEC5,40,S)> REF(MOV(SEC5,40,S),-1))
Sell
SEC2:=Security("C:\Metastock Data\REUTERSINDEX\.XAU",C);
SEC3:=Security("C:\Metastock Data\REUTERSINDEX\.CRB",C);
SEC5:=100-Security("C:\Metastock Data\REUTERSFOREX\@:YBAc1",C);
SEC6:=Security("C:\Metastock Data\REUTERSFOREX\EURJPY=",C);
sec1BOL:= 1+((C- Mov(C,30,S)+2*Stdev(C,30))/(4*Stdev(C,30)+.0001));
sec2BOL:=1+((SEC2- Mov(SEC2,30,S)+2*Stdev(SEC2,30))/(4*Stdev(SEC2,30)+.0001));
sec3BOL:=1+((SEC3- Mov(SEC3,30,S)+2*Stdev(SEC3,30))/(4*Stdev(SEC3,30)+.0001));
DIV2:=(sec2BOL-sec1BOL)/sec1bol*100;
DIV3:=(sec3BOL-sec1BOL)/sec1bol*100;
DIV1:=MIN(DIV2,DIV3);
(CROSS(MOV(MACD(),9,E),MACD()) AND HHV(MACD(),5)>REF(HHV(MACD(),50),-5))
OR (DIV1<-30 AND (ROC(SEC2,1,%)<-.5 OR ROC(SEC3,1,%)<-.5)
AND C<(1-.7/100)*HHV(H,4)) {Negative Divergence}
OR ( DIV1<0 AND ROC(SEC6,2,%)<-1 AND C<(1-.7/100)*HHV(H,4)
AND MOV(SEC6,40,S)< REF(MOV(SEC6,40,S),-1)) {Carry trade liquidation}
Sell short
SEC2:=Security("C:\Metastock Data\REUTERSINDEX\.XAU",C);
SEC3:=Security("C:\Metastock Data\REUTERSINDEX\.CRB",C);
SEC5:=100-Security("C:\Metastock Data\REUTERSFOREX\@:YBAc1",C);
sec1BOL:= 1+((C- Mov(C,30,S)+2*Stdev(C,30))/(4*Stdev(C,30)+.0001));
sec2BOL:=1+((SEC2- Mov(SEC2,30,S)+2*Stdev(SEC2,30))/(4*Stdev(SEC2,30)+.0001));
sec3BOL:=1+((SEC3- Mov(SEC3,30,S)+2*Stdev(SEC3,30))/(4*Stdev(SEC3,30)+.0001));
DIV2:=(sec2BOL-sec1BOL)/sec1bol*100;
DIV3:=(sec3BOL-sec1BOL)/sec1bol*100;
DIV1:=MAX(DIV2,DIV3);
(LLV(DIV1,3)<-10 AND DIV1>REF(DIV1,-1) AND ROC(C,2,%)<0
AND C<(1-.7/100)*HHV(H,4) AND (MOV(SEC4,40,S)< REF(MOV(SEC4,40,S),-1)
OR MOV(SEC5,40,S)< REF(MOV(SEC4,40,S),-1))) OR (DIV1<-20
AND DIV2+DIV3<-40 AND DIV1>REF(DIV1,-1) AND C< REF(C,-1)
AND C<(1-.7/100)*HHV(H,4)) OR (CROSS(MOV(C,50,S),MOV(C,15,S))
AND MOV(SEC5,40,S)< REF(MOV(SEC5,40,S),-1))
Buy to cover
SEC2:=Security("C:\Metastock Data\REUTERSINDEX\.XAU",C);
SEC3:=Security("C:\Metastock Data\REUTERSINDEX\.CRB",C);
sec1BOL:= 1+((C- Mov(C,30,S)+2*Stdev(C,30))/(4*Stdev(C,30)+.0001));
sec2BOL:=1+((SEC2- Mov(SEC2,30,S)+2*Stdev(SEC2,30))/(4*Stdev(SEC2,30)+.0001));
sec3BOL:=1+((SEC3- Mov(SEC3,30,S)+2*Stdev(SEC3,30))/(4*Stdev(SEC3,30)+.0001));
DIV2:=(sec2BOL-sec1BOL)/sec1bol*100;
DIV3:=(sec3BOL-sec1BOL)/sec1bol*100;
DIV1:=MAX(DIV2,DIV3);
(CROSS(MACD(),MOV(MACD(),9,E)) AND LLV(MACD(),5)< REF(LLV(MACD(),50),-5))
OR (DIV1>30 AND (ROC(SEC2,1,%)>.5 OR ROC(SEC3,1,%)>.5)
AND C>(1+.7/100)*HHV(H,4))
AUD Expert Advisor
To avoid the tedious task of running the test every day to check for whether
there are any new signals, you can create an expert advisor and attach it to
the AUD/USD chart.
To create the expert advisor, click on the appropriate icon and then click on
"New," and fill in an appropriate name (for example, "AUD Intermarket System")
in the name field and fill in the following in the Notes field: "See article:
Trading The Australian Dollar by Markos Katsanos published in the February 2009
issue of TAS&C." Then click on "symbols," select the appropriate action (that
is, buy), and fill in the same code that you used for the test described above.
Then click on "Graphic" and select an appropriate graphic (for example, green
arrows below the price plot). The same procedure should be repeated for the
sell, short, and buy-to-cover code.
AUD intermarket Bollinger band divergence system
To recreate the tests, click on Enhanced System Tester, click on "New system,"
and paste in the buy, sell, short, and buy-to-cover code [shown below].
To run the test, click on "New simulation," add securities, and select the
Australian dollar (AUD/USD). Then select "Periodicity: Daily." Click on "Next,"
and select a transaction cost and initial equity of 100,000. Click on "Trade
execution," uncheck "Realistic market prices," select "Buy price and sell price
at close with no delay," and fill in the slippage of 0.0002 (two pips) per
transaction.
Interest rates for the USD and the AUD fluctuated considerably during the test
duration, so I had to calculate debit and credit interest manually using
historical data from Oanda
(OANDA Interest Rates - OANDA FXTrade).
You will also need to change the first four lines of the code to point to the
appropriate folder in your hard drive where the XAU, the CRB index, and 90-day
bank bill futures (YBA) are located.
If you wish to replicate the test, keep in mind that for the test to begin
producing any signals, the indicators used should be calculated first, and this
requires at least 55 extra bars to be loaded.
Buy
SEC2:=Security("C:\Metastock Data\REUTERSINDEX\.XAU",C);
SEC3:=Security("C:\Metastock Data\REUTERSINDEX\.CRB",C);
SEC5:=100-Security("C:\Metastock Data\REUTERSFOREX\@:YBAc1",C);
sec1BOL:= 1+((C Mov(C,30,S)+2*Stdev(C,30))/(4*Stdev(C,30)+.0001));
sec2BOL:=1+((SEC2-mov(SEC2,30,S)+2*Stdev(SEC2,30))/(4*Stdev(SEC2,30)+.0001));
sec3BOL:=1+((SEC3- Mov(SEC3,30,S)+2*Stdev(SEC3,30))/(4*Stdev(SEC3,30)+.0001));
DIV2:=(sec2BOL-sec1BOL)/sec1bol*100;
DIV3:=(sec3BOL-sec1BOL)/sec1bol*100;
DIV1:=MAX(DIV2,DIV3);
(HHV(DIV1,3)>10 AND DIV1< REF(DIV1,-1) AND ROC(C,2,%)>0
AND C>(1+.7/100)*LLV(L,4)
AND (MOV(SEC4,40,S)> REF(MOV(SEC4,40,S),-1)
OR MOV(SEC5,40,S)> REF(MOV(SEC5,40,S),-1)) )
OR (DIV1>40 AND DIV2+DIV3>80 AND DIV1< REF(DIV1,-1)
AND C>REF(C,-1) AND C>(1+.7/100)*LLV(L,4) )
OR {MA Crossover} (CROSS(MOV(C,15,S),MOV(C,50,S))
AND MOV(SEC5,40,S)> REF(MOV(SEC5,40,S),-1))
Sell
SEC2:=Security("C:\Metastock Data\REUTERSINDEX\.XAU",C);
SEC3:=Security("C:\Metastock Data\REUTERSINDEX\.CRB",C);
SEC5:=100-Security("C:\Metastock Data\REUTERSFOREX\@:YBAc1",C);
SEC6:=Security("C:\Metastock Data\REUTERSFOREX\EURJPY=",C);
sec1BOL:= 1+((C- Mov(C,30,S)+2*Stdev(C,30))/(4*Stdev(C,30)+.0001));
sec2BOL:=1+((SEC2- Mov(SEC2,30,S)+2*Stdev(SEC2,30))/(4*Stdev(SEC2,30)+.0001));
sec3BOL:=1+((SEC3- Mov(SEC3,30,S)+2*Stdev(SEC3,30))/(4*Stdev(SEC3,30)+.0001));
DIV2:=(sec2BOL-sec1BOL)/sec1bol*100;
DIV3:=(sec3BOL-sec1BOL)/sec1bol*100;
DIV1:=MIN(DIV2,DIV3);
(CROSS(MOV(MACD(),9,E),MACD()) AND HHV(MACD(),5)>REF(HHV(MACD(),50),-5))
OR (DIV1<-30 AND (ROC(SEC2,1,%)<-.5 OR ROC(SEC3,1,%)<-.5)
AND C<(1-.7/100)*HHV(H,4)) {Negative Divergence}
OR ( DIV1<0 AND ROC(SEC6,2,%)<-1 AND C<(1-.7/100)*HHV(H,4)
AND MOV(SEC6,40,S)< REF(MOV(SEC6,40,S),-1)) {Carry trade liquidation}
Sell short
SEC2:=Security("C:\Metastock Data\REUTERSINDEX\.XAU",C);
SEC3:=Security("C:\Metastock Data\REUTERSINDEX\.CRB",C);
SEC5:=100-Security("C:\Metastock Data\REUTERSFOREX\@:YBAc1",C);
sec1BOL:= 1+((C- Mov(C,30,S)+2*Stdev(C,30))/(4*Stdev(C,30)+.0001));
sec2BOL:=1+((SEC2- Mov(SEC2,30,S)+2*Stdev(SEC2,30))/(4*Stdev(SEC2,30)+.0001));
sec3BOL:=1+((SEC3- Mov(SEC3,30,S)+2*Stdev(SEC3,30))/(4*Stdev(SEC3,30)+.0001));
DIV2:=(sec2BOL-sec1BOL)/sec1bol*100;
DIV3:=(sec3BOL-sec1BOL)/sec1bol*100;
DIV1:=MAX(DIV2,DIV3);
(LLV(DIV1,3)<-10 AND DIV1>REF(DIV1,-1) AND ROC(C,2,%)<0
AND C<(1-.7/100)*HHV(H,4) AND (MOV(SEC4,40,S)< REF(MOV(SEC4,40,S),-1)
OR MOV(SEC5,40,S)< REF(MOV(SEC4,40,S),-1))) OR (DIV1<-20
AND DIV2+DIV3<-40 AND DIV1>REF(DIV1,-1) AND C< REF(C,-1)
AND C<(1-.7/100)*HHV(H,4)) OR (CROSS(MOV(C,50,S),MOV(C,15,S))
AND MOV(SEC5,40,S)< REF(MOV(SEC5,40,S),-1))
Buy to cover
SEC2:=Security("C:\Metastock Data\REUTERSINDEX\.XAU",C);
SEC3:=Security("C:\Metastock Data\REUTERSINDEX\.CRB",C);
sec1BOL:= 1+((C- Mov(C,30,S)+2*Stdev(C,30))/(4*Stdev(C,30)+.0001));
sec2BOL:=1+((SEC2- Mov(SEC2,30,S)+2*Stdev(SEC2,30))/(4*Stdev(SEC2,30)+.0001));
sec3BOL:=1+((SEC3- Mov(SEC3,30,S)+2*Stdev(SEC3,30))/(4*Stdev(SEC3,30)+.0001));
DIV2:=(sec2BOL-sec1BOL)/sec1bol*100;
DIV3:=(sec3BOL-sec1BOL)/sec1bol*100;
DIV1:=MAX(DIV2,DIV3);
(CROSS(MACD(),MOV(MACD(),9,E)) AND LLV(MACD(),5)< REF(LLV(MACD(),50),-5))
OR (DIV1>30 AND (ROC(SEC2,1,%)>.5 OR ROC(SEC3,1,%)>.5)
AND C>(1+.7/100)*HHV(H,4))
AUD Expert Advisor
To avoid the tedious task of running the test every day to check for whether
there are any new signals, you can create an expert advisor and attach it to
the AUD/USD chart.
To create the expert advisor, click on the appropriate icon and then click on
"New," and fill in an appropriate name (for example, "AUD Intermarket System")
in the name field and fill in the following in the Notes field: "See article:
Trading The Australian Dollar by Markos Katsanos published in the February 2009
issue of TAS&C." Then click on "symbols," select the appropriate action (that
is, buy), and fill in the same code that you used for the test described above.
Then click on "Graphic" and select an appropriate graphic (for example, green
arrows below the price plot). The same procedure should be repeated for the
sell, short, and buy-to-cover code.
MetaStock code for the heikin-ashi-based oscillator
From February 2009 Letters to S&C:
Heikin-Ashi-based oscillator
Editor,
I very much enjoyed the article "Trading With The Heikin-Ashi Candlestick
Oscillator" by Sylvain Vervoort in the December 2008 issue and am still
studying it.
When I first came across the heikin-ashi technique a few years ago, I was
immediately attracted to its potential vis-à-vis its simplicity. Since
Vervoort seems to be seriously interested in the heikin-ashi technique, I
would like to share with him (and other readers) a heikin ashi-based
oscillator that I have created (the MetaStock code is shown below) and
suggest that he consider improving/building on it and perhaps run some
long-term and thorough backtests on, for instance, the Standard & Poor's
500 and sector indexes ETFs (SPY, XLF, XLI, XLK, etc.) to assert its
usefulness.
{Heikin-Ashi Counter}
period:=Input("Periods",5,100,12);
haclose:=(O+H+L+C)/4;
haopen:=(PREV+Ref(haclose,-1))/2;
hahigh:=Max(Max(H,haopen),haclose);
halow:=Min(Min(L,haopen),haclose);
counter:=If(hahigh>Ref(hahigh,-1) AND
halow>Ref(halow,-1),1,If(hahigh< Ref(hahigh,-1) AND
halow< Ref(halow,-1),-1,0));
indic:=Sum(counter,period)/period*100;
indic;
--Name Withheld
Sylvain Vervoort replies:
I am providing some test results for your heikin-ashi counter formula. [See
Figures 1 and 2.-Editor]
Getting positive results from using any single indicator is not easy. Either
you have to create crossovers using an additional average or smooth it so much
that it would be possible to trade on the turning points. Both of these methods
create too much delay to make it an automatic, profitable system. Another method
would be to use certain oscillator levels as buying and selling references, but
in that case you must have an oscillator that attains highest and lowest levels
a lot of the time.
So I tested the latter using your formula with just five days' counting. The
test formula is as follows:
period:=5;
haclose:=(O+H+L+C)/4;
haopen:=(PREV+Ref(haclose,-1))/2;
hahigh:=Max(Max(H,haopen),haclose);
halow:=Min(Min(L,haopen),haclose);
counter:=If(hahigh>Ref(hahigh,-1) AND
halow>Ref(halow,-1),1,If(hahigh< Ref(hahigh,-1) AND
halow< Ref(halow,-1),-1,0));
indic:=Sum(counter,period)/period*100;
buy:=indic>-20;
sell:=indic<-20;
Each stock has $1,000 to start with and there is no profit or loss sharing with
the other stocks. Further, we are going long only. I get a 70% profit with an
average of 68 trades per stock (inclusive of brokerage commissions) using 57
Dutch midcap stocks, from the beginning of 2003 until the end of December 2008.
Considering the current situation, this result is certainly not bad. Results
from a buy & hold approach will probably be negative these days. If I run the
same test using the same starting date but stopping at August 2007, I get a
profit of 144% with an average of 46 trades. (See Figures 1 and 2.)
You can probably experiment further with the formula and try other markets. I
get slightly better results, with only about half the number of trades, if I
use the heikin-ashi closing price average as a reference (all heikin-ashi
price levels divided by 4) that I normally use.
Yorum