OmniTrader Professional Forum OmniTrader Professional Forum
forums calendars search
today this week
 
register logon control panel Forum Rules
You are currently browsing as a guest.
You should logon to access more features
A Self-Moderated Community - ALL MEMBERS, PLEASE READ!
Vote for Members who contribute the most to your trading, and help us moderate content within the Forums.


  Current location        Thread information  
OmniTrader Professional Forum
OmniLanguage Discussion
OL for Crossing above or Crossing below
Last Activity 6/7/2019 4:35 PM
7 replies, 398 viewings

Jump to page : 1
Now viewing page 1 [25 messages per page]
 
back reply
Printer friendly version

^ Top
Daniel Wilson

Member
25
Posts: 41

Joined: 3/7/2006
Location: Moses Lake, WA

User Profile
 
Subject : OL for Crossing above or Crossing below
Posted : 12/26/2018 9:22 AM
Post #30216

Does anyone have an OmniLanguage code for when an indicator is crossing below or crossing above a value? All I can find now is > or < but not the specific act of "crossing" above or below the value.

-Daniel Wilson


^ Top
Jim Dean

Sage
20001000100100
Posts: 3209

Joined: 3/13/2006
Location: L'ville, GA

User Profile
 
Subject : RE: OL for Crossing above or Crossing below
Posted : 12/26/2018 9:29 AM
Post #30217 - In reply to #30216

Hi, Daniel

You need to do two tests ... the condition for the prior bar vs the condition for the current bar. For example:

if C[1] < SMA(20)[1] and C > SMA(20) then
... code for long crossover actions
elseif C[1] > SMA(20)[1] and C < SMA(20) then
... code for short crossover actions
end if


[Edited by Jim Dean on 12/26/2018 9:30 AM]

^ Top
Daniel Wilson

Member
25
Posts: 41

Joined: 3/7/2006
Location: Moses Lake, WA

User Profile
 
Subject : RE: OL for Crossing above or Crossing below
Posted : 12/27/2018 3:51 PM
Post #30218 - In reply to #30216

Thank you Jim!
^ Top
beech pilot

New User

Posts: 3

Joined: 11/1/2018
Location: Visalia

User Profile
 
Subject : RE: OL for Crossing above or Crossing below
Posted : 12/30/2018 10:08 AM
Post #30219 - In reply to #30216

hello say i wanted rsi(14) crossing above 0 . how would i write that in a formula for a filter
^ Top
Jim Dean

Sage
20001000100100
Posts: 3209

Joined: 3/13/2006
Location: L'ville, GA

User Profile
 
Subject : RE: OL for Crossing above or Crossing below
Posted : 12/30/2018 10:17 AM
Post #30220 - In reply to #30217

Use the same formula I gave initially, but substitute RSI(14) for "C", and 0 for "SMA(20)" and for "SMA(20)[1]" (since the value 0 is a constant that doesn't use the [n] syntax to reference it's value from n bars ago)

... I suggest you study the formula and think about how it works, so that you can solve similar problems, or simple variations of them on your own in the future ... reason: I think it's *very* important for traders to understand the "whys" and "hows" of their methodology, whenever possible.

[Edited by Jim Dean on 12/30/2018 10:21 AM]

^ Top
beech pilot

New User

Posts: 3

Joined: 11/1/2018
Location: Visalia

User Profile
 
Subject : RE: OL for Crossing above or Crossing below
Posted : 12/30/2018 11:16 AM
Post #30221 - In reply to #30216

ok what about if it is = 0 , sorry i am just not that great with omni language, i am just trying to get a column in the focus list as to when the BasingInd (250,2,14) is equal to the zero line or crossing the zero line
Attached file : 12-30-2018 9-13-28 AM.png (8KB - 19 downloads)

^ Top
Manfred

Veteran
100100
Posts: 210

Joined: 4/2/2006
Location: South Africa

User Profile
 
Subject : RE: OL for Crossing above or Crossing below
Posted : 1/12/2019 10:05 AM
Post #30246 - In reply to #30221

Hi,

JD explained the concept just fine but being new am guessing you're looking for someone to help connect a few more of the dots :-)

I dont have BasingInd() on my system so cannot test with that specifically. Also your initial example of RSI contradicts your later question of 0 crossing. RSI in its normal format ranges between 0 and 100 so you wont get zero crossings with that. Something like MACD indicator however, does have both positive and negative values so I'll use this for my worked example.

Thus to show a zero crossing with MACD on your focus list do something like this:

Right mouse click in focus list -> Add Omniscript column

Give it a name - e.g. MACDzerocrossing or whatever you wish to call it

In the Formula text box enter the Boolean condition you wish to test validity for. e.g. for a zero crossing from the downside to the upside and vice versa you'd need something like.

( MACD(12,26) > 0 AND MACD(12,26)[1] >= 0 ) OR ( MACD(12,26) < 0 AND MACD(12,26)[1] <= 0 )

In your case you probably just need to replace all instances of my MACD(12,26) above with your BasingInd(250,2,14) and in theory it should work.

Anyway getting back to the MACD example, if you look at the attached png, you will see a 0 in the Omniscript column in the focuslist. This means the condition is true for the current bar. If it was false then the column would show -1. You can corroborate this by adding the same indicator to a chart and reading the value as shown on the example png.

Assuming you use EOD daily data, I'll use the example of "today" and "yesterday" [1] below. For RT data substitute these terms with "current bar" and "previous bar", respectively.

In English what this is doing is checking whether today's value of the indicator MACD(12,26) is greater than > 0 AND also whether yesterday's value for the indicator was greater than or equal to >=0
This fulfils the condition when the indicator crosses from below to *above* the 0 line.
However, since the indicator could also conceivably cross from above to *below* the zero line you'll need to check for this too. This is the second part of the condition after the OR statement. You put OR there because you want either of the conditions to be valid and dont care which one - its a zero crossing either way.
The rest of the condition is simply the reverse logic to the previous. i.e. you swap around the < and <= operators for the alternative crossover condition.
You then encapsulate/group each check condition in additional parentheses ( ) so that each side of the OR operand is evaluated in full before the other side of the OR is tested for.

In pseudocode it implies this:

(Condition 1 part a AND Condition 1 part b) OR (Condition 2 part a AND Condition 2 part b)

Stated another way:

( Indicator value today >0 AND Indicator value yesterday[1] >=0 ) OR ( Indicator value today <0 AND Indicator value yesterday[1] <=0 )

You will get invalid results on a zero crossing if you don't use this approach to group the logic statements.

Hope this helps

Cheers

[Edited by Manfred on 1/12/2019 12:53 PM]

Attached file : Add-Omniscript-focus-list-condition-column.png (143KB - 23 downloads)

^ Top
Manfred

Veteran
100100
Posts: 210

Joined: 4/2/2006
Location: South Africa

User Profile
 
Subject : RE: OL for Crossing above or Crossing below
Posted : 1/12/2019 10:27 AM
Post #30247 - In reply to #30246

If it crucial to know when the condition is equal in addition to the crossover conditions simply add an additional OR statement to the condition formula. In my worked example that would be.

( MACD(12,26) > 0 AND MACD(12,26)[1] >= 0 ) OR ( MACD(12,26) < 0 AND MACD(12,26)[1] <= 0 ) OR MACD(12,26) = 0
Jump to page : 1
Now viewing page 1 [25 messages per page]
back reply

Legend    Action      Notification  
Administrator
Forum Moderator
Registered User
Unregistered User
E-Mail this thread to a friend
Toggle e-mail notification


Nirvana Systems
For any problems or issues please contact our Webmaster at webmaster@nirvsys.com.