| 
Rank: Advanced Member
 Groups: Registered, Registered UsersJoined: 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}    | 
    | 
             | 
            
         | 
    |  | 
        
        
        
            
        
            
            
    | 
Rank: Advanced Member
 Groups: Registered, Registered Users, Unverified UsersJoined: 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 ANDCondition3=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 | 
    | 
             | 
            
         | 
    |  | 
        
        
        
    
        
            
            
    | 
Rank: Advanced Member
 Groups: Registered, Registered Users, Unverified UsersJoined: 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 | 
    | 
             | 
            
         | 
    |  | 
        
        
        
            
        
            
            
    | 
Rank: Advanced Member
 Groups: Registered, Registered Users, SubscribersJoined: 10/29/2004(UTC)
 Posts: 1,394
 Location: Glastonbury, CT
 
 Was thanked: 3 time(s) in 3 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 | 
    | 
             | 
            
         | 
    |  | 
        
        
        
    
        
            
            
    | 
Rank: Advanced Member
 Groups: Registered, Registered UsersJoined: 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 | 
    | 
             | 
            
         | 
    |  | 
        
        
        
            
        
            
            
    | 
Rank: Advanced Member
 Groups: Registered, Registered Users, Unverified UsersJoined: 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  | 
    | 
             | 
            
         | 
    |  | 
        
        
        
    
        
            
            
    | 
Rank: Advanced Member
 Groups: Registered, Registered UsersJoined: 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.
 
 
 | 
    | 
             | 
            
         | 
    |  | 
        
        
        
            
        
            
            
    | 
Rank: Advanced Member
 Groups: Registered, Registered Users, Subscribers, Unverified UsersJoined: 10/28/2004(UTC)
 Posts: 3,112
 Location: Perth, Western Australia
 
 Was thanked: 17 time(s) in 17 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. | 
    | 
             | 
            
         | 
    |  | 
        
        
        
    
        
            
            
    | 
Rank: Advanced Member
 Groups: Registered, Registered UsersJoined: 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.