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
OmniScripts
omniscript for Trix moving average
Last Activity 6/22/2018 4:46 AM
15 replies, 982 viewings

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

^ Top
Paul K

Member

Posts: 8

Joined: 6/11/2007
Location: Lake Elsinore, Ca.

User Profile
 
Subject : omniscript for Trix moving average
Posted : 10/23/2015 8:59 AM
Post #24686

I would like to write an omniscript for the moving average of an indicator, in this case, the Trix(6). I would also hope to understand the reasons for the script format so I can use it to write scripts for other indicators, such as the ADX. If anyone could help with this, I would really appreciate it.
^ Top
Jim Dean

Sage
2000100010025
Posts: 3142

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

User Profile
 
Subject : RE: omniscript for Trix moving average
Posted : 10/23/2015 9:07 AM
Post #24687 - In reply to #24686

An omniscript formula is usually used to define a rule which evaluates as true or false. So, you need to have a "relational" operator ( >, <, =, >=, <=, <> ) as part of the formula, comparing one value to another value. The moving average of a function is easy to represent: you must choose what kind of moving average to use, and what function do you want to smooth out with the moving average. Then, you need to decide what value you will compare that smooth function to, using the relational operator. The value that you compare it to can be a scalar (i.e. a simple number), or can be another function, such as an un-smoothed version of the same function. Here is an example:

Sma(trix(6),5) < trix(6)


[Edited by Jim Dean on 10/23/2015 9:10 AM]

^ Top
Paul K

Member

Posts: 8

Joined: 6/11/2007
Location: Lake Elsinore, Ca.

User Profile
 
Subject : RE: omniscript for Trix moving average
Posted : 10/23/2015 9:23 AM
Post #24688 - In reply to #24687

Thanks. That's a good overview. Any chance you can help me write the script for an indicator of the 3 period simple moving average of the Trix(6)?
^ Top
Jim Dean

Sage
2000100010025
Posts: 3142

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

User Profile
 
Subject : RE: omniscript for Trix moving average
Posted : 10/23/2015 9:33 AM
Post #24689 - In reply to #24688

1. I can't recall if Trix() is a native function of OT (not at my PC now). If it's not, then you need to vet this definition: "The TRIX function calculates the percent rate-of-change of a triple exponentially smoothed moving average of the security's closing price." (copied from tradestation docs). If that is The ref you mean, then the trix needs two params, not just one - first, for the ema's, and second for the rate of change offset. If the ema periods = 6 and rate of change pds =10 (both arbitrary) then trix(6,10) by the above def would be:
( ema(ema(ema(6),6),6) - ema(ema(ema(6),6),6)[10] ) / ema(ema(ema(6),6),6)[10] * 100

2. You need to define what the "relational test" you want should be - ie what comparison operator and what the sma(trix) is to be compared to.

[Edited by Jim Dean on 10/23/2015 9:34 AM]

^ Top
Paul K

Member

Posts: 8

Joined: 6/11/2007
Location: Lake Elsinore, Ca.

User Profile
 
Subject : RE: omniscript for Trix moving average
Posted : 10/23/2015 9:55 AM
Post #24690 - In reply to #24686

If by native function, you mean a standard indicator within OT, it is. I've written omniscript for systems and stops, but the components of the script for an indicator in the 2 samples within the omnilanguage IDE seem a bit complicated for me. If at some point you have a chance to write the indicator script for this, I can use it as a template for other MA's of indicators. Thanks.
^ Top
Jim Dean

Sage
2000100010025
Posts: 3142

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

User Profile
 
Subject : RE: omniscript for Trix moving average
Posted : 10/23/2015 10:00 AM
Post #24691 - In reply to #24690

See my first post. I provided a sample. But you have not yet told me what you want to compare it to - I just assumed it was the unsmoothed version.

You first need to write out in English the rule that you want expressed in OScript.

You have not yet said what you want to use the script for - OScan, filter block, ColorChart, setup, Exit, or quick indicator, etc. The QI is the only one that does not need a relational operator.

Unless you provide more detailed info, there's not much more I can help you with, short of a very very long tutorial on a whole lot of aspects of OT - nirvana provides plenty of those.
^ Top
Paul K

Member

Posts: 8

Joined: 6/11/2007
Location: Lake Elsinore, Ca.

User Profile
 
Subject : RE: omniscript for Trix moving average
Posted : 10/23/2015 10:11 AM
Post #24692 - In reply to #24686

My intent is to use the moving average on a chart in the indicator pane with the trix, just as a moving average on a price chart shows crossover points. Additionally, I hope to be able to use it to create color charts and in omnilanguage sytems to add to strategies.
^ Top
Jim Dean

Sage
2000100010025
Posts: 3142

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

User Profile
 
Subject : RE: omniscript for Trix moving average
Posted : 10/23/2015 10:13 AM
Post #24693 - In reply to #24692

Sma(trix(6),3)
^ Top
Paul K

Member

Posts: 8

Joined: 6/11/2007
Location: Lake Elsinore, Ca.

User Profile
 
Subject : RE: omniscript for Trix moving average
Posted : 10/23/2015 10:50 AM
Post #24694 - In reply to #24686

Sorry, I just talked to OT tech support, and after they looked at your threads, they mentioned to me that I used the wrong term in my request. What I need is the formula in omnilanguage, as I currently have OT2011 which doesn't have the quick indicators. Can you write the formual in Omnilanguage?
^ Top
Jim Dean

Sage
2000100010025
Posts: 3142

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

User Profile
 
Subject : RE: omniscript for Trix moving average
Posted : 10/23/2015 10:52 AM
Post #24695 - In reply to #24694

#indicator
Return Sma(trix(6),3)
^ Top
Paul K

Member

Posts: 8

Joined: 6/11/2007
Location: Lake Elsinore, Ca.

User Profile
 
Subject : RE: omniscript for Trix moving average
Posted : 10/23/2015 10:59 AM
Post #24696 - In reply to #24686

I tried that and t wouldn't plot on the chart. Did I miss something?
^ Top
Jim Dean

Sage
2000100010025
Posts: 3142

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

User Profile
 
Subject : RE: omniscript for Trix moving average
Posted : 10/23/2015 11:06 AM
Post #24697 - In reply to #24696

Oops

#indicator
Plot("ST", Sma(trix(6),3))
Return 0

Or more versatile:

#indicator
#param "TrPds", 6,2,18
#param "SmPds",3,2,5
Dim Trx, SmTrx as single
Trx = trix(Trpds)
SmTrx = sma(trx,smpds)
Plot("trx", trx, green)
Plot("SMtrx , Smtrx, red)
Return SmTrx
^ Top
Paul K

Member

Posts: 8

Joined: 6/11/2007
Location: Lake Elsinore, Ca.

User Profile
 
Subject : RE: omniscript for Trix moving average
Posted : 10/23/2015 11:31 AM
Post #24698 - In reply to #24686

The first one worked perfectly. Thank you. When I tried the more complicated one, the 2nd "plot" line came back with "missing double quote" when I compiled.
^ Top
Jim Dean

Sage
2000100010025
Posts: 3142

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

User Profile
 
Subject : RE: omniscript for Trix moving average
Posted : 10/23/2015 11:33 AM
Post #24699 - In reply to #24698

Exersize for the student :-)

It's easy to fix if you study it. Hint: double quotes must be in pairs.

I composed it on my iPhone.

[Edited by Jim Dean on 10/23/2015 11:36 AM]

^ Top
Paul K

Member

Posts: 8

Joined: 6/11/2007
Location: Lake Elsinore, Ca.

User Profile
 
Subject : RE: omniscript for Trix moving average
Posted : 10/23/2015 11:42 AM
Post #24700 - In reply to #24686

Got it! Thanks for your help.
^ Top
Nathan Dunham

Member

Posts: 22

Joined: 3/1/2006
Location: Austin, TX

User Profile
 
Subject : RE: omniscript for Trix moving average
Posted : 10/23/2015 11:49 AM
Post #24701 - In reply to #24700

Hi Paul,

Here is a website with more examples of OmniLanguage code you can use as examples. You can also add them to your Library of indicators and systems.

http://www.omnitrader.com/prosi/

Regards,

Nathan Dunham
Nirvana Sales/Support
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.