Dukascopy
 
 
Wiki JStore Search Login

how detect if 2 lines cross eachother?
 Post subject: how detect if 2 lines cross eachother? Post rating: 0   New post Posted: Thu 03 Oct, 2013, 18:43 

User rating: 0
Joined: Wed 18 Sep, 2013, 18:29
Posts: 7
Location: ItalyItaly
Hi all

i'm new of visualjforex, and i have a really simple problem:
how detect when 2 EMAs cross eachother? i tried simple: " IF " (logic block) EMA1 == EMA2 , but seems it never happen (even if it cross eachother), cannot understand why. its like if it skip the moment it get equal value....

any help will be appreciated, thanks to all, bye!


 
 Post subject: Re: how detect if 2 lines cross eachother? Post rating: 1   New post Posted: Fri 04 Oct, 2013, 09:25 
Visual JForex expert at Dukascopy
User avatar

User rating: 27
Joined: Fri 03 May, 2013, 18:25
Posts: 366
Location: GermanyGermany
Greetings!

It is very rare that these two EMA's have the same value. Both indicators are irrational and if you say that you want to generate a certain signal by setting them to equal it is very seldom that this would ever happen.
You have to find 4 points to "see" a cross:
For example: EMA(40) and EMA (20);
Image

You need to check the two EMA's before and after the cross.
You can also check out the example of a SMA cross by clicking on the blue box of "strategy" after successful login in the Community.
Image


Attachments:
Strat_click.png [45.38 KiB]
Downloaded 473 times
EMA_Cross.png [52.54 KiB]
Downloaded 442 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: how detect if 2 lines cross eachother? Post rating: 0   New post Posted: Fri 04 Oct, 2013, 17:47 
User avatar

User rating: 7
Joined: Wed 04 Jul, 2012, 02:40
Posts: 109
Location: Australia, Melbourne
DLEGION,

This is the fun of codeing - you have to look at a problem and descibe it in code. For 2 lines crossing - the best way is to look at the 2 line's previous value : Line A = 100 , Line B = 200 ,,
and if the current value - Line A = 300 and line B = 250 the you can tell that they have crossed.

Example = ( LineA(prev) < LineB(prev) ) and ( LineA(now) > LineB(Now) ;

Visual Jforex is easy when you think about the above.

Enjoy

DoC


 
 Post subject: Re: how detect if 2 lines cross eachother? Post rating: 0   New post Posted: Sat 05 Oct, 2013, 09:55 

User rating: 0
Joined: Wed 18 Sep, 2013, 18:29
Posts: 7
Location: ItalyItaly
thanks for the help!
i'm not a programmer as you see, and i respect them everyday more for this job, its not easy "think in a machine way" !

thanks again, i will try your suggestions!

have a great day! :D


EDIT:
i tried it, and it works perfectly! thanks again for your help, your post was detailed and images helped a lot! thanks!
problem solved :)


 

Jump to:  

cron
  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com