BullCharts Forum Homepage
Forum Home Forum Home > BullCharts > BullScript
  New Posts New Posts RSS Feed: Seasonal Trend Indicator (STI)
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Seasonal Trend Indicator (STI)

 Post Reply Post Reply
Author
Message / View First Unread Post
KXC View Drop Down
Newbie
Newbie
Avatar

Joined: 24 Sep 2013
Location: Melbourne
Posts: 1
Post Options Post Options   Quote KXC Quote  Post ReplyReply Direct Link To This Post Topic: Seasonal Trend Indicator (STI)
    Posted: 17 Oct 2013 at 2:51pm

I would like to create a new indicator in Bullcharts to measure the seasonal influence, which I believe would be especially beneficial for Market Indices and Commodities .. and maybe for  Major Stocks as well.  However, i don't have the bullscript writing skills to be able to do something this complex.

I'm calling the indicator the Seasonal Trend Indicator (STI).
The criteria are as broadly as follows:
* STI calculates the Percent Gain or Loss for each period (Day or Week).
* Apply a moving avg of 10 period to the STI  (user variable)
* Present the output as a simple bar indicator with a zero line through the middle .. Day one (or start of week one) each year is 01/01/20xx.  How do you handle the calendar day counting process ?  Not sure ..
* Data is over minimum of (say) 4-10 years for each chart bar.   Make this a user varable
* If less than 4 years data available, then the indicator mssg the user to that effect.
 
Hopefully that is enough of a description to enable someone to develop the script.
 
Thank You for your help !
 
The Mask ..
Back to Top
cmacdon View Drop Down
BullCharts Guru
BullCharts Guru


Joined: 09 Sep 2012
Location: Brisbane
Posts: 236
Post Options Post Options   Quote cmacdon Quote  Post ReplyReply Direct Link To This Post Posted: 18 Aug 2014 at 4:21pm
Dear KXC

I notice there were no replies to your request and the probable reason is that your request is to code a Pandora's Box of possibilities.

I will not code what you want but I will show you a possible way for you to resolve a bit of what you want.

The reason I think this is a practical solution is that I recently tried to code a Murrey Math Indicator. To some extent the start date for Murrey Math is a bit like a seasonal indicator, T H Murrey starts each year on the Harvest Moon. Sounds good but he lives in North America. The Harvest Moon in Australia falls on a date about 6 months later in the Calender year. Each year the Harvest moon changes within a range, so it is not like Christmas day is 25 December each year. So getting a seasonal date right is a moveable feast, and if you want to go back 10 years, it probably ain't going to happen using a standard Forum indicator.

Gann starts many of his approaches using various equinoxe dates and depending where you are in the world his dates may not be the same at your centre of gravity dates.

The solution I came up which is probably usefule for the last year of trading will be shown below.

I am heavily dependent on some really very smart code by Jose Silva who used to write a lot of very good indicators on Metastock Forums and on his own Metastock Tools website.   Some of them are seasonal indicators.

I converted to Bullcharts some years back one of Jose's indicators showing the Full Moon, Half Moon and quarter Moon and they are shown at the top of two charts below.

They are based on Calender days, hence there is a squiggle in the trading day chart indicator lines.   (If you go into Bullcharts and the Format menu, select and Time Axis and untick the boxes for Hidden weekends, Public holidays and After Hours you will see that the indicator becomes a straight line as it is then showing on a calendar not trading day chart.

Step 1 is put on the Moon indicator. The ASX is 10 hours from Greenwich meridian so that parameter should show 10   Then you get the dates of the moon phases. My conversion of Jose Code with his copyright is shown further below.

Step 2 is set up you moveable indicator adapting into your indicator code the top two Bullscript lines I have shown in Chart I. (I also pick this up from something Maximo did on this forum for a stop loss indicator, so again I am beholden to him.

This ability to easily move an indicator backwards and forwards on a chart means you can easily find the start of your relevant season on the chart if the season starts on a full moon which many commodity seasons probably do, or if you know the particular date when the chart is put into Calender day mode.

So for the example in chart 1, I started the indicator on the Full Moon of 17 July 2014.

But assume you know that the particular season you want started on the full Moon 14 February 2014, then click on the indicator heading or indicator chart and a verticle line will appear which you grab with your mouse and drag the indicator across the chart to the day before 17 Feb 2014 and you will then have the indicator showing from the start of the season you want.

I will post the two charts below then the Adaptation of the Moon indicator code.
BC User since June 2007
Back to Top
cmacdon View Drop Down
BullCharts Guru
BullCharts Guru


Joined: 09 Sep 2012
Location: Brisbane
Posts: 236
Post Options Post Options   Quote cmacdon Quote  Post ReplyReply Direct Link To This Post Posted: 18 Aug 2014 at 4:26pm
BC User since June 2007
Back to Top
cmacdon View Drop Down
BullCharts Guru
BullCharts Guru


Joined: 09 Sep 2012
Location: Brisbane
Posts: 236
Post Options Post Options   Quote cmacdon Quote  Post ReplyReply Direct Link To This Post Posted: 18 Aug 2014 at 4:27pm
BC User since June 2007
Back to Top
cmacdon View Drop Down
BullCharts Guru
BullCharts Guru


Joined: 09 Sep 2012
Location: Brisbane
Posts: 236
Post Options Post Options   Quote cmacdon Quote  Post ReplyReply Direct Link To This Post Posted: 18 Aug 2014 at 4:28pm
Jose Silva's code converted to Bullscript is below:

{Full/New/Q1/Q3 Moon signals indicator Mk XV. Plots: +1 signal on Full Moon; -1 on New Moon; +0.5 on first Quarter; -0.5 on last Quarter. Accurate to within 2 hours every 19 years. Signals that fall on holidays or weekends are plotted on the next trading day. Use the signal advance input to view approaching signals. Adj lunar signals to market's local Time Zone (generally add 1hr for Daylight Saving Time): New Zealand: +12hrs Australia: +10 Japan: +9 SE Asia: +8 Thai/Indonesia: +7 India: +5.5 Dubai: +4 Moscow: +3 Europe: +1 UK & Portugal: 0 USA, NY: -5 Chicago: -6 http://www.travel.com.hk/region/timezone.htm Copyright © 2001-2009 Jose Silva. The grant of this license is for personal use only - no resale or repackaging allowed. All code remains the property of Jose Silva. http://www.metastocktools.com }

{ User inputs } TZ:=input("Market's local Time Zone? [-12hrs to +12hrs]", 10, -12, 12);
shift:=input("Advance signal by x calendar days", 0, -30, 30);
plot:=input("Plot Q1 and Q3 (half) signals? [1]Yes, [0]No", 0, 0, 1);
{ Lunar cycle length in days (synodic month) }
LunarMonth:=29.53059; offset:=4.86;
{ Calendar engine }
y:=Year()-(Month()<3);
leap:=Int(y/4)-Int(y/100)+Int(y/400);
mth:=Int((2+153*(Month()-3+12*(Month()<3)))/5);
dayNr:=DayOfMonth()+mth+y*365+leap-657382 -offset-TZ/24+shift;

{ New/Q1/Full/Q3 Moon cycles }
NM:=Frac((DayNr+LunarMonth/2)/LunarMonth);
Q1:=Frac((DayNr+LunarMonth/4)/LunarMonth);
FM:=Frac(DayNr/LunarMonth);
Q3:=Frac((DayNr-LunarMonth/4)/LunarMonth);

{ Lunar cycle signals }
cycle:=FM-NM;
FM1:=cycle<0 AND Alert(cycle>0,2);
NM1:=-(cycle>0 AND Alert(cycle<0,2));
cycle1:=Q1-Q3;
Q11:=(cycle1<0 AND Alert(cycle1>0,2))*.5;
Q31:=(cycle1>0 AND Alert(cycle1<0,2))*-.5;
signals:=If(plot=1,NM+Q1+FM+Q3,NM+FM);
{ Plot Lunar signals in own window } signals;

d:=0.5;

[horzline=0];

[linestyle=fill;
color=Green;]
signals; [linestyle=fill;
color=RED;]d;

{ Go Long Markers }
[visible=true]

[name= NewMoon; linestyle=marker; color=Blue; marker=Type2; tooltip="New"]
Cross((FM-NM),0);

[name= QtrMoon; linestyle=marker; color=Red; marker=Type4; tooltip="QtrMoon"]
Cross((Q11-Q31),0);

[visible=true]
[name= FullMoon; linestyle=marker; color=Black; marker=type1; tooltip="FullMoon"]
IF(Cross((FM1-NM1),0)=Cross((FM-NM),0),undefined,Cross((FM1-NM1),0));
BC User since June 2007
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.69
Copyright ©2001-2010 Web Wiz