Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MACD crossover on 1 minute chart

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

    MACD crossover on 1 minute chart

    I've coded MACD crossover strategy, it does work fine on 5 ticks range bars, but does not working on 1 minute chart. When I enable it, it appear yellow in the strategies tab, also I cant see any previous history of entry/exits.I tried to change settings like COB=true/false,.Avg, 1 Avg 2, etc, doesnt help. The conditions part of code as follow, please advise:


    // Condition set 1
    if (Position.MarketPosition == MarketPosition.Flat && (MACD(12, 26, 9).Avg[0] > 5)
    &&CrossBelow(MACD(12, 26, 9), MACD(12, 26, 9).Avg, 1))

    {
    EnterShort( DefaultQuantity, "short");
    EnterShort( DefaultQuantity, "short1");
    }




    // Condition set 2
    if (Position.MarketPosition == MarketPosition.Flat && (MACD(12, 26, 9).Avg[0] < 5)
    && CrossAbove(MACD(12, 26, 9), MACD(12, 26, 9).Avg, 1))

    {
    EnterLong( DefaultQuantity, "long");
    EnterLong( DefaultQuantity, "long1");
    }

    #2
    meowflying, looks to me like it the entry conditions simply don't trigger on the 1min then. Have you checked the signals visually, i.e. for example would the Avg value satisfy the <> 5 part? I would think that's probably not happening due to the higher compression of bars.

    Comment


      #3
      Originally posted by NinjaTrader_Bertrand View Post
      meowflying, looks to me like it the entry conditions simply don't trigger on the 1min then. Have you checked the signals visually, i.e. for example would the Avg value satisfy the <> 5 part? I would think that's probably not happening due to the higher compression of bars.

      I excluded <> 5 part, and even created new strategy through wizard to eliminate all possible problems, still doesnt work. Visually we have MACD crossover, so why strategy is not picking it up? Moreover, why its yellow, usually its an indication that strategy is in active position and will be green after exit execution. What is compression of bars anyway, and how I can make macd crossover work considering that?

      Comment


        #4
        meowflying, which instrument would that be?

        With bar compression comment I just meant, I felt it's more likely to give you that high AVG value readings on the 5 tick since this would have longer runs compared to the 1 min. Just test for example <> 0 to get this component out of question.

        If you want your script to reverse, it would not be correctly constructed, since now you only act if you're flat in the strategy. This means you likely only see the ExitOnClose each session and then one new entry as you're coming flat into the day...

        Comment


          #5
          The strategy is working now, however one condition is still not working:

          (MACD(12, 26, 9).Avg[0] > 5

          I tried to change it to:
          (MACD(12, 26, 9)[1] > 0

          still not working, any idea?

          And btw, if I want to check if the condition is right for the few bars back, for example if the condition is right for the duration of last 5 bars, how can I do that? [5] will check only fifth bar back, but not all 5 bars right?
          Last edited by meowflying; 01-23-2015, 07:02 AM.

          Comment


            #6
            meowflying,

            For example this works well for me testing on an ES 1 minchart

            Code:
            if (CrossBelow(MACD(12, 26, 9), MACD(12, 26, 9).Avg, 1)
            	&& MACD(12, 26, 9).Avg[0] < 0) 
            {
                EnterShort( DefaultQuantity, "short"); 
                EnterShort( DefaultQuantity, "short1");
            }
            ...and then switched condition for the long setup.

            When you say it does not work, do you mean you see trades being generated that would not fulfill the condition, so your MACD value being smaller than 0? To doublecheck it would best to print out the indicator values for each bar or work closely with the databox to see the exact values including the trailing fractions.

            Do you mean you want to say the crossabove has happend within the last 5 bars?

            Comment


              #7
              Yes it seems to work on ES, but not on DAX..hmm. I will try to change the settings and see how it goes.

              "Do you mean you want to say the crossabove has happend within the last 5 bars"
              Yes, how I can make a condition that will check last 5 bars, and not particular bar?

              Originally posted by NinjaTrader_Bertrand View Post
              meowflying,

              For example this works well for me testing on an ES 1 minchart

              Code:
              if (CrossBelow(MACD(12, 26, 9), MACD(12, 26, 9).Avg, 1)
                  && MACD(12, 26, 9).Avg[0] < 0) 
              {
                  EnterShort( DefaultQuantity, "short"); 
                  EnterShort( DefaultQuantity, "short1");
              }
              ...and then switched condition for the long setup.

              When you say it does not work, do you mean you see trades being generated that would not fulfill the condition, so your MACD value being smaller than 0? To doublecheck it would best to print out the indicator values for each bar or work closely with the databox to see the exact values including the trailing fractions.

              Do you mean you want to say the crossabove has happend within the last 5 bars?

              Comment


                #8
                meowflying, you can specify a higher lookback period to use for the evalulation of your cross logic. Right now you have this at 1 checking only for the most recent bar, but you can for example set this to 5 and have it check a higher number of bars.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                648 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                369 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
                573 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                575 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X