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

Notification

Icon
Error

Options
Go to last post Go to first unread
underground  
#1 Posted : Friday, January 18, 2008 5:32:25 PM(UTC)
underground

Rank: Advanced Member

Groups ready for retrieval: Registered, Registered Users
Joined: 3/23/2005(UTC)
Posts: 37

I want to write an easy language indicator that has 7 conditions build into it, some are easy a few are a little more complex. But for some reason I can write some of them separately but I can not combine them all into one function. Can any one help me out with this? I will add two conditions at a time to make things easy.

Condition 1 - logic Indicator A must be greater than Indicator B and C

Indicator A

Indicator B

Indicator C

If Fml(“A”) is > fml(“B”) and fml(“C”)

Condition 2 – Add Indicator D’s Y value output must be positive and increasing in value

Note – there are 2 output values X and Y I’m looking at the Y output value in this case

Indicator D

If Fml(“A”) is > fml(“B”) and fml(“C”) {Condition 1}

Plus

If FmlVar(“D”,”Y”), > 0 and FmlVar(“D”,”Y”) > FmlVar(“D”,Y”) {Condition 2}

oztrader  
#2 Posted : Friday, January 18, 2008 6:49:57 PM(UTC)
oztrader

Rank: Advanced Member

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

Hi Underground,

Could you build the conditions as shown below?

IndicatorA:=30;
IndicatorB:=21;
IndicatorC:=14;
Condition1:=IndicatorA>IndicatorB AND IndicatorA>IndicatorC;
{If Condition1 is satisfied then value will = 1}

IndicatorD:=Variables(x,y);
Condition2:=FmlVar(IndicatorD,"Y")>0 AND FmlVar(IndicatorD,"Y")>Ref(FmlVar(IndicatorD,"Y"),-1);
{If Condition2 is satisfied then value will = 1}

7ConditionsIndicator:=(Condition1=1 and Condition2=1 AND
Condition3=1 AND .... Condition7=1);

7ConditionsIndicator; {plots indicator}

I think the only problem could be that there is a limit on the number of variables!

Cheers,

ozt

oztrader  
#3 Posted : Saturday, January 19, 2008 11:50:59 PM(UTC)
oztrader

Rank: Advanced Member

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

Hi Underground,

The last line of my previous post, as shown in red below, is incorrect!

"I think the only problem could be that there is a limit on the number of variables!"

According to the manual there is a maximum of 20 different numeric constants which may be used in each formula.

Cheers,

ozt

henry1224  
#4 Posted : Sunday, January 20, 2008 12:55:00 PM(UTC)
henry1224

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)
oz, yes there can only be 20 variables, but after you have finished using a variable, you can reuse the name of a variable to create a new value
underground  
#5 Posted : Tuesday, January 22, 2008 5:31:27 PM(UTC)
underground

Rank: Advanced Member

Groups ready for retrieval: Registered, Registered Users
Joined: 3/23/2005(UTC)
Posts: 37

henry1224 - thanks for the help, I was able to get the first two conditions to work correctly.

The next two go something like this:

Condition #3

Indicator E

Indicator F

Logic:

Indicator E and F both need to be increasing in value, or equal to previous bar

I was thinking something like this?

If(ROC(Fml("Indicator E"),1,$)>=0,1,

+

If(ROC(Fml("Indicator F"),1,$)>=0,1,

Condition #4

Indicator F

Indicator G

Logic:

Indicator F is equal to or greater than 1.0 and increasing in value, plus Indicator G is increasing in value

Not sure about condition 4

oztrader  
#6 Posted : Monday, January 28, 2008 12:15:13 AM(UTC)
oztrader

Rank: Advanced Member

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

Hi Underground,

Does "Indicator F" need to be a part of both Condition #3 and Condition #4 or can it be combined in the code for Condition #3?

Cheers,

ozt

johnl  
#7 Posted : Sunday, April 13, 2008 8:12:49 PM(UTC)
johnl

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 11/7/2005(UTC)
Posts: 602

If the indicator I want to be increasing in value doesn't change directions too fast
and is pretty smooth I use If((AA-Ref(AA,-2)>0),1,0) where AA is my indicator.
The Ref(AA,-2) looks the AA value 2 bars back. This gives me a true/false value I can
use later.

wabbit  
#8 Posted : Sunday, April 13, 2008 8:53:04 PM(UTC)
wabbit

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)
MS returns a boolean value of 1 or 0 depending on whether a condition can be expressed as true or false, so you dont need the If((AA-Ref(AA,-2)>0),1,0) it can just be written as (AA-Ref(AA,-2))>0 and it will return a value of 1 if this condition is true, 0 otherwise.

Binary values can be added together, e.g.

Code:
ma1:=Mov(C,12,S);
ma2:=Mov(C,33,S);

x:=Cross(ma1,ma2) + (C>10);

{plot}
x;


"x" will take on three possible values:
0 if the Cross() event did not happen AND the price is not greater than 10
1 if either of the Cross() event happened OR the price is greater than 10, but NOT both
2 if both of the Cross() event happened AND the price is greater than 10.

These concepts allow you to write more simple code to deal with more complex situations.


wabbit [:D]

[edit]I didn't deal with the N/A situations, but these can be easily figured out by looking at a chart with the above function plotted.

johnl  
#9 Posted : Monday, April 21, 2008 12:53:40 PM(UTC)
johnl

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 11/7/2005(UTC)
Posts: 602


Dropping all the nonessential stuff always looks better.
I keep each as a separate variable so I can easily and subtract information without
messing everthing else up. I do a lot of throwing stuff against the wall to see what sticks.
Readability is what I find difficult when I start dropping stuff like that.
For instance: take those weeky to daily indicators of Roy's. They great work but soft
coding just one that has the function (MA,RS, etc) as a variable makes it
more usable.
The new program structure would look like:
a1:= FML(I want to convert);
b1:= do date stuff
c1:= convert a1 into a standard variable
d1:= get b1 stuff and c1 stuff and do daily stuff
e1:= plot converted d1 variable.
All that embedded stuff drives me nuts. I am pretty sure it's all a conspiracy. [:)]

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.