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

Notification

Icon
Error

Options
Go to last post Go to first unread
me_melb  
#1 Posted : Saturday, June 4, 2011 3:44:41 AM(UTC)
me_melb

Rank: Newbie

Groups: Registered, Registered Users
Joined: 11/22/2010(UTC)
Posts: 7

Hi, I am trying to see impact of using different parameters of a moving average on different shares. i.e. mov (C,90,E), mov (C,100,E), mov (C,50,E), mov (C,90,W) etc….. After implementing that, I want to count how many times the close price crosses above or below a moving average. Basically I want a formula which will count the total thumbs up or down in given chart. (see attached). This is my first post so please be gentle and I appreciate all your help in advance.
jjstein  
#2 Posted : Saturday, June 4, 2011 11:04:07 AM(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)
That can be done with SUM(Condition,Lookback) for each MA cross, but will need to decide how far back ("Lookback") you want to go, as well as specify the "collection" of MA's you want to use.

me_melb  
#3 Posted : Saturday, June 4, 2011 5:45:13 PM(UTC)
me_melb

Rank: Newbie

Groups: Registered, Registered Users
Joined: 11/22/2010(UTC)
Posts: 7

Thanks Jonathan for your response.

with your two question

How Far back - I am thinking 5 years (is this possible)
Collection of MA - I am thinking 90,120,150,180 period Close, Exponential initially (but I assume I can amend this if I want to - is that right?)

Appreciate further help on this.

jjstein  
#4 Posted : Saturday, June 4, 2011 7:33:38 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)
Well, here's a couple of things to play with...

I assume you can create a custom indicator, and adjust the color, style, etc. Also, note that when you drag any indicator into a chart, if you drag it down to the X-AXIS, the mouse cursor changes to a little rectangle, and will create a new window -- if the indicator stays as a little squiggly line, the indicator you are dragging will be added to whichever window it's in when you release the mouse button.


1. These two will plot a count of crossovers.
---------------------------------------------
{* Thumbs Up *}
Lookback:=Input("Lookback",1,10000,1260);

Sum(Cross(C,Mov(C,90,E)),Lookback)
+Sum(Cross(C,Mov(C,120,E)),Lookback)
+Sum(Cross(C,Mov(C,150,E)),Lookback)
+Sum(Cross(C,Mov(C,180,E)),Lookback);


{* Thumbs Down *}
Lookback:=Input("Lookback",1,10000,1260);

Sum(Cross(Mov(C,90,E),C),Lookback)
+Sum(Cross(Mov(C,120,E),C),Lookback)
+Sum(Cross(Mov(C,150,E),C),Lookback)
+Sum(Cross(Mov(C,180,E),C),Lookback);


2. This will plot a binary indicator, showing which count is higher.
-----------------------------------------------------------------
{* Combo *}
Lookback:=Input("Lookback",1,10000,1260);

ThumbsUp:=
Sum(Cross(C,Mov(C,90,E)),Lookback)
+Sum(Cross(C,Mov(C,120,E)),Lookback)
+Sum(Cross(C,Mov(C,150,E)),Lookback)
+Sum(Cross(C,Mov(C,180,E)),Lookback);

ThumbsDown:=
Sum(Cross(Mov(C,90,E),C),Lookback)
+Sum(Cross(Mov(C,120,E),C),Lookback)
+Sum(Cross(Mov(C,150,E),C),Lookback)
+Sum(Cross(Mov(C,180,E),C),Lookback);

If(ThumbsUp>ThumbsDown,1,If(ThumbsUp<ThumbsDown,-1,0));


3. This will plot a binary indicator WITHOUT repeating the same signal -- modify it slightly for use in an Expert, by removing the INPUT statements and just set the variables: One version for a Buy or Sell "Signal" (Plot:=1), another (Plot:=2) for the "Season" TREND or HIGHLIGHTS.
-------------------------------------------------------------------------
{* Signal/Season *}
Lookback:=Input("Lookback",1,10000,1260);
Plot:=Input("1=Signal 2=Season",1,2,1);

ThumbsUp:=
Sum(Cross(C,Mov(C,90,E)),Lookback)
+Sum(Cross(C,Mov(C,120,E)),Lookback)
+Sum(Cross(C,Mov(C,150,E)),Lookback)
+Sum(Cross(C,Mov(C,180,E)),Lookback);

ThumbsDown:=
Sum(Cross(Mov(C,90,E),C),Lookback)
+Sum(Cross(Mov(C,120,E),C),Lookback)
+Sum(Cross(Mov(C,150,E),C),Lookback)
+Sum(Cross(Mov(C,180,E),C),Lookback);

Buy:=ThumbsUp>ThumbsDown;
Sell:=ThumbsUp<ThumbsDown;

{ LOGIC: Season means Signal is in effect }

init:=Cum(IsDefined(Buy+Sell))=1;
flag:=ValueWhen(1,Buy-Sell<>0 OR init,Buy)*2-1;
Signal:=If(flag<>Ref(flag,-1),flag,0);
Season:=ValueWhen(1,Buy-Sell<>0,Buy)*2-1;

If(Plot=1,Signal,Season);

me_melb  
#5 Posted : Sunday, June 5, 2011 12:37:02 AM(UTC)
me_melb

Rank: Newbie

Groups: Registered, Registered Users
Joined: 11/22/2010(UTC)
Posts: 7

Thanks Jonathan,

I've attempted to use your suggestion and found few issues.

I've attached a document with few screenshots and what I'm trying to do here. Hope this clarifies few things.

http://www.scribd.com/doc/57118145/Equis

Thanks Again for your help.
jjstein  
#6 Posted : Sunday, June 5, 2011 11:01:44 AM(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've looked at your SCRIBD document, but can't say it adds any clarity.

One thing did stand out, though -- the logical conditions you wrote into the CROSS will never occur.

Suggest you re-think what you want to do, in detail, and re-post.

What were the "few issues" you found?
jjstein  
#7 Posted : Sunday, June 5, 2011 11:25:24 AM(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)
OK, SCRIBD just had a glitch -- the rest just displayed, so I see your issues now.

Plot these as TWO separate indicators, then drag them into a new window and color them.

{* #1: CrossOver Count - Up *}
Lookback:=Input("Lookback",1,10000,1260);

Sum(Cross(C,Mov(C,90,E)),Lookback)
+Sum(Cross(C,Mov(C,120,E)),Lookback)
+Sum(Cross(C,Mov(C,150,E)),Lookback)
+Sum(Cross(C,Mov(C,180,E)),Lookback);


{* #2: CrossOver Count - Down *}
Lookback:=Input("Lookback",1,10000,1260);

Sum(Cross(Mov(C,90,E),C),Lookback)
+Sum(Cross(Mov(C,120,E),C),Lookback)
+Sum(Cross(Mov(C,150,E),C),Lookback)
+Sum(Cross(Mov(C,180,E),C),Lookback);


Should look like this.


Let's see if that works before going any further.

jjstein  
#8 Posted : Sunday, June 5, 2011 4:22:23 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)
After another look at your SCRIBD document, on reflection, another way to accomplish this would be to do an Exploration of the stocks in which you're interested. Note that "1260" is about 5 years, assuming 252 trading days/year, and that when you run the Exploration, you'll have to set Options to load at least that much PLUS the longest moving average; ie: 1260 + 180 = 1440.

Exploration: Crossover Count UP
-----------------------------------
Column A: Sum(Cross(C,Mov(C,90,E)),1260)
Column B: Sum(Cross(C,Mov(C,120,E)),1260)
Column C: Sum(Cross(C,Mov(C,150,E)),1260)
Column D: Sum(Cross(C,Mov(C,180,E)),1260);


Exploration: Crossover Count DOWN
----------------------------------------
Column A: Sum(Cross(Mov(C,90,E),C),1260)
Column B: Sum(Cross(Mov(C,120,E),C),1260)
Column C: Sum(Cross(Mov(C,150,E),C),1260)
Column D: Sum(Cross(Mov(C,180,E),C),1260)

me_melb  
#9 Posted : Sunday, June 5, 2011 4:28:09 PM(UTC)
me_melb

Rank: Newbie

Groups: Registered, Registered Users
Joined: 11/22/2010(UTC)
Posts: 7

Thanks Jonathan,

I'm at work now but will be able to try this tonight and let you know the outcome.

Cheers,

oztrader  
#10 Posted : Sunday, June 5, 2011 8:24:34 PM(UTC)
oztrader

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 7/12/2007(UTC)
Posts: 134
Location: Perth Western Australia

Here are a couple of options that may be of some help. Firstly an event counter that includes all bars loaded on the chart:- [Code] {Indicator Name = me_melb Counter1} MA:=Mov(C,90,E); Event:=Cross(MA,C); Count:=Cum(Event); Count [Code] or secondly an event counter that counts from a specified date to the last bar on the chart:- [Code] {Indicator Name = me_melb Counter2} StartDay:=Input("Day of Month",1,31,1); StartMonth:=Input("Month",1,12,1); StartYear:=Input("Year",1995,2030,2006); StartFullDate:= (StartYear)+(StartMonth/12)+(StartDay/365); FullDate:=Year()+Month()/12+DayOfMonth()/365; Start:=StartFullDate<=FullDate; MA:=Mov(C,90,E); Event:=Cross(MA,C); Count:=Cum(Start*Event); Count [Code] Cross(MA,C) gives the same result as Cross(C less than MA,C greater than MA)
me_melb  
#11 Posted : Monday, June 6, 2011 12:59:19 AM(UTC)
me_melb

Rank: Newbie

Groups: Registered, Registered Users
Joined: 11/22/2010(UTC)
Posts: 7

Thanks OzTrader and Jonathan for your help.

I've ended up with below code to run my exploration

(Sum(Cross(C,Mov(C,90,E)),1260))+(Sum(Cross(Mov(C,90,E),C),1260))
(Sum(Cross(C,Mov(C,120,E)),1260))+(Sum(Cross(Mov(C,120,E),C),1260))
(Sum(Cross(C,Mov(C,150,E)),1260))+(Sum(Cross(Mov(C,150,E),C),1260))
(Sum(Cross(C,Mov(C,180,E)),1260))+(Sum(Cross(Mov(C,180,E),C),1260))
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.