log in     sign up for free
 
In my opinion, you do not have a trading system unless you know exactly when you will get out of the market position at the time you enter it.
Van K. Tharp
 
 
Home
systems (285)
 
 
Special offer: buy MetaStock (try for free)   |   Reuters QuoteCenter Real-Time Data (get a free month)   |   EOD Data
 

Buy

MetaStock

     (special offer)
 
 
 

Buy

EOD data for MetaStock

     (special offer)
 
 
 

Buy

Realtime data for MetaStock

     (special offer)
 
 
Formula Library
 
AmiBroker
MetaTrader
MetaStock
TradeStation
Wealth-Lab
NinjaTrader
 
add your formula
System Library
 
 
Account login
Your email:
Password:
 
Log in
New to s4t? Sign up.
If you forgot your password click here.
Search the Web
 
Custom Search

2-point Plot

Formula for: MetaStock

indicator

 

 

Views:  1802

Added: May 29, 2008
 
Rate this code:  Rate: 1 Rate: 2 Rate: 3 Rate: 4 Rate: 5
This formula has not been rated yet
 

email this link

 
 
Tags: MetaStock, indicator
 



k> I would like to know if someone would be able to write the formula of a
k> trendline in MS ?
k> Thanks in advance for your help,
k> Karile


--------------------------------------------------------------------------------

By tweaking the MS code below, you can plot just about any trendline imaginable (coding example of 2-point, x/y line plot - useful for creating automatic chart trendlines).

 

 



Code:

2-point plot

{ 2-point plot, coding example v2.5 }
{ Trendline choice 1: last High/Low in month }
{ Trendline choice 2: lows at Jan/June 2004 }
{ ©Copyright 2003-2004 Jose Silva }
{ http://www.metastocktools.com }

plot:=Input("choose event trend [1~2]",1,2,1);
choose:=Input("plot: trendline [1], event points [2]",1,2,1);

{define events}
time1:=C=HHV(C,21);
time2:=C=LLV(C,21);
time2:=time2 AND time2<>time1;

{alternative events}
dateA:=Year()=2004 AND Month()=1;
dateA:=If(LastValue(Cum(dateA))=0,
Year()=LastValue(Year())-1
AND Month()=LastValue(Month()),dateA);
LoValA:=Lowest(ValueWhen(1,dateA,L));
timeA:=dateA AND L=LastValue(LoValA);

dateB:=Year()=2004 AND Month()=6;
dateB:=If(LastValue(Cum(dateB))=0,
Year()=LastValue(Year())
AND Month()=LastValue(Month()),dateB);
LoValB:=Lowest(ValueWhen(1,dateB,L));
timeB:=dateB AND L=LastValue(LoValB);
timeB:=timeB AND timeB<>timeA;

{choose events}
time1:=If(plot=1,time1,timeA);
time2:=If(plot=1,time2,timeB);
price1:=If(plot=1,C,L);
price2:=If(plot=1,C,L);

{restrict to last events}
time1:=time1
AND Cum(time1)=LastValue(Cum(time1));
time2:=time2
AND Cum(time2)=LastValue(Cum(time2));

{sort events}
t1pds:=LastValue(BarsSince(time1));
t2pds:=LastValue(BarsSince(time2));
x1:=If(t1pds>=t2pds,time1,time2);
x2:=If(t1pds>=t2pds,time2,time1);
y1:=If(t1pds>=t2pds,price1,price2);
y2:=If(t1pds>=t2pds,price2,price1);

{fix coordinates}
y1:=ValueWhen(1,x1,y1);
y2:=LastValue(ValueWhen(1,x2,y2));
b1:=LastValue(BarsSince(x1));
b2:=LastValue(BarsSince(x2));

{trendline definition}
plot:=y1+BarsSince(x1)*(y2-y1)/(b1-b2+.000001);
plot:=Ref(Ref(plot,-b2),b2);{rem to extend plot}

If(choose=1,plot,time1+time2)


 





Code to difficult? Find somebody to help you with coding here.

 



Author: Jose Silva
Source: http://www.metastocktools.com

 

View similar (indicator for MetaStock):

Volume By Price 25
Twigg\'s Money Flow
Exponential Moving Average - %Price Change - Filtered
True Strength Index III
John Kosar
FibCMO Indicator
Candle - Dark Cloud Cover
Dual High Low Tide
Darvis Box
Day Trading Volatility Index - DTVI
...
 
 
all formulas for MetaStock
all formulas

 

 

Email to friend

Top

 

     
However we try to maintain hiqhest possible level of service - most formulas, oscillators, indicators
and systems are submitted by anonymous users.
Therefore S4T™ does not take any responsibility for it's quality.
If you use any of this information, use it at your own risk. You are responsible for your own trading decisions.
Be sure to verify that any information you see on these pages is correct, and is applicable to your particular trade.
In no case will S4T™ be responsible for your trading gains or losses.
PayPalSecure payments by PayPal S4T™ is a part of TAURO EDUCATION NETWORK
 
Privacy note | (c) copyrights systems4trading.com 2006-2009