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

Notification

Icon
Error

Options
Go to last post Go to first unread
Marcus_Aurel  
#1 Posted : Friday, August 26, 2011 1:07:46 PM(UTC)
Marcus_Aurel

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 8/26/2011(UTC)
Posts: 6

hello, my name is marcus. i´m a complete newbie on meta stock and cannot code yet :-(

i´m very interesed in cot data and seasonals.

i´ve got a seasonals code from a trading friend. but he use amibroker. so is it possible
to code this indicator for Meta Stock?

i would be very glad if someone here can help me.

here is the code:

/***********************************************************************************************************************
*** Seasonal Chart
***********************************************************************************************************************/
SetBarsRequired( -2, -2 );
SetChartOptions( 0, chartShowArrows|chartShowDates|chartHideQuoteMarker );
//fd = fopen( "Seasonal.txt", "w" );

dy = DayOfYear();
dt = DateTime();
dn = DateNum();
period = Param( "Zeitraum (Jahre)", 15, 5, 100, 5 );
end = ParamDate( "Endpunkt", DateTimeToStr(dt[BarCount-1]), 0 );
endp = 0;
startp = 0;

procedure ZoomChart( )
{
AB = CreateObject( "Broker.Application" );
AW = AB.ActiveWindow;
AW.ZoomToRange( "01.01.2010", "31.12.2010" );
}
ZoomChart( );

// Index zum Endpunkt finden
for( z=BarCount-1; z>=0; z-- )
if( end >= dn[z] ) {
endp = z;
break;
}

//Find Index for Starting Point
for( startp=endp; startp>0; startp-- ) {
if( dy[startp] < dy[startp-1] ) period--;
if( period < -1 ) break;
}


Title = FullName() + " >Seasonal< " + DateTimeToStr(dt[startp]) + " - " + DateTimeToStr(dt[endp]) + " Kurs";
if( diff == "Differenz(NYSE)" ) Title += "/NYSE";

/************************************************************************
*** process (3) ***
*** realtive change from one trading day to next trading day ***
************************************************************************/
function rij( )
{
P = C;
rj[0] = 0;
for( i=1; i<BarCount; i++ ) {

d = dy - dy[i-1]; if( d < 1 ) d = 1; // Tage Differenz (bei Jahreswechsel, immer 1 Tag)
rj = ( P/P[i-1] )^(1/d); // d-te Wurzel aus der Kursänderung (geom. Mittel pro Kalendertag)
}
return rj;
}

/************************************************************************
***helpfunction. searches the calender day in qoute chain ***
************************************************************************/
function findDOY( d )
{
s= "";
// for( i=0; i<BarCount; i++ ) {
for( i=startp; i<=endp; i++ ) {
if( dy == d ) {
s = s + i + ",";
}
}
return s;
}

/************************************************************************
*** process (2) ***
*** geometric change per year to date ***
************************************************************************/
function wi( )
{
w[0] = 0;
rj = rij( );

for( i=1; i<367; i++ ) { // one Year

Cal = findDOY( i ); // exist the calender day in quote
n = StrCount( Cal, "," );
prod = 1;
for( pi=1; pi<n; pi++ ) { // multiplicate founded calendar dates

s = StrExtract( Cal, pi );
sn = StrToNum( s );
prod *= rj[sn];
}
if( i<BarCount ) { // just because syntax warning
if( n==0 ) w = 1; //
else w = prod^(1/n); // n-te Wurzel, geom. Mittel
}
}
return w;
}

/************************************************************************
*** process (1) ***
*** build the qoute chain with the middle values ***
************************************************************************/
function sn( )
{
w = wi( );
start = 0;
end = 0;

// for output, design the start and ending point
for( i=BarCount-1; i>0; i-- ) {

if( dy < dy[i-1] ) {
if( end > 0 ) {
start = i;
break;
} else {
end = i-1;
}
}
}

// filling the quote chains
for( i=0; i<BarCount; i++ ) seasonChart = Null;
seasonChart[start] = 100;
for( i=start+1; i<=end; i++ ) {
d = dy;
if( d < BarCount ) {
seasonChart = seasonChart[i-1] * w[d];

}
}

return seasonChart;
}

Season = sn( );
Plot( Season, "", colorBlack );


//fclose( fd );

jjstein  
#2 Posted : Friday, August 26, 2011 2:04:25 PM(UTC)
jjstein

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/13/2005(UTC)
Posts: 715
Location: Midwest, USA

Was thanked: 1 time(s) in 1 post(s)
Why don't you explain what it is you are looking for, rather than have us puzzle through the code?

Marcus_Aurel  
#3 Posted : Saturday, August 27, 2011 5:53:38 AM(UTC)
Marcus_Aurel

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 8/26/2011(UTC)
Posts: 6

hello, thank you for so fast answer.

okay, in next posting i will explain which indicator i search.

thank you until answering!

Marcus
Marcus_Aurel  
#4 Posted : Saturday, August 27, 2011 8:36:18 AM(UTC)
Marcus_Aurel

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 8/26/2011(UTC)
Posts: 6

hello togehter,

i´m searching for an indicator, that show me the seasonality of an commodity or curency chart.

for 5 years and 15 years.

here is a popular example from moore resarch:

http://www.mrci.com/client/futures/strat/f3832.php

http://www.seasonalcharts.com/classics_ro[censored]l.html

here is another version of code that can be helpful:

dp_y = 252;

// day's avg Close for 5, 10, 20, 40 yrs and 15 yrs Close

ac5y =
(Ref(C,-dp_y*5)+Ref(C,-dp_y*4)+Ref(C,-dp_y*3)+Ref(C,-dp_y*2)+Ref(C,-dp_y))/5;

ac10y =
(Ref(C,-dp_y*10)+Ref(C,-dp_y*9)+Ref(C,-dp_y*8)+Ref(C,-dp_y*7)+Ref(C,-dp_y*6)+
Ref(C,-dp_y*5)+Ref(C,-dp_y*4)+Ref(C,-dp_y*3)+Ref(C,-dp_y*2)+Ref(C,-dp_y))/10;

ac20y = (Ref(C,-dp_y*20)+Ref(C,-dp_y*19)+Ref(C,-dp_y*18)+Ref(C,-dp_y*17)+Ref(C,-dp_y*16)+
Ref(C,-dp_y*15)+Ref(C,-dp_y*14)+Ref(C,-dp_y*13)+Ref(C,-dp_y*12)+Ref(C,-dp_y*11)+
Ref(C,-dp_y*10)+Ref(C,-dp_y*9)+Ref(C,-dp_y*8)+Ref(C,-dp_y*7)+Ref(C,-dp_y*6)+
Ref(C,-dp_y*5)+Ref(C,-dp_y*4)+Ref(C,-dp_y*3)+Ref(C,-dp_y*2)+Ref(C,-dp_y))/20;

ac40y = (Ref(C,-dp_y*40)+Ref(C,-dp_y*39)+Ref(C,-dp_y*38)+Ref(C,-dp_y*37)+Ref(C,-dp_y*36)+
Ref(C,-dp_y*35)+Ref(C,-dp_y*34)+Ref(C,-dp_y*33)+Ref(C,-dp_y*32)+Ref(C,-dp_y*31)+
Ref(C,-dp_y*30)+Ref(C,-dp_y*29)+Ref(C,-dp_y*28)+Ref(C,-dp_y*27)+Ref(C,-dp_y*26)+
Ref(C,-dp_y*25)+Ref(C,-dp_y*24)+Ref(C,-dp_y*23)+Ref(C,-dp_y*22)+Ref(C,-dp_y*21)+
Ref(C,-dp_y*20)+Ref(C,-dp_y*19)+Ref(C,-dp_y*18)+Ref(C,-dp_y*17)+Ref(C,-dp_y*16)+
Ref(C,-dp_y*15)+Ref(C,-dp_y*14)+Ref(C,-dp_y*13)+Ref(C,-dp_y*12)+Ref(C,-dp_y*11)+
Ref(C,-dp_y*10)+Ref(C,-dp_y*9)+Ref(C,-dp_y*8)+Ref(C,-dp_y*7)+Ref(C,-dp_y*6)+
Ref(C,-dp_y*5)+Ref(C,-dp_y*4)+Ref(C,-dp_y*3)+Ref(C,-dp_y*2)+Ref(C,-dp_y))/40;

// plot price and seasonality overlay

//Plot(C, "", colorWhite, styleBar);
//SetChartOptions(0, chartShowDates);
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );

FiveYear = ParamToggle("5YrPlot", "No | Yes");
TenYear = ParamToggle("10YrPlot", "No | Yes");
TwentyYear = ParamToggle("20YrPlot", "No | Yes");
FortyYear = ParamToggle("40YrPlot", "No | Yes");

if( FiveYear )
{
Plot(ac5y, "5yr", colorYellow, styleOwnScale);
}
if( TenYear )
{
Plot(ac10y, "10yr", colorLightOrange, styleOwnScale);
}
if( TwentyYear )
{
Plot(ac20y, "20yr", colorRed, styleOwnScale);
}
if( FortyYear )
{
Plot(ac40y, "40yr", colorBrightGreen, styleOwnScale);
}


jjstein  
#5 Posted : Saturday, August 27, 2011 4:52:57 PM(UTC)
jjstein

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/13/2005(UTC)
Posts: 715
Location: Midwest, USA

Was thanked: 1 time(s) in 1 post(s)
I think Roy or someone is going to have to chime in here; I'm still not sure what you're aiming for.

Marcus_Aurel  
#6 Posted : Sunday, August 28, 2011 4:17:11 AM(UTC)
Marcus_Aurel

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 8/26/2011(UTC)
Posts: 6

hello togehter:

i´m searching for an indicator, that shows me the seasonal performance like this

http://www.seasonalcharts.com/classics_ro[censored]l.html


MS Support  
#7 Posted : Thursday, September 8, 2011 11:14:35 AM(UTC)
MS Support

Rank: Advanced Member

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

Thanks: 92 times
Was thanked: 155 time(s) in 150 post(s)
This is more of a chart style than an indicator.

Current retail versions of MetaStock do not offer seasonal charts. It is available in some of the institutional products of our parent company. I expect this to be added to the retail product in a future version, but I can not say when this will happen.
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.