Search | User Listing Vidsite | Calendars | Quotes
Home Page ->  OLang, OScript & OPilot -> Writing OScript Scans -> View ThreadLogon (or Register, or Join TradeTight)

You are logged in as a limited-access Guest.To join TradeTight, first read the info in the Organization & Content room, then click the link above. 

2 Chronicles 26:5 (NIV) … (Uzziah) sought God during the days of Zechariah, who instructed him in the fear of God. As long as he sought the LORD, God gave him success.


Using Custom Indicators in Scans
Jump to page : 1
Now viewing page 1 [50 msgs/pg]
Jump to room :
DonSchuman
Posted 7/18/2015 12:56 PM (#6403)
Subject: Using Custom Indicators in Scans



Veteran

Posts: 210
100100
Location:
USA: TX, Mansfield
I originally posted this question in the Nirvana forum because I was browsing for an answer and found a thread that had been started there. I am moving my portion (and Jim's reply) here because I prefer to use TradeTight.

Don

Original Post:
I have a custom indicator that I want to use in an omniscan. What is the correct syntax?

myIndicator()?
myIndicator(Return)?
myIndicator(variable)?

Transferred by Don on 7/18/2015, Original Author: Don Schuman - 7/18/2015 2:53 AM, jump to original link

Top of the page Bottom of the page
DonSchuman
Posted 7/18/2015 12:58 PM (#6404 - in reply to #6403)
Subject: Using Custom Indicators in Scans



Veteran

Posts: 210
100100
Location:
USA: TX, Mansfield
Jim's Reply:

Myindicator(Param,param,…) depending on how many #param stmts your Indic has. It will return the Return value to the script.

If your Indic has no param's then use ()

Transferred by Don on 7/18/2015, Original Author: Jim Dean - 7/18/2015 5:23 AM, jump to original link

Top of the page Bottom of the page
JimDean
Posted 7/18/2015 1:07 PM (#6405 - in reply to #6404)
Subject: Using Custom Indicators in Scans



Owner/Admin

Posts: 3806
20001000500100100100
Location:
USA: GA, Lawrenceville
Thanks, Don. Here is a more thorough explanation of it, in the Syntax Room:

http://tradetight.org/forums/thread-view.asp?tid=254#M2573
Top of the page Bottom of the page
JimDean
Posted 7/19/2015 4:58 AM (#6407 - in reply to #6405)
Subject: Using Custom Indicators in Scans



Owner/Admin

Posts: 3806
20001000500100100100
Location:
USA: GA, Lawrenceville
And, here is a long-winded followup that has to do with Boolean truth values and other nifty stuff about how the OLang indicator's return value can be used …

If the Return value from the called function is itself a true/false flag, no other Boolean operators or syntax are needed.

That is, if myindicator() returns 0, it is interpreted as "false" … if it returns -1 (or any other nonzero value), it is interpreted as "true".

Or you can combine it (as a T/F value) with other logical conditions, such as:
myindicator() And Sma(V,50) > 1e5

Final note: although myindicator() by itself is considered equiv to True for any nonzero value, there is one special case where it must be exactly -1 to be treated as "true" … that's when it is used with a "not" modifier. "not true" = "false" … "not false" = "true" … the not operator flips the sense of the answer.

If you say "not myindicator()", then if myindicator() is -1, or if it's zero, it works properly. But if myindicator() has any other nonzero value, "not myindicator()" will fail to reverse it to "false" - in that case, use "myindicator() <> 0" instead.

The reason for this has to do with zeros and ones = the binary code that all computers think in. The binary representation for "false" is 0000000… etc … which also happens to represent a numeric value of "0". Binary for "true" is 11111111… etc … which also represents a numeric value of -1.

"Not" simply toggles the binary digits between 1<> 0, so: "not 1001001" changes to "0110110".
(1001001 has a decimal value of 73, and 0110110 equals 54 … "not 73" yields 54 and vice versa.)

Clearly, more than you asked about - but I've always considered number theory and its application to computers to be interesting and useful. If you are more interested in this, Google for things like "Boolean algebra" or "Bit Masking". It has a lot to do with electronics design and is a part of math "field theory" so some of the articles you find might be sort of intense.

Here's another application of it that might intrigue you:
OLang is restricted to a single, single-precision return value for each bar. So, we naturally conclude that there is no way to convey two or three or more pieces of info out of an OLang routine at once.

But, you can. For instance, you can use the integer portion to hold one value and the decimal portion to hold a second unrelated value, while the +/- sign can itself represent a third unrelated T/F value. Of course you need to "build" and "extract" the components of the return value carefully, using "int()" and "frac()" functions … and you need to keep in mind the reliable limit of only six full 0-9 digits in single precision - but even with those limitations, you can do a LOT using just a single number return.

Taking it further, you can actually convey FIFTEEN individual T/F distinctions, using Bit-Masking, in a single return value, since 32,767 = 111111111111111 in binary, and bit masking allows you to toggle each of those 1's individually to 0's. I've never need to do that much at once, but it's possible.

Here is a useful link with some info about converting between decimal and binary, plus a cute little converter tool - try converting 65,535 to decimal, for instance - it becomes 1111111111111111 … 16 ones - which in a "16-bit" processor is a "pure" representation of "true" - a snapshot is attached showing the math, and here is the link:
http://www.rapidtables.com/convert/number/decimal-to-binary.htm

Math can be very useful and interesting!

Attachments
Attachments image.jpg (130KB - 4 downloads)
Top of the page Bottom of the page
Jump to page : 1
Now viewing page 1 [50 msgs/pg]
( E-mail a Link | Printer Version | Search Room )

Owner of site: Jim Dean -- Forum content is confidential, and may not be distributed without written permission.