- Ev
- Topluluk
- Programlama
- Does anybody know, on an EA, how to get on a math operation ...
Advertisement
            
                
                Edit Your Comment
            
            
        Does anybody know, on an EA, how to get on a math operation
                    
                        
                            Jul 11, 2011 zamanından beri üye
                                     
                        
                        
                            38 iletiler
                        
                    
                
            
                    Dec 23, 2013 at 20:08
                                    
                
                    
                            
                                Jul 11, 2011 zamanından beri üye
                                 
                            
                            
                                38 iletiler
                            
                    
                
            
                        Does anybody know, on an EA, how to get on a math operation ( substraction to be specific) only positive numbers?
I am running into the problem that, for example, when the open price less than the close price, and the open price is smaller, the result is negative. I need this result to be positive, on other words, I need to substract ALWAYS the bigger price from the smaller price. Again, if someone knows how to do this, and is willing to share, that would be great.
Thank you
                                                            I am running into the problem that, for example, when the open price less than the close price, and the open price is smaller, the result is negative. I need this result to be positive, on other words, I need to substract ALWAYS the bigger price from the smaller price. Again, if someone knows how to do this, and is willing to share, that would be great.
Thank you
                                    To win you have to risk loss
                                
                                                                         
    
                            forex_trader_136673                    
                                    
                    
                        
                            Jun 28, 2013 zamanından beri üye
                                     
                        
                        
                            842 iletiler
                        
                    
                
             
    
                            forex_trader_168526                    
                                    
                    
                        
                            Dec 19, 2013 zamanından beri üye
                                     
                        
                        
                            126 iletiler
                        
                    
                
            
                    Dec 23, 2013 at 21:10
                                    
                
                    
                            
                                Dec 19, 2013 zamanından beri üye
                                 
                            
                            
                                126 iletiler
                            
                    
                
            
                        double MathAbs( double value) 
Returns the absolute value (modulus) of the specified numeric value.
Parameters:
value - Numeric value.
Sample:
double dx=-3.141593, dy;
// calc MathAbs
dy=MathAbs(dx);
Print("The absolute value of ",dx," is ",dy);
// Output: The absolute
 
                                                                                            
                                                            Returns the absolute value (modulus) of the specified numeric value.
Parameters:
value - Numeric value.
Sample:
double dx=-3.141593, dy;
// calc MathAbs
dy=MathAbs(dx);
Print("The absolute value of ",dx," is ",dy);
// Output: The absolute
 
    
                            forex_trader_168526                    
                                    
                    
                        
                            Dec 19, 2013 zamanından beri üye
                                     
                        
                        
                            126 iletiler
                        
                    
                
            
                    Dec 23, 2013 at 21:37
                                    
                
                    
                            
                                Dec 19, 2013 zamanından beri üye
                                 
                            
                            
                                126 iletiler
                            
                    
                
            ahuruglica posted:
Multiply with -1
😄
multiplying by negative one will only invert the negative or positive sign.
similar to doing a zero minus whatever your number is.
ie, if i have a variable X and i want to invert it...
x=0-x;
this will invert the sign, similar to multiplying by negative one.
the MathAbs function returns the absolute value of a signed number, whether it is positive or negative.
ie, xx=MathAbs(x);
happy coding.
                    
                        
                            Nov 21, 2011 zamanından beri üye
                                     
                        
                        
                            1601 iletiler
                        
                    
                
            
                    Dec 27, 2013 at 10:55
                                    
                
                    
                            
                                Nov 21, 2011 zamanından beri üye
                                 
                            
                            
                                1601 iletiler
                            
                    
                
            
                        A= MathAbs(1.3800) = 1.3800
B= MathAbs(-1.3810) = 1.3810
So if A > B then A - B else B - A = 1.3810 - 1.3800 = 10 pips
                                                            B= MathAbs(-1.3810) = 1.3810
So if A > B then A - B else B - A = 1.3810 - 1.3800 = 10 pips
                    
                        
                            Jul 11, 2011 zamanından beri üye
                                     
                        
                        
                            38 iletiler
                        
                    
                
            
                    Dec 27, 2013 at 23:31
                                    
                
                    
                            
                                Jul 11, 2011 zamanından beri üye
                                 
                            
                            
                                38 iletiler
                            
                    
                
            
                        Thanks to all for the answer. I do not think the multipling by -1 will do as this will only work if the result is negative, however, what is the result is positive? then, the multiplication's result would be negative
                                                                                            
                                                            
                                    To win you have to risk loss
                                
                                                                        
                    
                        
                            Jul 11, 2011 zamanından beri üye
                                     
                        
                        
                            38 iletiler
                        
                    
                
            
                    Dec 27, 2013 at 23:31
                                    
                
                    
                            
                                Jul 11, 2011 zamanından beri üye
                                 
                            
                            
                                38 iletiler
                            
                    
                
            
                        Thank you, Crazytrader!
                                                                                            
                                                            
                                    To win you have to risk loss
                                
                                                                         
    
                            forex_trader_136673                    
                                    
                    
                        
                            Jun 28, 2013 zamanından beri üye
                                     
                        
                        
                            842 iletiler
                        
                    
                
            
                    Dec 28, 2013 at 12:08
                                            
                                        (Dec 28, 2013 at 12:09 düzenlendi)
                                    
                                    
                
                    
                            
                                Jun 28, 2013 zamanından beri üye
                                 
                            
                            
                                842 iletiler
                            
                    
                
            
                        It was a little joke cause it remembered me primary school, and it was a math solution for many mathematical problems.
But it can work:
if A-B<0 then (A-B)*-1
if A-B>=0 then A-B
cheers
                                                            But it can work:
if A-B<0 then (A-B)*-1
if A-B>=0 then A-B
cheers
                    
                        
                            Jul 11, 2011 zamanından beri üye
                                     
                        
                        
                            38 iletiler
                        
                    
                
            
                    Dec 29, 2013 at 03:29
                                    
                
                    
                            
                                Jul 11, 2011 zamanından beri üye
                                 
                            
                            
                                38 iletiler
                            
                    
                
            
                        Thank you ahuruglica
                                                                                            
                                                            
                                    To win you have to risk loss
                                
                                                                         
        
            *Ticari kullanım ve istenmeyen e-postalara müsamaha gösterilmez ve hesabın feshedilmesine neden olabilir.
        
        
                
                
                    İpucu: Bir resim/youtube urlsi yayınlamak, onu otomatik olarak gönderinize gömer!
                
            
            
                
                
                    İpucu: Bu tartışmaya katılan bir kullanıcı adını otomatik olarak tamamlamak için @ işaretini yazın.
                
            
         
 
                                         
                                     
                             
 
     
     
     
                                 
                                 
                                 
                                     
