Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

MACD Diff Based Entry and Exit

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

    MACD Diff Based Entry and Exit

    Hello,

    One of my requirements for entry that I want is for the MACD Diff to be higher than the previous candlesticks close value. (Showing an increase in momentum) I need this to work for when the MACD Difference was previously declining and has now started to reverse trend.

    Also, for my exit strategy I need the value of the MACD Diff high since entry to have decreased by 20% for my exit to be filled.

    Lastly, how do I make sure that there is only one order entry sent per requirements matched. For example, when all my requirements are matched I want there to be one order entry sent out until my requirements are no longer matched and then the strategy could look for another possible entry.

    Thank you so much for your time and help!

    #2
    Hello jabbhc,

    The code for the MACD Diff being higher than the previous close would appear as:
    Code:
    if (CurrentBar > 1 && MACD(12, 26, 9).Diff[0] > Close[1])
    You can check if the value of the Diff plot from 1 bar ago is less than 2 bars ago
    MACD(12, 26, 9).Diff[1] < MACD(12, 26, 9).Diff[0]

    Similarly you can compare the plot from 0 bars ago to be greater than 1 bar go.

    You find 20% of a value by multiplying it by .2.

    Print(MACD(12, 26, 9).Diff[0] * .2);

    The EntriesPerDirection you can set to 1, so once a position is taken new orders are ignored.


    If you have not already watched the Strategy Builder 301 video, I recommend this as a starting point.
    Below is a link to forum post with helpful information about getting started with NinjaScript.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by ScottWalsh, Today, 04:29 PM
    0 responses
    5 views
    0 likes
    Last Post ScottWalsh  
    Started by rtwave, 04-12-2024, 09:30 AM
    2 responses
    22 views
    0 likes
    Last Post rtwave
    by rtwave
     
    Started by tsantospinto, 04-12-2024, 07:04 PM
    5 responses
    70 views
    0 likes
    Last Post tsantospinto  
    Started by cre8able, Today, 03:20 PM
    0 responses
    7 views
    0 likes
    Last Post cre8able  
    Started by Fran888, 02-16-2024, 10:48 AM
    3 responses
    49 views
    0 likes
    Last Post Sam2515
    by Sam2515
     
    Working...
    X