logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
MS Support  
#1 Posted : Monday, February 17, 2025 11:06:50 PM(UTC)
MS Support

Rank: Advanced Member

Groups: Moderators, Registered, Registered Users, Subscribers
Joined: 10/8/2010(UTC)
Posts: 1,971

Thanks: 94 times
Was thanked: 156 time(s) in 151 post(s)

Markos Katsanos’ article, “Is the Price REIT” presents a system to for trading REIT ETFs. Below are the MetaStock formulas for the backtest system.  The article include optimization variables which must be defined in MetaStock’s System Tester. 

 

Code:
Name    Description    Minimum    Maximum    Step
OPT1    Bollinger Band Period    15    20    5
OPT2    Bollinger Band StDev    2    2    0.5
OPT3    Lookback period for TNX HH or LL    25    25    5
OPT4    Donchian Channel Length    30    30    5
OPT5    Minimum% TNX Change    15    25    5
OPT6    Maximum correlation for buy signal    0.2    0.3    0.1
OPT7    Minimum yield (TNX/10)    2    2    0.5
OPT8    ATR Stop Multiplier    1.5    1.5    0.5
OPT9    Maximum Stop Loss %    8    8    1

Those OPT variables must be replaced with numeric constants to use the formulas in an exploration or expert advisor. 

Buy Order:

Code:
SPY:= Security("ONLINE:SPY", C);
TNX:= Security("ONLINE:TNX", C);

YLD:= TNX/10; STO10:= Mov(Stoch(10,1),3,S); ATR15:= Mov(ATR(1),15*2-1,E);

{ TNX HH &LL } LLT:= LLV(TNX, OPT3); HHT:= HHV(TNX, OPT3); TNXUP:= (TNX-LLT)/(LLT+.001)*100; TNXDN:= (TNX-HHT)/(HHT+.001)*100;

{ ETF HH & LL } LL:= LLV(L,100); PERCUP:= (C-LL)/(LL+.001)*100; Upper:= Ref(HHV(C, OPT4),-1) ; { Donchian Upper Channel }

{ Correlations } CORT:= Correl(C,TNX,20,0); CORS:= Correl(C,SPY,20,0);

BBBOT:= BBandBot(C, OPT1, S, OPT2);

NoBuy:= C<Mov(C,30,S) AND C<(1-OPT9/100)*HHV(C,2) AND  (SPY<(1-OPT9/100)*Ref(SPY,-1) OR CORS<0);

{ Buy Conditions } BuyBB:= (L<BBBOT AND C>BBBOT+.2*ATR15) AND ((TNXDN<-OPT5 AND CORT<OPT6) OR YLD<OPT7) AND C>(H+L)/2 AND NoBuy = 0;

BUYTrend:= C>UPPER AND SPY>Mov(SPY,20,S) AND  (HHVBARS(TNX, OPT4)>10 OR CORT>OPT6 OR YLD<OPT7);

BuyBB OR BuyTrend

Sell Order:

Code:
SPY:= Security("ONLINE:SPY", C);
TNX:= Security("ONLINE:TNX", C);

YLD:= TNX/10; STO10:= Mov(Stoch(10,1),3,S); ATR15:= Mov(ATR(1),15*2-1,E);

LLT:= LLV(TNX, OPT3); HHT:= HHV(TNX, OPT3); TNXUP:= (TNX-LLT)/(LLT+.001)*100; TNXDN:= (TNX-HHT)/(HHT+.001)*100;

LL:= LLV(L,100); PERCUP:= (C-LL)/(LL+.001)*100;

CORT:= Correl(C,TNX,20,0); CORS:= Correl(C,SPY,20,0);

BBBOT:= BBandBot(C, OPT1, S, OPT2);

NoBuy:= C<Mov(C,30,S) AND C<(1-OPT9/100)*HHV(C,2) AND  (SPY<(1-OPT9/100)*Ref(SPY,-1) OR CORS<0);

{ Buy Conditions } BuyBB:= (L<BBBOT AND C>BBBOT+.2*ATR15) AND ((TNXDN<-OPT5 AND CORT<OPT6) OR YLD<OPT7) AND C>(H+L)/2 AND NoBuy = 0;

{ Sell Conditions } Sell1:= (TNXUP> OPT5 OR (YLD>4 AND TNXUP>0) ) AND C<HHV(C,5)-OPT8*ATR15 AND BuyBB = 0;

STOP:= C<Mov(C,30,S) AND C<(1-OPT9/100)*Ref(C,-1) AND (SPY<(1-OPT9/100)*Ref(SPY,-1) OR CORS<0);

SELLOB:= PERCUP>50 AND C<HHV(H,3)-OPT8*ATR(15) AND HHV(STO10,3)>90;

SELL1 OR SELLOB OR STOP

William Golson

MetaStock Technical Support

Edited by user Monday, February 17, 2025 11:14:14 PM(UTC)  | Reason: Not specified

Users browsing this topic
Guest (Hidden)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.