Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MACD on 15 min charts

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

    MACD on 15 min charts

    Hello,

    I had a strategy working on daily bars and I am trying to convert it so that it works on 15 minutes bar at 3.45 pm.

    However the following line of code is not working:

    HTML Code:
    if (CrossAbove(MACD(macdfastactual, macdslowactual, macdsmoothactual), MACD(macdfastactual, macdslowactual, macdsmoothactual).Avg,macdlookbackactual)
    				&& ToTime(Time[0]) == 154500
    				)
                {
    				
                    EnterLong(1,"Buy MACD Crossover");				
                }
    The following variables are initial declared( thats what I was using with a daily bar chart)
    HTML Code:
    private int macdfast=12;
    		private int macdslow=26;
    		private int macdsmooth=9;
    		private int macdlookback=3;
    They are then transformed for a 15 minutes chart:

    HTML Code:
    int macdfastactual=macdfast*periodsperday;
    			int macdslowactual=macdslow*periodsperday;
    			int macdsmoothactual=macdsmooth*periodsperday;
    			int macdlookbackactual=macdlookback*periodsperday;

    #2
    Hello Manuel17,

    Thank you for your inquiry.

    Can you please clarify what you mean by the line of code not working?

    Are you getting a compile error? Is the EnterLong() not executing?

    Have you done any debugging to check if the conditions you have specified are true or not? You can do this by utilizing Prints.

    We have a post on our support forum detailing debugging: http://ninjatrader.com/support/forum...58&postcount=1
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      Hello Zachary,

      Sorry for the late reply, I was away. The EnterLong is not executing at all and I do not understand why. I tried to debug it and it does not work.

      Manuel

      Comment


        #4
        Hello Manuel17,

        Thanks for your reply.

        Please add a Print statement just above and just after the EnterLong() to see if you are getting the logic correct but the order is not being entered.

        For example:
        {
        Print ("about to enterlong");
        EnterLong(1,"Buy MACD Crossover");
        Print ("Entered long");
        }

        If you do not get any print statements then you would need to look at the conditional statement:
        if (CrossAbove(MACD(macdfastactual, macdslowactual, macdsmoothactual), MACD(macdfastactual, macdslowactual, macdsmoothactual).Avg,macdlookbackactual)
        && ToTime(Time[0]) == 154500)

        Just above the condition you can add a print statement like: Print ("Bar: "+Time[0]); to verify the time. You can also add print statements to print out the values of Macd and it average so that you know going into the if statement what values it is evaluating. This is the only way you will know why it does or does not work.
        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by mjairg, 07-20-2023, 11:57 PM
        3 responses
        213 views
        1 like
        Last Post PaulMohn  
        Started by TheWhiteDragon, 01-21-2019, 12:44 PM
        4 responses
        544 views
        0 likes
        Last Post PaulMohn  
        Started by GLFX005, Today, 03:23 AM
        0 responses
        3 views
        0 likes
        Last Post GLFX005
        by GLFX005
         
        Started by XXtrader, Yesterday, 11:30 PM
        2 responses
        12 views
        0 likes
        Last Post XXtrader  
        Started by Waxavi, Today, 02:10 AM
        0 responses
        7 views
        0 likes
        Last Post Waxavi
        by Waxavi
         
        Working...
        X