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
Operator overloading in OL?
Last Activity 7/6/2025 3:47 AM
6 replies, 1962 viewings

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

^ Top
kmcintyre

Veteran
10025
Posts: 132

Joined: 9/12/2007
Location: Valley Center, CA

User Profile
 
Subject : Operator overloading in OL?
Posted : 8/10/2021 2:59 PM
Post #31561

Many standard indicators offer mulptiple variations of parameters (signatures).

RSI(14) vs. RSI(Data, 14)
SMA(50) vs. SMA(Data, 50)
etc.

I would like to be able to pass a data series into my #indicator too!
And if I don't pass a Data series, I would like to default to the current symbol's Close.

(This is known as operator overloading...)

Is there a way to do this in OL?

Thanks

^ Top
Ryan Olson

Veteran
1002525
Posts: 170

Joined: 12/29/2006
Location: Austin, Tx

User Profile
 
Subject : RE: Operator overloading in OL?
Posted : 8/10/2021 3:04 PM
Post #31563 - In reply to #31561



Good Afternoon,

Most of our indicators and systems have the ability to do this and are indicated with a small triangle showing there are additional options.

Not every one but many. Attached is a screenshot of what to look for.




Attached file : forum.png (2KB - 188 downloads)

^ Top
Jim Dean

Sage
2000100010010010010025
Posts: 3433

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

User Profile
 
Subject : RE: Operator overloading in OL?
Posted : 8/10/2021 4:16 PM
Post #31565 - In reply to #31561

no
^ Top
kmcintyre

Veteran
10025
Posts: 132

Joined: 9/12/2007
Location: Valley Center, CA

User Profile
 
Subject : RE: Operator overloading in OL?
Posted : 8/10/2021 9:11 PM
Post #31566 - In reply to #31561

And that's what I love about OL...


^ Top
Ryan Olson

Veteran
1002525
Posts: 170

Joined: 12/29/2006
Location: Austin, Tx

User Profile
 
Subject : RE: Operator overloading in OL?
Posted : 8/10/2021 9:39 PM
Post #31568 - In reply to #31566



The answer isn't as easy as "no".

You can pass quite a few things into indicators:

For example, SMA can take SMA(50), SMA(V,50) SMA((C-H), 50) but not tuples, dictionaries but you are able to pass some information directly into indicators.

If you are building the indicator you will only be able to pass the parameters you have built in but not data series.

However, inside the indicator you are in control, you can calculate whatever you want, you have access to price, volume, read from data files and more.

As far as "true" overloading operators - this is a concept used in OOP programming and not completely implemented in OmniLang.
^ Top
Jim Dean

Sage
2000100010010010010025
Posts: 3433

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

User Profile
 
Subject : RE: Operator overloading in OL?
Posted : 8/11/2021 7:08 AM
Post #31569 - In reply to #31568

Ryan, the answer IS simply “no”.

You can only pass numeric constants into OmniLanguage routines. Period.

In fact, if you try to reassign the value of the parameter inside the OL routine, it won’t work.

It is a constant.

Otoh, all variables dim’d inside the routine are one-dimensional arrays, even though they have a “hidden” index [bar].

There are a few dozen system-reserved words such as Numrec that are constants as well.

As simple as that.
^ Top
Jim Dean

Sage
2000100010010010010025
Posts: 3433

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

User Profile
 
Subject : RE: Operator overloading in OL?
Posted : 8/11/2021 7:11 AM
Post #31570 - In reply to #31569

As to overloading …

If you define an OL indicator with three Params, then if you call it from an OScript or another OLang routine, you MUST specific exactly Three params in the call.

You cannot specify more or leas than three.

Overloading is a programming option that allows extra params to be spec’d.

Impossible in OLang.

Simple as that.
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.