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.


Only Forum Moderators, Administrators, and the owner of this message may delete it.

 
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.
Deleting message 32441 : RE: impulseMACD


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