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

Notification

Icon
Error

Options
Go to last post Go to first unread
Leverage  
#1 Posted : Monday, November 4, 2013 6:17:00 PM(UTC)
Leverage

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 1/25/2010(UTC)
Posts: 44
Location: Rome, IT

Hi guys,
I would like to apply an highlights in an expert advisor of an oscillator between 0-100.
This oscillator (i.e. stochastic, RSI, etc.) if cross the value 20 trend is long and would like to color my bars in green, but if get down from 100 to 80 the trend il down and would like to color my bars in red.

I think that is necessary PREV function to remember advisor if it is over 20 or under 80 but decreasing from 100 and I don't be able to formulate the correct syntax.

Someone can help me please?

Tnx
mstt  
#2 Posted : Tuesday, November 5, 2013 5:42:43 PM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)
Hi Leverage

Your description doesn't include much detail and I fear that what you haven't told us is more important than what you have told us. Nevertheless here's a simple piece of code that doesn't require PREV and would allow you to AND similar elements if necessary.

A:=Stoch(14,5);
BarsSince(Cross(A,20))<BarsSince(Cross(80,A));

Roy
Leverage  
#3 Posted : Wednesday, November 6, 2013 2:35:05 AM(UTC)
Leverage

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 1/25/2010(UTC)
Posts: 44
Location: Rome, IT

Thank you so much Roy,
I wrote a simple self made oscillator to detect the market trend.
I wanted to make a linear regression as an oscillator to normalize it and obtain oversold and overbought areas.
I.E.
A:=linearreg(C,14);
osc:=(A-LLV(A,14))/(HHV(A,14)-LLV(A,14))*100;
In this simple formula I research with an optimization, the two trigger levels.
With an highlights I can resolve my chart pane more simply to watching and your suggest code it's a good solution for me.
I'm not very familiar with "count bars functions" :p
Now, I try to discriminate with your advice the intermediate situation that the oscillator get down below 80 and rise up above 80 without arrive at 20 area and viceversa,

Max
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.