Announcement

Collapse
No announcement yet.

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:

      World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.


      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.

      Comment


        #4
        Thank you, It resolved my issues.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        41 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        20 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        28 views
        1 like
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        45 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        37 views
        0 likes
        Last Post CarlTrading  
        Working...
        X