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

Trade Exit After 1 Entry Bar on Swing High Indicator

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

    Trade Exit After 1 Entry Bar on Swing High Indicator

    Hi,

    I'm doing an EMA Cross Exit Strategy via Strategy Builder where the trade exits when, price/bar crosses above the Swing High. Often, I see it close 1 bar after entry.

    Is there a way in the building strategy to ignore the last swing high on the next bar? I tried to use the Bars ago parameter and still happens

    Below is my code and screenshots of the exits.

    if (
    // When Price is Greater than Swing High
    ((Close[0] >= Swing1.SwingHigh[0])
    && (CurrentBars[0] != SavedBar))
    // SMA 50 Below SMA200
    || ((CrossBelow(SMA1, SMA2, 1))
    && (CurrentBars[0] != SavedBar)))
    {
    ExitLong(Convert.ToInt32(DefaultQuantity), "", "");
    SavedBar = Convert.ToInt32(CurrentBars[0]);
    }

    Thank you in advance.​

    #2
    Hello twistedheart,

    As a heads up, the Swing indicator changes its previous bar values.

    You can check the .SwingHighBar and .SwingLowBar to see if the swing has changed.

    Below is a link to the help guide.
    https://ninjatrader.com/support/help.../nt8/swing.htm

    To understand why the condition is evaluating as true or false, print the time of the bar and all values used in the condition along with labels for each value and comparison operator.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by llanqui, Today, 03:53 AM
    0 responses
    6 views
    0 likes
    Last Post llanqui
    by llanqui
     
    Started by burtoninlondon, Today, 12:38 AM
    0 responses
    10 views
    0 likes
    Last Post burtoninlondon  
    Started by AaronKoRn, Yesterday, 09:49 PM
    0 responses
    15 views
    0 likes
    Last Post AaronKoRn  
    Started by carnitron, Yesterday, 08:42 PM
    0 responses
    11 views
    0 likes
    Last Post carnitron  
    Started by strategist007, Yesterday, 07:51 PM
    0 responses
    14 views
    0 likes
    Last Post strategist007  
    Working...
    X