OmniTrader Professional Forum - OmniLanguage Frequently Asked Questions
How to Check for Crossovers

^ Top
Matthew Greenslet

Posts: 2077

Joined: 2/27/2006

User Profile
 
Subject : How to Check for Crossovers
Posted : 10/8/2007 4:10 PM
Post #6855

Q: How can I check if two indicators cross each other?

A:

In order to check for crossovers you need to compare two values. You will check the prior values against the current values. If 1 bar back Level1 was below Level2 And todays value of Level1 is above Level2 then we have a crossover. You now have the logic for Level1 crossing above Level2. You can just reverse the comparison sign to check for Level1 crossing below Level2. All of our indicators you can reference prior bars by encompassing a look back in brackets.

If needed, please see the following FAQ for examples:
http://www.omnitrader.com/omnitrader/proforum/thread-view.asp?threadid=1288&posts=1

So if we had two EMAs, say a 10 period and a 40 period EMA, and we wanted to know when they cross over, the logic would look like this.

If EMA(10)[1] < EMA(40)[1] AND EMA(10) > EMA(40) then

'Add code here to preform when the 10 period EMA crosses
'to the upside of the 40

ElseIF EMA(10)[1] > EMA(40)[1] AND EMA(10) < EMA(40) then

'Add code here to preform when the 10 period EMA crosses
'to the downside of the 40

End IF




https://www.omnitrader.com/currentclients/proforum/thread-view.asp?threadid=1289&posts=1