VST Custom Strategy Lunar Cycle code

The following details will assist in placing the Lunar Cycle indicator within the VST Custom Strategy. (The VST Custom Strategy is FREE to download and use.)

  • If the VST Custom Strategy needs to be installed, the download link is located to the left of screen. (Check the VST is installed prior to the Custom Strategy)

  • The VST Custom Strategy may be re-installed at any time to over-write any unwanted code.

  • Copy/paste the code below into Windows Notepad, copy/paste the code from notepad into the VST Custom Strategy. (This ensures the code is pure text and clean)

  • The charts below will assist in with entering the new code.

This MetaStock indicator is available for free download from metastocklools.com . To download the indicator click here. (The code below is from the VSTpro template)

The code in all versions of the VST is open and able to be modified.

Click on images to enlarge.




-----------copy/paste code below this line---------------

{Full/New/Q1/Q3 Moon signals indicator Mk XV.
Buy: day before Q3
Sell: day before Q1
Trade at own risk!

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

Copyright © 2001-2010 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}
in:=Input("Entry: [0]NM [1]Q1 [2]FM [3]Q3",0,3,3);
ex:=Input("Exit: [0]NM [1]Q1 [2]FM [3]Q3",0,3,1);
TZ:=Input("Market's local Time Zone? [-12hrs to +12hrs]",-12,12,10);
shift:=Input("Advance signal by x calendar days",-30,30,-1);

{Lunar cycle length in days (synodic month)}
LunarMonth:=29.53059;

{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
-4.86-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;
FM:=cycle<0 AND Alert(cycle>0,2);
NM:=cycle>0 AND Alert(cycle<0,2);
cycle:=Q1-Q3;
Q1:=cycle<0 AND Alert(cycle>0,2);
Q3:=cycle>0 AND Alert(cycle<0,2);

{Entry conditions}
entry:=
If(in=0,NM,
If(in=1,Q1,
If(in=2,FM,
Q3)));

{Exit conditions}
exit:=
If(ex=0,NM,
If(ex=1,Q1,
If(ex=2,FM,
Q3)));

{Display}
entry-exit;

No comments:

Post a Comment

 
Design Credit Best Blogger Tips | Best Blogger Templates | Best Social Icons