Current location | Thread information | |
![]() ![]() ![]() ![]() ![]() ![]() |
Last Activity 10/5/2024 12:51 AM 12 replies, 1585 viewings |
|
|
Printer friendly version |
^ Top | |||
Lou Venezia![]() Member Posts: 23 Joined: 7/22/2022 ![]() |
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 ![]() Posts: 25 Joined: 6/9/2024 Location: South Australia ![]() |
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 ![]() |
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 ![]() |
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 ![]() 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. | ||
^ Top | |||
Lou Venezia![]() Member Posts: 23 Joined: 7/22/2022 ![]() |
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 ![]() Posts: 25 Joined: 6/9/2024 Location: South Australia ![]() |
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 ![]() |
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 ![]() Posts: 25 Joined: 6/9/2024 Location: South Australia ![]() |
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 ![]() |
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 ![]() Posts: 25 Joined: 6/9/2024 Location: South Australia ![]() |
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 ![]() Posts: 25 Joined: 6/9/2024 Location: South Australia ![]() |
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] ![]() ![]() | ||
^ Top | |||
Lou Venezia![]() Member Posts: 23 Joined: 7/22/2022 ![]() |
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. |
|
|
Legend | Action | Notification | |||
Administrator
Forum Moderator |
Registered User
Unregistered User |
![]() |
Toggle e-mail notification |