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 Option Whisperer, Today, 09:55 AM
            1 response
            11 views
            0 likes
            Last Post bltdavid  
            Started by port119, Today, 02:43 PM
            0 responses
            1 view
            0 likes
            Last Post port119
            by port119
             
            Started by Philippe56140, Today, 02:35 PM
            0 responses
            3 views
            0 likes
            Last Post Philippe56140  
            Started by 00nevest, Today, 02:27 PM
            0 responses
            2 views
            0 likes
            Last Post 00nevest  
            Started by Jonafare, 12-06-2012, 03:48 PM
            5 responses
            3,986 views
            0 likes
            Last Post rene69851  
            Working...
            X