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

MACD diff

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

    MACD diff

    I am trying to automate a bot using MACD, but i cannot figure out how to use the diff. Im trying to make it sell if the Macd Diff is less than -0.5 and make it buy when its greater than 0.5 , but i cannot figurs out the code. I tried doing the green line - red line wich should give the same value as the macd diff but did not work. What shall i do?

    // Set 1
    if ((CrossAbove(MACD1.Default, MACD1.Avg, 1))
    && ((MACD1.Default-MACD1.Avg) >= MacdVol)
    && (Times[0][1].TimeOfDay >= StartTime.TimeOfDay)
    && (Times[0][1].TimeOfDay <= EndTime.TimeOfDay))
    {
    EnterLong(Convert.ToInt32(Lots), "");
    }

    // Set 2
    if ((CrossBelow(MACD1.Default, MACD1.Avg, 1))
    && ((MACD1.Default-MACD1.Avg) <= MacdVol*(-1))
    && (Times[0][1].TimeOfDay >= StartTime.TimeOfDay)
    && (Times[0][1].TimeOfDay <= EndTime.TimeOfDay))​

    #2
    use the drop-down putton "value plot". there you can choose the diff.

    if (MACD1.Diff[0] > MacdLong)
    {
    EnterLong(Convert.ToInt32(DefaultQuantity), "");
    }

    // Set 2
    if (MACD1.Diff[0] < MacdShort)
    {
    EnterShort(Convert.ToInt32(DefaultQuantity), "");
    }​
    Last edited by sane1111; 09-14-2022, 07:37 AM.

    Comment


      #3
      Hello ae72.,

      Thank you for your post.

      As sane1111 mentioned, you can use the dropdown menu to select which plot value you would like to use in your condition. I made a short video that demonstrates what it would look like to set up a condition with the MACD Diff plot:



      This is also similar to the condition example in the help guide for How to compare plot values of multi-plot indicators:



      The only difference is on the right side of the condition, you are not comparing to another plot, but instead comparing to a numeric value.

      Please let us know if we may be of further assistance.
      Emily C.NinjaTrader Customer Service

      Comment


        #4
        Thank you, It resolved my issues.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Shansen, 08-30-2019, 10:18 PM
        24 responses
        939 views
        0 likes
        Last Post spwizard  
        Started by Max238, Today, 01:28 AM
        0 responses
        7 views
        0 likes
        Last Post Max238
        by Max238
         
        Started by rocketman7, Today, 01:00 AM
        0 responses
        4 views
        0 likes
        Last Post rocketman7  
        Started by wzgy0920, 04-20-2024, 06:09 PM
        2 responses
        28 views
        0 likes
        Last Post wzgy0920  
        Started by wzgy0920, 02-22-2024, 01:11 AM
        5 responses
        33 views
        0 likes
        Last Post wzgy0920  
        Working...
        X