Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using MACD instead of Average

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

    Using MACD instead of Average

    I thought I just do .MACD and it would measure the macd > 0 as opposed to the Avg but im getting a compile error. For .Avg it compiles fine?

    if (MACD(longmacdfast, 26, 9)[0] > 0

    do I not just do if (MACD(longmacdfast, 26, 9).MACD[0] > 0


    When I went through the Strategy Wizard I had the option to choose MACD under Plot, but now that the code is unlocked how do I do this?
    Last edited by zachj; 01-25-2012, 07:13 PM.

    #2
    What is the error? " ) expected " ??


    Originally posted by zachj View Post
    I thought I just do .MACD and it would measure the macd > 0 as opposed to the Avg but im getting a compile error. For .Avg it compiles fine?

    if (MACD(longmacdfast, 26, 9)[0] > 0

    do I not just do if (MACD(longmacdfast, 26, 9).MACD[0] > 0


    When I went through the Strategy Wizard I had the option to choose MACD under Plot, but now that the code is unlocked how do I do this?

    Comment


      #3
      I think you are missing a )


      Code:
                  if ( MACD(12, 26, 9)[0] > 0)
                  {
                      Print ("hi");
                  }
      Originally posted by zachj View Post
      I thought I just do .MACD and it would measure the macd > 0 as opposed to the Avg but im getting a compile error. For .Avg it compiles fine?

      if (MACD(longmacdfast, 26, 9)[0] > 0

      do I not just do if (MACD(longmacdfast, 26, 9).MACD[0] > 0


      When I went through the Strategy Wizard I had the option to choose MACD under Plot, but now that the code is unlocked how do I do this?

      Comment


        #4
        I just didn't have the whole region of code...

        Code:
        if (MACD(longmacdfast, 26, 9)[0] > 0
        
        && Close[0] > BigMO(89)[0]
        
        && SuperTrend(14, 2.618, true).UpTrend[0] < Close[0]
        
        && MACD(longmacdfast, 26, 9)[0] > MACD(longmacdfast, 26, 9)[1]
        	
        && ToTime(Time[0]) > ToTime(timestart, 0, 0)
        	
        && ToTime(Time[0]) < ToTime(16, 0, 0))	
         
        
        { 
        EnterLong(DefaultQuantity, "");
        }
        Again when I went through the Strategy Wizard I had the option to choose MACD under Plot, but now that the code is unlocked how do I do this?

        Comment


          #5
          Originally posted by zachj View Post
          I thought I just do .MACD and it would measure the macd > 0 as opposed to the Avg but im getting a compile error. For .Avg it compiles fine?

          if (MACD(longmacdfast, 26, 9)[0] > 0

          do I not just do if (MACD(longmacdfast, 26, 9).MACD[0] > 0


          When I went through the Strategy Wizard I had the option to choose MACD under Plot, but now that the code is unlocked how do I do this?

          I don't have SuperTrend or BigMO, but the rest compiled fine.

          I also substituted numbers for your variables.


          Code:
                      if (MACD(12, 26, 9)[0] > 0
          
          //&& Close[0] > BigMO(89)[0]
          
          //&& SuperTrend(14, 2.618, true).UpTrend[0] < Close[0]
          
          && MACD(12, 26, 9)[0] > MACD(12, 26, 9)[1]
              
          && ToTime(Time[0]) > ToTime(10, 0, 0)
              
          && ToTime(Time[0]) < ToTime(16, 0, 0))    
           
          
          { 
          EnterLong(DefaultQuantity, "");
          }

          Comment


            #6
            Of course it compiles fine as is. No offense but I was looking to hear from a NT rep.

            I want to make sure its calculationg a MACD >0 and not using the Avg or Diff. After the MACD method you can put a "." and menu of different variables pops up. Trying to figure out why I can't compile after I put .MACD after the method, I am able to compile with .Avg though.

            This will not compile -----> MACD(longmacdfast, 26, 9).MACD[0] > 0
            But this does? ---------> MACD(longmacdfast, 26, 9).Avg[0] > 0

            And again looking to replicate the Strategy Wizard how it gives the option to choose MACD, Avg or Diff under Plot. I unlocked the code though so am not able to adjust this in the wizard.

            Comment


              #7
              This is incorrect syntax: MACD(longmacdfast, 26, 9).MACD[0] > 0

              You don't need .MACD after the method for the MACD. Onbly for Avg and Diff.

              From the menu, Help->Help->search->macd->first topic Moving Average..

              Returns MACD value
              MACD(int fast, int slow, int smooth)[int barsAgo]
              MACD(IDataSeries input, int fast, int slow, int smooth)[int barsAgo]

              Returns average value

              MACD(int fast, int slow, int smooth).Avg[int barsAgo]
              MACD(IDataSeries input, int fast, int slow, int smooth).Avg[int barsAgo]

              Returns difference value

              MACD(int fast, int slow, int smooth).Diff[int barsAgo]
              MACD(IDataSeries input, int fast, int slow, int smooth).Diff[int barsAgo]
              Code:
              Examples
               [LEFT]     [LEFT]     // Prints the current  MACD  value
              double value = MACD(12, 26, 9)[0];
              Print("The current MACD value is " + value.ToString());
               
               // Prints the current  MACD average  value
              double value = MACD(12, 26, 9).Avg[0];
              Print("The current MACD average value is " + value.ToString());
               
               // Prints the current  MACD difference  value
              double value = MACD(12, 26, 9).Diff[0];
              Print("The current MACD difference value is " + value.ToString());[/LEFT]
              [/LEFT]
              Originally posted by zachj View Post
              Of course it compiles fine as is. No offense but I was looking to hear from a NT rep.

              I want to make sure its calculationg a MACD >0 and not using the Avg or Diff. After the MACD method you can put a "." and menu of different variables pops up. Trying to figure out why I can't compile after I put .MACD after the method, I am able to compile with .Avg though.

              This will not compile -----> MACD(longmacdfast, 26, 9).MACD[0] > 0
              But this does? ---------> MACD(longmacdfast, 26, 9).Avg[0] > 0

              And again looking to replicate the Strategy Wizard how it gives the option to choose MACD, Avg or Diff under Plot. I unlocked the code though so am not able to adjust this in the wizard.

              Comment


                #8
                Something is not right then because when I run a backtest the Net profit is coming out much different than it was previously, and it happened after I adjusted that part of the code. I think I will have to start from scratch and run it through the wizard again and just paste all my manual codes back in.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                657 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                373 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                109 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                574 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                579 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X