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 trilliantrader, 04-18-2024, 08:16 AM
        7 responses
        27 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by samish18, 04-17-2024, 08:57 AM
        17 responses
        64 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by rocketman7, Today, 02:12 AM
        2 responses
        19 views
        0 likes
        Last Post rocketman7  
        Started by briansaul, Today, 05:31 AM
        1 response
        13 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by PaulMohn, Today, 03:49 AM
        1 response
        12 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Working...
        X