Forex



Go Back   Forex Trading > Discussion Areas > Metatrader 4
Forex Forum Register More recent Blogs Calendar Advertising Others Help






Register
Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.

From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.

Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
  • Elite Section
    Get access to private discussions, specialized support, indicators and trading systems reported every week.
  • Advanced Elite Section
    For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
See more

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 02-26-2007, 09:17 PM
Junior Member
 
Join Date: Jan 2007
Posts: 26
echnaton is on a distinguished road
Although both MA lines are equal Orders where made

Hello,

although both Moving Average lines are equal an order where send by my script. But I donīt wants this.

Here some code:

PHP Code:
//Crossed function for example
int Crossed (double line1 double line2)
{
      static 
int last_direction 0;
      static 
int current_direction 0;
            
      if(
line1==line2)return (0); 

      if(
line1>line2)current_direction 1//up
      
if(line1<line2)current_direction 2//down
      
      
if(current_direction != last_direction//changed 
      
{
            
last_direction current_direction;            
            return (
last_direction);
      }
      else
      {
            return (
0);
      }
}


//Call of the function inside start() 

SEma iMA(NULL,0,ShortEma,0,MODE_EMA,PRICE_CLOSE,1); 
LEma iMA(NULL,0,LongEma,0,MODE_EMA,PRICE_CLOSE,1);  

   
int isCrossed  0;
   
isCrossed Crossed(SEma,LEma); 


if(
isCrossed == 1)
   {
OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,Ask-StopLoss*Point,Ask+TakeProfit*Point,Name_Expert,MAGIC,0,Green);
return(
0);
   }  
         
   if(
isCrossed == 2)
   {   
OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,Bid+StopLoss*Point,Bid-TakeProfit*Point,Name_Expert,MAGIC,0,Red);
return(
0);
   } 
Although both Moving Average lines are equivalent high often simply an order are made.

I understand that not, can me someone help?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #2 (permalink)  
Old 02-26-2007, 11:12 PM
ralph.ronnquist's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 297
ralph.ronnquist is on a distinguished road
Try replacing
PHP Code:
if ( line1 == line2 ) return ( ); 
with
PHP Code:
if ( MathAbsline1 line2 ) < Point ) return ( ); 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #3 (permalink)  
Old 03-16-2007, 07:36 PM
Junior Member
 
Join Date: Jan 2007
Posts: 26
echnaton is on a distinguished road
Hello,

I have test it and your tip was right, thank you very much!

but I donīt now why

PHP Code:
if ( line1 == line2 ) return ( ); 
was not right.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #4 (permalink)  
Old 03-16-2007, 11:56 PM
ralph.ronnquist's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 297
ralph.ronnquist is on a distinguished road
It has to do with "precision".

The double number representation is 64 bits, which makes it very high precision (though not mathematically exact).
Lines on the screen are limited by the screen resolution, which is of the order of 10 bits.
Obviously when plotting two double numbers onto the screen, you might need to put them on the same pixels even if the numbers are different.

As a rule of thumb, double numbers that are computed by different calculations very rarely end up equal, even when you think they should; very, very small differences (down to 20:th decimal or so), but enough for "==" to say false.

By your test, the lines were required to be equal to the highest precision offered by the representation, while by my suggestion, they are only required to be equal to a Point precision.

Perhaps you would really want "Point*Period/6" or something since the idea of MA lines "being equal" might also depend on the chart time frame; on an hourly time frame, perhaps being within 10 pips of each other is equal enough to be considered equal?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
modify orders and close pending orders bkgridley Questions 8 05-23-2007 10:49 PM
Is 1 lot in 1:10 equal to 0.1 lot in 1:100 leverage ? mpforex Metatrader 4 3 03-24-2007 11:06 AM
Need an indicator made hidethereal Indicators - Metatrader 4 12 09-28-2006 07:10 PM
What's going on? Demo shows I made a *ton* of money ycomp Metatrader 4 2 03-31-2006 02:01 AM


All times are GMT. The time now is 12:41 AM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.