OmniTrader Professional Forum OmniTrader Professional Forum
forums calendars search
today this week
 
register logon control panel Forum Rules
You are currently browsing as a guest.
You should logon to access more features
A Self-Moderated Community - ALL MEMBERS, PLEASE READ!
Vote for Members who contribute the most to your trading, and help us moderate content within the Forums.


  Current location        Thread information  
OmniTrader Professional Forum
OmniLanguage Discussion
impulseMACD
Last Activity 10/5/2024 12:51 AM
12 replies, 1585 viewings

Jump to page : 1
Now viewing page 1 [25 messages per page]
 
back reply
Printer friendly version

^ Top
Lou Venezia

Member

Posts: 23

Joined: 7/22/2022

User Profile
 
Subject : impulseMACD
Posted : 3/5/2024 10:28 AM
Post #32413

is there a way to access the trigger line, signal line and histogram in impulse MACD - iMACD(34,9).

Thanks for assistance
^ Top
Etherist

Member
25
Posts: 25

Joined: 6/9/2024
Location: South Australia

User Profile
 
Subject : RE: impulseMACD
Posted : 6/10/2024 4:08 AM
Post #32433 - In reply to #32413

Accessing the components of the impulse MACD (iMACD), can be achieved within OmniTrader using OmniScript.

Accessing iMACD Components in OmniTrader:

To access the trigger line, signal line, and histogram of the impulse MACD with parameters (34,9), you can use OmniScript to calculate and plot these values.

OmniScript Example:

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

' Define parameters for the iMACD
Dim FastLength As Integer
Dim SlowLength As Integer
Dim SignalSmoothing As Integer

FastLength = 34
SlowLength = 9
SignalSmoothing = 9

' Calculate the MACD line and Signal line
Dim MACDLine As Series
Dim SignalLine As Series
Dim Histogram As Series

MACDLine = MACD(Close, FastLength, SlowLength) ' MACD line using close prices
SignalLine = Signal(MACDLine, SignalSmoothing) ' Signal line (EMA of MACD line)

' Calculate the Histogram as the difference between MACD line and Signal line
Histogram = MACDLine - SignalLine

' Plot the iMACD components
Plot1(MACDLine, "MACD Line", ColorBlue)
Plot2(SignalLine, "Signal Line", ColorRed)
Plot3(Histogram, "Histogram", ColorGreen)

' Optionally, you can add logic for trading signals based on the iMACD
If CrossOver(MACDLine, SignalLine) Then
Buy("Buy Signal")
ElseIf CrossUnder(MACDLine, SignalLine) Then
Sell("Sell Signal")
End If

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

Explanation

1. Define Parameters:
- `FastLength`: The fast period length for the MACD.
- `SlowLength`: The slow period length for the MACD.
- `SignalSmoothing`: The period length for the signal line.

2. Calculate MACD Line and Signal Line:
- `MACDLine`: Calculated using the `MACD` function with the `Close` price and specified fast and slow lengths.
- `SignalLine`: Calculated as the EMA of the `MACDLine` over the `SignalSmoothing` period.

3. Calculate Histogram:
- `Histogram`: The difference between the `MACDLine` and the `SignalLine`.

4. Plot the Components:
- `Plot1`: Plots the `MACDLine` in blue.
- `Plot2`: Plots the `SignalLine` in red.
- `Plot3`: Plots the `Histogram` in green.

5. Trading Logic (Optional):
- Includes basic trading signals for crossover events between the `MACDLine` and the `SignalLine`.

Customisation and Use:

- Customisation: Adjust the `FastLength`, `SlowLength`, and `SignalSmoothing` parameters to fit your specific needs.
- Use: Implement this script within OmniTrader to plot and potentially use the iMACD components for your trading strategy.
^ Top
Lou Venezia

Member

Posts: 23

Joined: 7/22/2022

User Profile
 
Subject : RE: impulseMACD
Posted : 6/11/2024 8:37 AM
Post #32439 - In reply to #32413

I appreciate this very much. This code is outstanding and easy to understand - fantastic job. Can't wait to implement it - I can't thank you enough as this is an integral part of a strategy that I am implementing.
^ Top
Lou Venezia

Member

Posts: 23

Joined: 7/22/2022

User Profile
 
Subject : RE: impulseMACD
Posted : 6/11/2024 8:52 AM
Post #32440 - In reply to #32413

I tried compiling this code and came up with "Series not defined" error. I'm somewhat of a beginner with OmniLanguage(many years of past programming experience but not with basic language) and can research this error. I just don't want to do anything that would negatively affect the efficacy of the code. Any insight would be very much appreciated.
^ Top
Etherist

Member
25
Posts: 25

Joined: 6/9/2024
Location: South Australia

User Profile
 
Subject : RE: impulseMACD
Posted : 6/11/2024 9:57 AM
Post #32441 - In reply to #32413

Hey there Lou

Might be worth changing the series to a single ... alas I may need a refresher course in VB too. See how this goes:

=======================================================================
' Define parameters for the iMACD
Dim FastLength As Integer
Dim SlowLength As Integer
Dim SignalSmoothing As Integer

FastLength = 34
SlowLength = 9
SignalSmoothing = 9

' Declare variables for the MACD components
Dim MACDLine As Single
Dim SignalLine As Single
Dim Histogram As Single

' Calculate the MACD line and Signal line
MACDLine = MACD(Close, FastLength, SlowLength) ' MACD line using close prices
SignalLine = Signal(MACDLine, SignalSmoothing) ' Signal line (EMA of MACD line)

' Calculate the Histogram as the difference between MACD line and Signal line
Histogram = MACDLine - SignalLine

' Plot the iMACD components
Plot1(MACDLine, "MACD Line", ColorBlue)
Plot2(SignalLine, "Signal Line", ColorRed)
Plot3(Histogram, "Histogram", ColorGreen)

' Optionally, you can add logic for trading signals based on the iMACD
If CrossOver(MACDLine, SignalLine) Then
Buy("Buy Signal")
ElseIf CrossUnder(MACDLine, SignalLine) Then
Sell("Sell Signal")
End If

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

Explanation of Changes:

Variable Declarations:

Replaced Dim MACDLine As Series with Dim MACDLine As Single.
Replaced Dim SignalLine As Series with Dim SignalLine As Single.
Replaced Dim Histogram As Series with Dim Histogram As Single.

Worth a shot ... my version of OT is tied up currently with a back-test. Let me know how you go. Cheers.
^ Top
Lou Venezia

Member

Posts: 23

Joined: 7/22/2022

User Profile
 
Subject : RE: impulseMACD
Posted : 6/11/2024 11:08 AM
Post #32442 - In reply to #32413

Made the corrections but now running into a number of compile errors such as Plot1, Plot2, etc need to be changed to "PlotLine", etc. Am in the process of working thru the other compile errors. Logic seems sound but I think VB syntax,use causing compile issues.
^ Top
Etherist

Member
25
Posts: 25

Joined: 6/9/2024
Location: South Australia

User Profile
 
Subject : RE: impulseMACD
Posted : 6/11/2024 10:16 PM
Post #32443 - In reply to #32413

Apologies Lou, it seems I didn't quite have the coding specific to the nuances of OmniScript.

I think you're on the ball with changing from Plot to Plotline.

I'd be interested to see what other changes are needed to compile this code.
^ Top
Lou Venezia

Member

Posts: 23

Joined: 7/22/2022

User Profile
 
Subject : RE: impulseMACD
Posted : 6/12/2024 9:32 AM
Post #32444 - In reply to #32413

In reviewing code in more detail I believe that this will deliver same result as MACD(9,34). The impulse MACD (iMACD) plot is quite different and the calculation is different from standard MACD calculation.
^ Top
Etherist

Member
25
Posts: 25

Joined: 6/9/2024
Location: South Australia

User Profile
 
Subject : RE: impulseMACD
Posted : 6/19/2024 9:40 PM
Post #32449 - In reply to #32413

Try out the attached ... it compiles this time but I do not have the histogram showing. Let me know how you go and any other feedback. Cheers.



[Edited by Etherist on 6/20/2024 1:19 AM]

^ Top
Lou Venezia

Member

Posts: 23

Joined: 7/22/2022

User Profile
 
Subject : RE: impulseMACD
Posted : 6/21/2024 10:57 AM
Post #32450 - In reply to #32413

Thanks for the update. I tried running it and it produces a result that is the exact opposite of the iMACD. That is, when this code shows a rise in MACD line the iMACD shows an exact opposite downturn MACD line - it matches the MACD line of this code but in the opposite direction. I have purchased the iMACD product from Nirvana so I can compare the two results. I only wanted to be able to access the MACD and MACD Trigger lines for the iMACD but time to move on at this point. Thanks for all of your help.
^ Top
Etherist

Member
25
Posts: 25

Joined: 6/9/2024
Location: South Australia

User Profile
 
Subject : RE: impulseMACD
Posted : 6/21/2024 8:11 PM
Post #32451 - In reply to #32413

Interesting result. Thanks for testing. Enjoy the new Impulse Suite. I will take a closer look at this Suite too. All the best with your trading.
^ Top
Etherist

Member
25
Posts: 25

Joined: 6/9/2024
Location: South Australia

User Profile
 
Subject : RE: impulseMACD
Posted : 6/23/2024 8:37 PM
Post #32452 - In reply to #32413

Hey there Lou

Attached is my final attempt at the LazyBear ImpulseMACD Indicator. Would be interested to see how it compares to the official Suite.

You can access all the components of the iMACD either via the parameters or via the Omni code itself. Give it a go, if you have the time or interest.

Cheers :-)

P.S. I updated the attachment re: Histogram colors, etc. and added a Trading Strategy section.



[Edited by Etherist on 6/28/2024 4:51 AM]

Attached file : ImpulseMACD_LB_v2.txt (3KB - 92 downloads)
Attached file : iMACDind.jpg (122KB - 203 downloads)

^ Top
Lou Venezia

Member

Posts: 23

Joined: 7/22/2022

User Profile
 
Subject : RE: impulseMACD
Posted : 6/24/2024 7:40 PM
Post #32453 - In reply to #32413

Thanks. I'll test it out tomorrow and compare results. Will let you know. Thanks for your help and determination. Hopefully this does the trick.
Jump to page : 1
Now viewing page 1 [25 messages per page]
back reply

Legend    Action      Notification  
Administrator
Forum Moderator
Registered User
Unregistered User
E-Mail this thread to a friend
Toggle e-mail notification


Nirvana Systems
For any problems or issues please contact our Webmaster at webmaster@nirvsys.com.