Rank: Newbie
Groups: Registered, Registered Users Joined: 3/1/2012(UTC) Posts: 5
|
Can somebody help with the formula for the Ned Davis / Valueline 4% swing method.
A buy is given when the valueline index rises 4% from a previous valley on a weekly close. Note this is a cumulative rise. This does not have to take place in 1 week.
A sell is given when the weekly close of the value line composite drops by 4% or more from any weekly peak.
Here is the security Security("C:\Stock Market Indicators\vindex",C)
Thank you in advance for any help with this formula!
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
Code:
tr:={enter your trough or valley definition here};
pk:={enter your peak definition here};
data:=Security("C:\Stock Market Indicators\vindex",C);
buy:=data > valuewhen(1,tr,data)*1.04;
sell:=data < valuewhen(1,pk,data)*0.96;
{plot}
buy;
sell;
I will leave up to you, how you're going to decide on what is a peak and trough and to latch the signals to avoid repetitive signals etc. wabbit [:D]
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 10/29/2004(UTC) Posts: 1,394 Location: Glastonbury, CT
Was thanked: 2 time(s) in 2 post(s)
|
I would do a search under Zweig 4% Rule
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users Joined: 3/1/2012(UTC) Posts: 5
|
Here is the formula I found
If(PREV = 1,
If(CLOSE < HighestSince(1,PREV <> 1,CLOSE)*.96,
-1,PREV),
If(PREV = -1, If(CLOSE>LowestSince(1,PREV <> -1,CLOSE)*1.04,
+1,PREV),
If(PREV = 0, If(CLOSE>Lowest(CLOSE)*1.04,
+1,
If(CLOSE
-1,
How do I incorporate the following security into this formula security("c:\stock market indicators\vindex",c);
Thanks for the help!
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users Joined: 3/1/2012(UTC) Posts: 5
|
My programing skills are week and I wanted to see if anyone has any suggestions. I am getting a message that this operator is not being used correctly and the cursor is blinking on the forward slash on the last line. Do I need to take that out or do I need to something else?
Thanks for any help you can provide!!
b1:=security("c:\stock market indicators\vindex",c);
If(PREV = 1, If(b1 < HighestSince(1,PREV <> 1,b1) *.96, -1,PREV), If(PREV = -1, If(b1>LowestSince(1,PREV <> -1,b1)*1.04, +1,PREV), If(PREV = 0, If(b1>Lowest(b1)*1.04, +1, If(b1<Highest(b1)*.96, -1, PREV)),PREV)))</highest(b1)*.96
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
What do you think the last line of code says? Golf4 wrote:... or do I need to something else?
You need to spend a lot more time getting the basics of programming correct. Please do your own homework and read the MS User Manual and do the exercises in the free Equis Formula Primer. It isn't hard and you don't have to be a professional code-cutter to make sense of the simple MS scripting language; it will help you to understand why "</" is not a recognized operator. wabbit [:D]
|
|
|
|
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)
|
Golf -- That code is a serious contender for "worst of the year". It's use of eight (8) PREV statements absolutely guarantees it will be so slow as to be unusable. Take Henry's search advice, and read the results more carefully. There are no peaks or valleys, this is merely a 4% rise or drop in the weekly close. This indicator REQUIRES that you set your chart periodicity to WEEKLY. Code:b1:=Security("c:\stock market indicators\vindex",C);
x:=Input("Weekly % change:",0.1,10,4);
y:=Input("Period",1,52,1);
If(ROC(b1,y,%)>=x,1,If(ROC(b1,y,%)<=-x,-1,0));
FUTURE NOTE: HOW TO POST CODE. Put your code between these two lines, but take out the space after the first asterisk: * code* Put your code here. * /code* So it looks like this:
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 1/20/2012(UTC) Posts: 152
Was thanked: 1 time(s) in 1 post(s)
|
Hi Golf4,
I want to establish myself as a serious programmer here, so here is the simplest code for what you are asking:
Code:
If(C>Ref(C,-1)*1.04,1,If(C
It plots exactly like jjstein's code above.
Am I great or what?
Ed.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 1/20/2012(UTC) Posts: 152
Was thanked: 1 time(s) in 1 post(s)
|
Hi Golf4,
I want to establish myself as a serious programmer here, so here is the simplest code for what you are asking:
Code:
If(C>Ref(C,-1)*1.04,1,If(C
It plots exactly like jjstein's code above.
Am I great or what?
Ed.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 1/20/2012(UTC) Posts: 152
Was thanked: 1 time(s) in 1 post(s)
|
Trouble.
The browser eats from code, although I used
If ( C > Ref ( C, -1 ) * 1.04 , 1 , If ( C < Ref ( C, -1 ) * 0.96 , -1 , 0 ) )
No spaces though.
Ed.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 1/20/2012(UTC) Posts: 152
Was thanked: 1 time(s) in 1 post(s)
|
test1
If(C>Ref(C,-1)*1.04,1,If(C[
]
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 1/20/2012(UTC) Posts: 152
Was thanked: 1 time(s) in 1 post(s)
|
Here it is in plain English, because my browser does strange things:
If ( Close is greater than Close yesterday times 1.04, write 1, or if ( Close is smaller than close yesterday times 0.96, write -1, otherwise write 0 ) )
If(C>Ref(C,-1)*1.04,1,If(C[
]
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
Even easier to code and faster to execute, is to remove the If() statements completely: Code:upper:=ref(C,-1)*1.04;
lower:=ref(C,-1)*0.96;
test:=(C>upper)-(C<lower);
{plot}
test;
wabbit [:D]
|
|
|
|
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.