Optuma Forums › Optuma Scripting › A few scripting questions
Tagged: OPTEX
- This topic has 7 replies, 5 voices, and was last updated 2 years ago by
Darren.
-
AuthorPosts
-
January 11, 2021 at 10:54 pm #61987
Jeffrey
- Topics: 18
- Replies: 10
- Posts: 28
Hello everyone!
I am new to Optuma and have a few questions that I could not find answers to via the free instructional videos. I apologize if I have overlooked them! If you have a link that you could direct me to or point me in the right general direction, I would greatly appreciate it!!1. I would like to use the OPTEX() code in my script, but I only want the signal to fire when the BQ line is within the blue or red areas.
2. Is there a way to have the “Showbar” arrow appear on the first or last day of retrograde only? As opposed to multiple arrows showing the duration of the retrograde period? Also, is it possible to generate a signal X amount of days after mercury turns direct or even signal at the end of the Orb shadow?
3. Is there a way to have the signal WAIT to be generated until the “low of the high bar” has been exceeded (assuming we’re planning on going short), after certain criteria have been met? For example, Moon reaches its maximum latitude then waits to be trigged by the violation of the “low of the high bar”.
Thank you!!
JeffJanuary 12, 2021 at 12:47 pm #61993Mathew
- Topics: 41
- Replies: 2,042
- Posts: 2,083
Hi Jeff,
Re 1. Each of those levels are available using the ” dot notation” whenever a function has multiple outputs, enter a “.” and you will see the options available.
In this case I also want to use a variable as it is more efficient.So this would be the code to signal when the Black Ratio line enters into the red zone.
123456// store all the Optex results in a variableo1 = OPTEX();// do we cross into the red zoneo1.Ratio CrossesAbove o1.25UpperRe 2 and 3. Remember that we have a separate group for Astro scripts. In this case your questions are more general so I’ll answer them here.
Re 2: When you have a true false condition, that is stored as 1 for true and 0 for false. So something you can do when you want to signal on the first bar is use the ChangeTo operator to find when the result ChangeTo 1
eg If you were looking at Higher Bars —something which could be true multiple times in a row — and you wanted to capture only the first higher bar.1234c1 = BARTYPES().Higher;c1 ChangeTo 1Re 3: You would use offsets. In this case you have a Higher bar and you want the last bar to be higher and this bar to have a low which is lower than the previous bar. We use square brackets to offset the data.
12345h1 = BARTYPES().Higher;l1 = LOW();(h1[1] == 1) and (l1 < l1[1])Hope that helps
Mathew
1 user thanked author for this post.
February 20, 2021 at 12:11 am #62571Jeffrey
- Topics: 18
- Replies: 10
- Posts: 28
How would you reverse this for a breach of the “high of the low bar” scenario? (triggering in for a long position). I can’t seem to wrap my head around this one.
1 user thanked author for this post.
February 20, 2021 at 10:49 pm #62581Darren
- Topics: 76
- Replies: 1,038
- Posts: 1,114
Hi Jeffrey,
Try this:
12345l1 = BARTYPES().Lower;h1 = HIGH();(l1[1] == 1) and (h1 > h1[1])1 user thanked author for this post.
July 25, 2021 at 3:22 pm #65319Andrew
- Topics: 1
- Replies: 3
- Posts: 4
I am trying to write a script and don’t know if it is possible. I have the oscillator line in MACD set at 5. I am trying to write a script that essentially says the oscillator line is ticked upwards or angled upwards and above the zero line. Does not need to cross the zero line just angled up and above it. I have tried several combinations of the following but without any success. Does anyone have any ideas to help
MACD()TYPE=oscilator BAR1=5 angled up greater than 0.00
thanks
andrew
July 26, 2021 at 8:42 am #65328Matthew
- Topics: 5
- Replies: 677
- Posts: 682
Hi,
I would use the following (i was not sure if you wanted it to be above zero for the entire sequence but that is what i have done, if the trend up can start below zero you can modify the script to suit).
1234567891011121314//Set BaseMACD V1 = MACD(DEFAULT=Oscillator, BAR1=5);//Check MACD DirectionV2 = V1 IsUp ;//5 Days of increasing valueV3 = BARSTRUE(V2, LOOKBACK=5) == 5;//MACD Above 0V4 = V1 > 0;//5 Days of MACD above 0V5 = BARSTRUE(V4, LOOKBACK=5) == 5;//ResultsV3 and V5Here is how it looks on the chart…
Green Shaded Zone == Criteria passed.Your definition of how many bars it takes to be considered an upward angle may be different to my example, however the script should give you an idea of where to start.
-
This reply was modified 2 years ago by
Matthew.
August 18, 2021 at 10:57 pm #65599Jeffrey
- Topics: 18
- Replies: 10
- Posts: 28
Hi Jeffrey,
Try this:
12345l1 = BARTYPES().Lower;h1 = HIGH();(l1[1] == 1) and (h1 > h1[1])l1 = BARTYPES().Lower;
h1 = HIGH();
(l1[1] == 1) and (h1 > h1[1])The signals are working as I specified. Thank you!
As I have ran this, I realized that I made a mistake in my description. How would I get this to give a signal upon exceeding and “closing” beyond the previous bar as opposed to just exceeding the previous bar’s price then retracing back within it’s range?August 19, 2021 at 1:18 am #65601Darren
- Topics: 76
- Replies: 1,038
- Posts: 1,114
Hi Jeffrey,
Try this:
123456l1 = BARTYPES().Lower;h1 = HIGH();c1 = CLOSE();(l1[1] == 1) and (c1 > h1[1]) -
AuthorPosts
- You must be logged in to reply to this topic.