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 helpwanted, Today, 03:06 AM
        1 response
        7 views
        0 likes
        Last Post sarafuenonly123  
        Started by Brevo, Today, 01:45 AM
        0 responses
        7 views
        0 likes
        Last Post Brevo
        by Brevo
         
        Started by aussugardefender, Today, 01:07 AM
        0 responses
        5 views
        0 likes
        Last Post aussugardefender  
        Started by pvincent, 06-23-2022, 12:53 PM
        14 responses
        242 views
        0 likes
        Last Post Nyman
        by Nyman
         
        Started by TraderG23, 12-08-2023, 07:56 AM
        9 responses
        384 views
        1 like
        Last Post Gavini
        by Gavini
         
        Working...
        X