Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Building Strategy based on MACD

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Building Strategy based on MACD

    Hello everyone. Im making progress building my strategy thanks to all your replies and guidance on my previous posts.

    They all have been really helpful. That's why im making this new post about MACD indicator. I want to add it as a confluence for my strategy. The thing is I don't really know how to access to the elements that are part of the MACD indicator (the lines that cross). I mean, I dont know what to call them on my conditions statements.

    For what I see when I configure the MACD, the lines that cross are the MACD line (fast ema of 12 period) and the Avg line (the slow sma of 26 period) PD: I dont know what the smooth 9period is for.

    Anyways.

    Let me elaborate with this following example:

    //Set 1

    if (fast 12 period crosses above slow 26 period && the cross occurs above the zero line (so-called base line)
    {
    BUY
    }

    //Set 2


    if (fast 12 period crosses below slow 26 period && the cross occurs below the zero line (so-called base line)
    {
    SELL
    }


    What are the names I need to write on my condition statement to reference these MACD elements? For the fast, slow and zero line.

    And actually, Id be perfect to know how to reference the other levels that surround the zero line... for instance:


    if (fast 12 period crosses above slow 26 period && the cross occurs above -1.5 and below 1.5) //-1.5 and 1.5 are the values that are around the zero line.
    {
    BUY
    }

    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


    1.50 //the cross must occur below this level


    0 (zero line) //ideal zone


    -1.50 ////the cross must occur above this level




    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Thank you in advance.






    #2
    Hello camtrading,

    Thanks for your post.

    Just to check, you have posted in the NinjaTrader 7 strategy forum.

    If you are using Ninjatrader7, are you coding directly in Ninjascript or are you working with the Strategy Wizard in Ninjatrader7?

    If you are using NT8, I can move this to the correct forum and also would need to know if you are coding directly in Ninjascript, or are you working with the Strategy Builder in NinjaTrader8?

    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hello again. Im so sorry, my mistake. Please move this to NT8.

      Im coding directly in NinjaScript.

      Comment


        #4
        Hello camtrading,

        Thanks for your reply.

        We've moved the thread to the NinjaTrader 8 forum, no worries.

        An easy way to learn to code is to actually use the Strategy Builder to create the condition you are looking for and then use "view code" to look at the coding created by the Strategy builder. You can then copy and paste what you need and it helps to see the syntax generated. To that end, I've created a short specific video on the MACD questions: https://paul-ninjatrader.tinytake.co...M18xNDEwNDA3OQ

        In addition, here is another example of using the strategy builder to generate code for you: https://paul-ninjatrader.tinytake.co...NV8xMTQ5NjY2NQ

        You can also use the ninjascript section of the help guide to see how to use the MACD as well: https://ninjatrader.com/support/help...gence_macd.htm

        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Aviram Y, Today, 05:29 AM
        0 responses
        1 view
        0 likes
        Last Post Aviram Y  
        Started by quantismo, 04-17-2024, 05:13 PM
        3 responses
        25 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by ScottWalsh, 04-16-2024, 04:29 PM
        7 responses
        34 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by cls71, Today, 04:45 AM
        0 responses
        6 views
        0 likes
        Last Post cls71
        by cls71
         
        Started by mjairg, 07-20-2023, 11:57 PM
        3 responses
        216 views
        1 like
        Last Post PaulMohn  
        Working...
        X