OmniTrader Professional Forum
-
OmniScripts
Looking for OmniLanguage Help |
^ Top | ||
Diamondjag![]() Posts: 404 Joined: 3/12/2006 Location: Brighton, Colorado ![]() | I'm looking for an OmniLanguage function that would look for a 250 day low then trigger a sell order if the RSI(5) goes above 85 in the next 4 days. I got a start but don't know how to incorporate the RSI within the next four days. Any help would be appreciated. Thanks. IF L=LLV(250) and RSI(5) >= 85 Then Signal = ShortSignal End If | |
^ Top | ||
Jim Dean![]() Posts: 3433 Joined: 3/13/2006 Location: L'ville, GA ![]() | Hi, Dave The trick is to check the 250-day-low condition for five days PRIOR, and the four bars SINCE then. OT/OL don't allow looking into the future. ;~) IF L[5]=LLV(250)[5] and HHV(RSI(5),4) >= 85 Then Signal = ShortSignal However, that simple approach will create a ***delayed*** entry signal if the RSI rule is met on days 1-3 after the low rule is met. The correct way to do it is to ask if the RSI rule is met TODAY, and if so, check back for the Low rule being satisfied in the "acceptable" window: dim gI as integer If RSI(5) >= 85 then for gI = 1 to 4 if L[gI]=LLV(250)[gI] then Signal = ShortSignal exit for end if next gI This will give you the earliest possible entry signal that meets your rules. The forum doesn't permit indentation but hopefully you can follow it OK. Note that LLV is an "inefficient" function, so this code tries to minimize its use ... an efficient workaround to LLV for this application requires a lot more code. I doubt that you'd notice the difference, unless your rule allowed for the prior lowest-low to occur a long time before the RSI rule. | |
^ Top | ||
Diamondjag![]() Posts: 404 Joined: 3/12/2006 Location: Brighton, Colorado ![]() | Jim, Always happy when I see you respond to an Omni Language question. I copied what you sent. Probably did something wrong at the end. Got a message that said that line 15 needed a closing "end if". What am I missing here? Thanks ![]() | |
^ Top | ||
Jim Dean![]() Posts: 3433 Joined: 3/13/2006 Location: L'ville, GA ![]() | Here is the corrected code with final end if, in pretty indentation form that makes the whole thing more understandable: ![]() | |
^ Top | ||
Diamondjag![]() Posts: 404 Joined: 3/12/2006 Location: Brighton, Colorado ![]() | Added the "end if" and it works nicely. Will now go in and pretty it up with the indentations. Thank you so much! |