Etherist![]() Member ![]() Posts: 25 Joined: 6/9/2024 Location: South Australia ![]() | 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. |