OmniTrader Professional Forum - OmniLanguage Discussion
Can anyone help with omnilanguage exit ?

^ Top
MikeB

Posts: 11

Joined: 4/7/2020
Location: Auckland NZ

User Profile
 
Subject : Can anyone help with omnilanguage exit ?
Posted : 6/4/2024 1:52 AM
Post #32425

Can anyone help with omnilanguage exit ?
Rhinohull(10) change from up (blue) to Red (down)
Posted : 6/3/2024 2:45 AM
Post #48919

Can anyone help with omnilanguage exit ?

exit long Trade when:
Rhinohull(10) change from up (blue) to Red (down)
thanks
Mike Attached file : Capture.JPG
Attached file : Capture.JPG (11KB - 103 downloads)

^ Top
Etherist

Posts: 25

Joined: 6/9/2024
Location: South Australia

User Profile
 
Subject : RE: Can anyone help with omnilanguage exit ?
Posted : 6/10/2024 4:31 AM
Post #32434 - In reply to #32425

Here's a potential exit strategy using the RhinoHull Moving Average (RHMA) with a parameter of 10, where the exit condition is based on a change in the RhinoHull indicator from up (blue) to down (red).

Exit Long Trade Using RhinoHull Indicator:

========================================================================

' Define the RhinoHull parameters
Dim RHMAPeriod As Integer
RHMAPeriod = 10

' Calculate the RhinoHull Moving Average
Dim RhinoHullMA As Series
RhinoHullMA = RhinoHull(Close, RHMAPeriod)

' Check the color change condition for RhinoHull MA
Dim CurrentColor As String
Dim PreviousColor As String

If RhinoHullMA > RhinoHullMA[1] Then
CurrentColor = "Blue"
Else
CurrentColor = "Red"
End If

If RhinoHullMA[1] > RhinoHullMA[2] Then
PreviousColor = "Blue"
Else
PreviousColor = "Red"
End If

' Exit long trade condition: Change from Blue to Red
If PreviousColor = "Blue" And CurrentColor = "Red" Then
ExitLong("Exit Long Trade", "RhinoHull Color Change")
End If

======================================================================

Explanation

1. Define Parameters:
- `RHMAPeriod`: The period for the RhinoHull Moving Average. In this case, it is set to 10.

2. Calculate RhinoHull Moving Average:
- `RhinoHullMA`: Calculate the RhinoHull MA using the `RhinoHull` function with the close prices and specified period.

3. Determine Current and Previous Color:
- `CurrentColor`: Assign "Blue" if the current RhinoHull MA is greater than the previous value, otherwise assign "Red".
- `PreviousColor`: Assign "Blue" if the previous RhinoHull MA is greater than the value before it, otherwise assign "Red".

4. Exit Long Trade Condition:
- Exit the long trade if the `PreviousColor` was "Blue" and the `CurrentColor` is "Red". This indicates a change from up (blue) to down (red).

Customisation and Use:

- Customisation: Adjust the `RHMAPeriod` to suit your specific trading strategy.
- Use: Implement this script in OmniTrader to automatically exit long trades based on the RhinoHull MA color change.

This script will ensure that you exit a long trade when the trend detected by the RhinoHull Moving Average changes from up to down, helping manage risk and potentially improve trading performance.
^ Top
MikeB

Posts: 11

Joined: 4/7/2020
Location: Auckland NZ

User Profile
 
Subject : RE: Can anyone help with omnilanguage exit ?
Posted : 10/4/2024 3:54 AM
Post #32485 - In reply to #32434

really appreciate your reply, Etherist

I was expecting notification from the site if anyone replied
checked a couple of times and saw nothing

sorry for my late thankyou

Just wondering how I use this code.
I was looking for an omni language exit in a trade plan

do i use this in a vote block or what?
excuse my ignorance

well done mate you've made my day
Mike
^ Top
Etherist

Posts: 25

Joined: 6/9/2024
Location: South Australia

User Profile
 
Subject : RE: Can anyone help with omnilanguage exit ?
Posted : 10/4/2024 11:26 PM
Post #32486 - In reply to #32425

Hey there MikeB

Alas I too do not have the Rhino Suite, as commented by others.

Re: Thread notification via email ... I think you need to select a checkbox at the bottom of your post to be notified when you get a reply to that post.

So ... it might be worth watching this OmniTrader’s Trading Strategies video: https://www.omnitrader.com/currentclients/SupportCenter/section6/.

There is a section in there addressing "Understanding Market Reversal Exits".

To answer your question, you need to edit the Orders component in a given (RhinoHull) strategy. There is the ability to write your own exits using exit algorithms.

Assuming your installation is set to the default location: "Program Files (x86)/Nirvana/OT202X/Manuals/OmniTrader Professional User Guide.pdf" (change "OT202X" with the version of OmniTrader you are using), then you can check the various sections on Programmable Stops, i.e. see on page 21 of this document, you'll see an example of a Stop.

Also on p.47 you have the section on "Writing Your Own Indicators, Systems, & Stops" and more specifically p.53 "Writing a Stop" ... Stops are used in the Orders block and can be created just like indicators and systems.

Therefore you can create a #Stop in OmniLanguage, once this compiles correctly, then this Stop can be applied to the Orders component in the Rhino Hull Strategy.

I'd need to know a bit more about the Rhino Suite to provide more in depth advice. Happy to assist where I can.

Cheers Etherist :-)

P.S. This post on Stops may be useful, or not: https://www.omnitrader.com/currentclients/proforum/thread-view.asp?threadid=7995
^ Top
MikeB

Posts: 11

Joined: 4/7/2020
Location: Auckland NZ

User Profile
 
Subject : RE: Can anyone help with omnilanguage exit ?
Posted : 10/5/2024 12:51 AM
Post #32487 - In reply to #32425

thanks mate

It didnt take 5 minutes to construct that reply so thants for that comprehensive answer

if I make serious money from this I will make a note to send you some!

standby

all the best MikeB


https://www.omnitrader.com/currentclients/proforum/thread-view.asp?threadid=8169&posts=5