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

Newbie help

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

    Newbie help

    Hi!

    So i'm trying to make a Strategy with the Crossing of MacD, alone the MacD isn't good and will only give a 48% winrate.
    Now i want to filter out some of the bad trades using the 200EMA, Only going Short when the price is below and only going long when the price is above.
    Like seen in this video ; https://www.youtube.com/watch?v=nmffSjdZbWQ&t=351s

    I've tried putting it in a group with a 1% above or below seeing i would like to trade the trend and not a range.

    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0)
    return;

    if (CurrentBars[0] < 1)
    return;

    // Set 1
    if ((CrossAbove(MACD1.Default, MACD1.Avg, 1))
    // Condition group 1
    || ((Close[0] * 1) > EMA1[0]))
    {
    EnterLong(Convert.ToInt32(DefaultQuantity), "");
    }

    // Set 2
    if ((CrossBelow(MACD1.Avg, MACD1.Default, 1))
    // Condition group 1
    && ((Close[0] * 1) < EMA1[0]))
    {
    EnterShort(Convert.ToInt32(DefaultQuantity), "");
    }

    }

    But this doesn't solve it and the script will still go long while under the 200ema.

    Any advice?
    Thanks!

    #2
    Welcome to the forums Unxander!

    Code:
    if ((CrossAbove(MACD1.Default, MACD1.Avg, 1))
    // Condition group 1
    || ((Close[0] * 1) &gt; EMA1[0]))
    This condition checks if there is a corssover OR if the current market price (Close[0)] times 1 is greater than the EMA value. This is not factoring a percentage of the close being greater than the EMA and since you are checking OR (if any) ether condition can be true

    To set up a condition factoring 1%, please see the attached screenshot.

    If you are simply trying to set up entry conditions, I suggest checking if the strategy position is flat before calling EnterLong/EnterShort. (Positions will reverse if EnterLong/EnterShort is called in the opposite direction.) Please see "Creating market position comparisons" in our help guide page below.



    If you have not already seen it, please see our Strategy Builder 301 tutorial for a full walk through on using this tool.

    Understand the fundamentals of basic strategy creation by developing an actual strategy using the NinjaTrader Strategy Builder.2:45 Opening a Strategy Builde...


    We look forward to assisting.
    Attached Files
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Waxavi, Today, 02:10 AM
    1 response
    16 views
    0 likes
    Last Post NinjaTrader_LuisH  
    Started by Kaledus, Today, 01:29 PM
    5 responses
    13 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by Waxavi, Today, 02:00 AM
    1 response
    12 views
    0 likes
    Last Post NinjaTrader_LuisH  
    Started by alifarahani, Today, 09:40 AM
    5 responses
    23 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by gentlebenthebear, Today, 01:30 AM
    3 responses
    17 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Working...
    X