Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 4/30/2005(UTC) Posts: 112
|
I want to develop an Expert Advisor using Stochastic (14,3,3) based on the following:-
Issue a Buy signal right after:-
A non-crossover of %K & %D with an attempt to cross PLUS
An overbought signal of Stochastic (14,3,3) happened just earlier
Issue a Sell signal right after:-
A non-cross over %K & & %D with an attempt to cross PLUS
An oversold signal of Stochastic (14,3,3) happened just earlier
See attached pdf file. can anyone help me to develop that.
Regards,
Gary
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 4/30/2005(UTC) Posts: 112
|
It appears that no one is gonna help me..... Help please!
Gary
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 1/19/2005(UTC) Posts: 1,065 Location: Koh Pha-Ngan, Earth
Was thanked: 2 time(s) in 2 post(s)
|
Gary, the problem is that abstract or loose terms such as " an attempt to cross", are just about impossible to code. Try re-defining your request in logical terms.
jose '-)
http://metastocktools.com
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 4/30/2005(UTC) Posts: 112
|
Hi Jose,
Thanks for your note. You are right, need to define quantifyable indicator to code.
say in the following way:-
Diff=Stochastic (STO) - signal (followed by a overbought signal)
Max(diff)= the maximium of diff since preious overbought signal
Min(diff)=the minimum of diff after a Max(diff) is formed
Non-crossover:
Diff (at time X) < Max(diff) *50% and then
Diff (at time X+) > Min(diff) *120%
Similarly for previous oversold signal....
Does it make more sense?
The same way can be used to code a "non-crossover" on MACD...., right?
Gary
p/s I am not sure if I make it clear to you as I don't know the MS formula language to make it clearer .......
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 1/19/2005(UTC) Posts: 1,065 Location: Koh Pha-Ngan, Earth
Was thanked: 2 time(s) in 2 post(s)
|
|
|
|
|
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)
|
garykong wrote:Diff=Stochastic (STO) - signal (followed by a overbought signal)
Max(diff)= the maximium of diff since preious overbought signal
Min(diff)=the minimum of diff after a Max(diff) is formed
Non-crossover:
Diff (at time X) < Max(diff) *50% and then
Diff (at time X+) > Min(diff) *120%
Gary,
I have tried to write something along the lines of what I think you have tried to explain, and it didn't work....
Could you write in more verbose terms (specifically in plain language) EXACTLY what you are looking for? I will start you off:
Try:
Define the stochastic indicator, stoch(14,3) to be overbought when above 80 AND the indicator is greater than its 3 day SMA. I measure the difference between the indicator and the SMA to find the maximum (maxDiff) and minimum (minDiff) of these values only when the indicator is overbought.
To trigger a BUY signal:[list:08c12dbb14][*:08c12dbb14]the indicator must be in overbought territory, AND[*:08c12dbb14]the difference between the indicator and its SMA is less than 50% of the maximum difference, AND then the following day[*:08c12dbb14]the maxDiff value increases to more than 120% of its previous value[/list:u:08c12dbb14]
This is what I was working on, but the results I came up with didnt look like they matched your example....
wabbit :D
|
|
|
|
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)
|
The code I was working with at the time started by using some simple processes to plot a histogram of the difference betweent the Stoc(14,3) and its 3 day SMA:
---8<------------------------
{Stochastic Histogram}
st:=Stoch(14,3);
ma:=Mov(st,3,S);
Hist:=st-ma;
Hist;
---8<------------------------
Notice when the histogram is greater than zero; I found the highest value of the histogram since the value crossed above zero:
[edit - trying a couple of new things - away from original intentions, but hoping to end up there!]
---8<------------------------
{Stochastic Histogram}
{second grab}
st:=Stoch(14,3);
ma:=Mov(st,3,S);
Hist:=st-ma;
hiHist:=HighestSince(1,Hist<0,Hist);
Hist;
HiHist;
---8<------------------------
I then tried to find those bars on the histogram that were less than 50% of the hiHist and the next day made a new high of the hiHist:
[edit - still trying more new things - away from original intentions, but hoping to end up there!]
---8<------------------------
{Stochastic Histogram}
{third grab}
st:=Stoch(14,3);
ma:=Mov(st,3,S);
Hist:=st-ma;
hiHist:=HighestSince(1,Hist<0,Hist);
signal:=hist>0 AND BarsSince(hist<0)>1 AND Ref(Hist<0.5*hiHist,-1) AND hist=hihist;
Hist;
HiHist;
signal;
---8<------------------------
Can you see where I am getting lost in your logic??
wabbit :D
|
|
|
|
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)
|
{last grab until I hear back from you.... :) }
st:=Stoch(14,3);
ma:=Mov(st,3,S);
Hist:=st-ma;
hiHist:=HighestSince(1,Hist<0,Hist);
loHist:=LowestSince(1,Hist<0,Hist);
signal:=hist>0 AND BarsSince(hist<0)>1 AND Ref(Hist<0.5*hiHist,-1) AND hist>loHist*1.2;
Hist;
hiHist;
loHist;
signal*LastValue(Highest(Hist)); {autoscale signal line}
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 4/30/2005(UTC) Posts: 112
|
Hi Wabbit,
It doesn't really in the way that I need it... I will have a look and explain it in more details afterwards...
Thanks for your help and will probably need more afterwards!
Gary
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 4/30/2005(UTC) Posts: 112
|
Hi Wabbit,
I think there may be something wrong on the loHist or else....
My intentions are:-
Buy signal-
When Hist>0;
record hiHist as you might have done;
measure loHist (that should the formation of hiHist);
trigger buy signal if Hist > loHist * 1.2;
See attached pdf file.
Initially, I try to fix it, but fail, so need your help....
Gary
p/s the top indicator in the chart, "ST- NX", is the "LastValue(Highest(Hist))" that doesn't match with my intention...
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 4/30/2005(UTC) Posts: 112
|
.... forget to attach the file..
Gary
|
|
|
|
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)
|
Hate to say this gary - but I am off to work for a couple of weeks and wont get the opportunity to script the indicator you are looking for....
Why not get into the Users Manual and the Formula Primer yourself and learn just a little bit more to be able to finish this indicator yourself. If you get stuck, some of the people 'round here will assist where required.
Dont forget to post the code you use too! Pictures may say a thousand words, but its we code create/correct!
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.