Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Simple MACD Crossover Strategy that isn't so simple

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

    #16
    To be more specific, it didnt Exit on a long position. It just seemed to be waiting for a stop loss or profit, which I removed.

    What I would like is for it to exit when the opposite MACD cross occurs.

    Also, I tried my code and it didnt seem to exit as well. Any ideas?

    Comment


      #17
      May have fixed this issue

      I believe I fixed it. I added the ExitShort(); command once it enters the macd long cross. Does this make sense

      if (CrossAbove(MACD(12, 26, 9), MACD(12, 26, 9).Avg, 1))
      {
      ExitShort();
      buyFlag = true; // enable ability to buy because Macd crossed above 0
      sellFlag = false; // disable ability to sell because Macd crossed above 0
      }

      if (buyFlag && Stochastics(7, 14, 3).K[0] > 80) //&& Position.MarketPosition == MarketPosition.Flat)
      {
      EnterLong(); // BuyFlag and stochstics K are true so enter long
      buyFlag = false; // reset buyFlag until next macd cross above
      }

      Comment


        #18
        Hello eberline,

        Thanks for your replies.

        To answer your latest post, if you would review post #12 we added the exit short condition after checking that we were in a short position. While the method ExitShort is ignored if we are not in a position (so what you have will work) it is better practice to test for the position before exiting.
        Paul H.NinjaTrader Customer Service

        Comment


          #19
          Total Profit

          Thank you Paul.

          How do I set a total profit condition? Meaning when a total profit is reached, close the strategy for the day?

          Similarly, how would I set a total loss for the day?

          Thank You.

          Comment


            #20
            Hello eberline,

            Thanks for your post and questions.

            Moneymanagement while in a strategy is addressed in the sample code here: http://www.ninjatrader.com/support/f...ead.php?t=4084

            Please let me know if I can be of further assistance.
            Paul H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by lorem, Yesterday, 09:18 AM
            4 responses
            13 views
            0 likes
            Last Post lorem
            by lorem
             
            Started by Spiderbird, Today, 12:15 PM
            0 responses
            5 views
            0 likes
            Last Post Spiderbird  
            Started by cmtjoancolmenero, Yesterday, 03:58 PM
            12 responses
            42 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by FrazMann, Today, 11:21 AM
            0 responses
            6 views
            0 likes
            Last Post FrazMann  
            Started by geddyisodin, Yesterday, 05:20 AM
            8 responses
            52 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Working...
            X