Rank: Newbie
Groups: Registered, Registered Users Joined: 4/2/2009(UTC) Posts: 6
|
Basically what I am trying to do is create an indicator, in this case the difference between the +DI and -DI, that is can be different colors when rising and falling. Much like a price oscillator, I would want the indicator to be able to be both colors while above and below zero (a bar that is rising but below zero could be green or a bar that is falling and below above zero could be red). Everything I've been trying so far hasn't worked and it is entirely possible that this can't be done with MetaStock, but if you guys have any suggestions or solutions I'd greatly appreciate it. Thanks a lot
|
|
|
|
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)
|
hi ehhitch,
Welcome to the Forum.
Please post the code you've been trying and I am sure someone will assist you to fix the problems to achieve your desired result.
wabbit [:D]
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users Joined: 4/2/2009(UTC) Posts: 6
|
Sorry I should have posted that originally. Here's what I've got so far:
x:= ROC( DI(), 1, $); y:= ROC( x, 1, $); If(y>=0, x, 0); If(y<0, x, 0)
It ends up giving me two indicators that make one very broken histogram. Also, anything above zero is one color and anything below zero is another. If there is a way to make color conditional to the direction of the change in relation to the previous measurement (in this case the DI from the day before) that would be best. Thanks
|
|
|
|
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)
|
Here's one take on the simple version of colouring a chart: ----------------------------------- x:= ROC( DI(), 1, $); plus:=x*(x>0); minus:=x*(x<0); {histograms} 0; {blue} plus; {green} minus; {red} -----------------------------------
I think this is more what you're after though? -----------------------------------
x:= ROC( DI(), 1, $); yp := ValueWhen(1,x>0,x) > ValueWhen(2,x>0,x); yn := ValueWhen(1,x<0,x) < ValueWhen(2,x<0,x); {histograms} 0; {blue} x*(x>0)*(yp>0); {lightgreen} x*(x>0)*(yp=0); {darkgreen} x*(x<0)*(yn>0); {darkred} x*(x<0)*(yn=0); {red} -----------------------------------
Hope this helps. wabbit [:D] P.S. Don't forget to save the chart as a template after adjusting the colours so you don't have to do it every time!
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users Joined: 4/2/2009(UTC) Posts: 6
|
Thank you, that helps a lot. My only question would be is there any way to set x in relation to the previous day's data as opposed to having it related to 0? I don't have the most advanced knowledge of MetaStock formulas but I feel like an inequality that relates today's data to the previous day's data should be possible. Then I could use the histogram coloring scheme you provided to color code it to my preference. Thank you very much for your continued 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)
|
Sorry, I don't understand the problem? Can you provide more detail?
wabbit [:D]
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users Joined: 4/2/2009(UTC) Posts: 6
|
I'm sorry ignore that last post; I'm not even sure what I was going for. The second formula you provided me, the one that uses the ValueWhen function, actually accomplishes what I was trying to do. I am unfamiliar with that formula and I was wondering if you could explain the purpose of the inequality in the function because when I tried recreating similar indicators I was unsuccessful. Thanks a lot.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 11/7/2005(UTC) Posts: 602
|
Think of ValueWhen(A,B,C) as going backwards on the chart and picking out the "A"th occurrence from today of "C" when the calculation or value of "B" is true. I had to write a test formula to convince myself of what it is doing, do one with moving averages.
|
|
|
|
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.