Optuma Forums › Optuma Scripting › thestrat
Tagged: thestrat
- This topic has 7 replies, 2 voices, and was last updated 10 months ago by
Darren.
-
AuthorPosts
-
June 25, 2021 at 12:20 am #65075
Marc
- Topics: 18
- Replies: 29
- Posts: 47
Hi guys,
I am trying to write a script to identify this 3 candle set up:
//condition so 3rd from last candle is a 2//
v1= HIGH()[2] > HIGH()[3];
v2= LOW()[2] < low()[3];v1 or v2
//2nd candle is an inside candlet//
HIGH()[1] < HIGH()[2];
and LOW()[1] > LOW()[2];
and//last day candle//
HIGH() > HIGH()[1];I have in the scan: Unknown function: offset low2 > i don’t know what is causing the issue.
Previously I have tried this formula:
high() > high(1) and LOW() >= LOW(1);
and HIGH(0)[1] < HIGH(0)[2];
and low(0)[1]> low(0){2];>>> and HIGH(0)[1] < HIGH(0)[2]; is not giving correct results.
pls let me know how to correct it.
This is part of a trading method called Thestrat. It requires to draw horizontal lines on top/ bottom of M/W/D candles. I have read in the forum that Optuma’s script did not allow to do draw horizontal line automatically but the post was 2 years old I believe. Is there a way now to automatically draw those lines from highs/low of multi time frames?
thanks and best regards
Marc.June 25, 2021 at 2:19 am #65079Darren
- Topics: 70
- Replies: 787
- Posts: 857
Hi Marc,
The high 3 bars ago would be HIGH()[2] not HIGH()[3]. You could also use HIGH(2) to get the same result, but don’t put a 0 in the parentheses if using square brackets.
For inside bars we have a BarTypes() function that will automatically find them, so BARTYPES(DEFAULT=Inside)[1] can be used to find when yesterday was an inside bar.
As for the horizontals, they can be drawn using a Show Plot, so to plot the month/week high use HIGH() and click on the text to change the Timeframe to Month or Week:
To only plot the current month high use LAST(HIGH(Month(PERIODAMOUNT=1)))
To only plot the previous month’s high: LAST(HIGH(Month(PERIODAMOUNT=1))[1])
Hope that helps!
June 25, 2021 at 7:22 am #65081Marc
- Topics: 18
- Replies: 29
- Posts: 47
Hi Darren,
Ok I got how to plot the lines. Thank you very much.
Regarding the formula, it does not really work though
The candle from 2 days ago needs to be a directional candle meaning it closed higher or lower than the candle 3 days ago . So it should be outside bar + inside bar + outside bar (Up) but this does not work:
BARTYPES(DEFAULT=Outside)[2];
and BARTYPES(DEFAULT=Inside)[1];
and BARTYPES(Day(PERIODAMOUNT=1), DEFAULT=Outside);
when I Execute scan: unknown Function: offset Bartypesdefault= Inside1I have modified the original formula accordingly and it works
v1= HIGH()[2] > HIGH()[3] and LOW()[2] >= LOW()[3];
v2= LOW()[2] < low()[3] and HIGH()[2] <= HIGH()[3];
v1 or v2However when I add the inside bar and BARTYPES(DEFAULT=Inside)[1]; on the NASDAQ100 results include outside bars such as ADSK, CDW, CHTR, COST, CSX.. etc)… Then if I add the last criteria: and BARTYPES(Day(PERIODAMOUNT=1), DEFAULT=Outside); I have: unknown Function: offset Bartypesdefault= Inside1 … so I don’t get the expected result…
Thanks and best regards
Marc
June 26, 2021 at 11:12 pm #65095Darren
- Topics: 70
- Replies: 787
- Posts: 857
Hi Marc,
Don’t put ; between the ‘and’ conditions and the scans will work without the unknown function error.
12345BARTYPES(DEFAULT=Outside)[2]and BARTYPES(DEFAULT=Inside)[1]and BARTYPES(DEFAULT=Outside)June 27, 2021 at 7:46 am #65097Marc
- Topics: 18
- Replies: 29
- Posts: 47
Hi Darren,
Pls kindly let me know what is wrong with this formula. I am looking for a higher high or higher low candle(2)+ an inside candle (1) + a higher high (2)
v1=BARTYPES(Day(PERIODAMOUNT=1), DEFAULT=Lower)[2];
v2=BARTYPES(Day(PERIODAMOUNT=1), DEFAULT=Higher)[2];
v3=BARTYPES(DEFAULT=Inside)[1];
v4=BARTYPES(Day(PERIODAMOUNT=1), DEFAULT=Higher);v1 or v2
and v3 and v4I don’t get the inside candle with this formula even though it can come up as a “true” in the table, it is not on the chart.
Thanks and best regards
MarcJune 29, 2021 at 2:18 am #65115Darren
- Topics: 70
- Replies: 787
- Posts: 857
Hi Marc,
I put (v1 or v2) in parentheses and I got the expected results. Also, I assume you are applying to a daily watchlist / chart? If so there’s no need to specify the timeframe in the script.
12345678v1=BARTYPES(DEFAULT=Lower)[2];v2=BARTYPES(DEFAULT=Higher)[2];v3=BARTYPES(DEFAULT=Inside)[1];v4=BARTYPES(DEFAULT=Higher);(v1 or v2) and v3 and v4If you change the colour scheme to Swing Relations then the inside bars will show as black, as per this example for XOM which returned a true result (as of Friday’s data). If you still have issues send your watchlist to support and we’ll take a look.
1 user thanked author for this post.
July 5, 2021 at 7:55 pm #65181Marc
- Topics: 18
- Replies: 29
- Posts: 47
Hi Darren,
I’d like to have an indication of the bar type in my watchlist: 1 if inside bar, “2up” if Higher bar, “2dw” if lower bar, 3 if outside bar.
I am going nowhere with my formula… Can you pls show me how to write it?
Thanks and best regards
Marc
July 6, 2021 at 7:36 pm #65199Darren
- Topics: 70
- Replies: 787
- Posts: 857
Hi Marc,
You would need a combination of IF statements and conditional column labels in the watchlist. This is a bit beyond basic scripting support so if you would like to arrange a paid scripting consultation send a note to support.
However, the concept of IF statement and values are the same as in this example which shows the direction of the RRG in a watchlist. Replace the Heading values with BartTypes():
https://forum.optuma.com/topic/scripts-for-relative-rotation-graphs-rrgs/#post-64301
-
AuthorPosts
- You must be logged in to reply to this topic.