Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy keeps looping and does not enter at next entry

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

    Strategy keeps looping and does not enter at next entry

    When I'm using multiple indicator or strategies it keeps looping even after I set profit target. I am trying to hit a profit target and after that trend is over I want the strategy to enter at the next entry. Below is one of the example. I wish there was a if and then statement in C# it would be alot easier to say if trend was -1 then +1 then entry 1.

    // Set 1
    if (AuSuperTrendU111.Trend[0] == -1)
    {
    EnterShort(Convert.ToInt32(DefaultQuantity), "");
    }

    // Set 2
    if (AuSuperTrendU111.Trend[0] == 1)
    {
    EnterLong(Convert.ToInt32(DefaultQuantity), "");
    }


    Thanks,
    Taylor

    #2
    Hello Taylor,

    Welcome to the NinjaTrader forums!

    C# does have an 'else' and an 'else if'.

    Below are links to educational sites.
    http://www.dotnetperls.com/if
    https://www.w3schools.com/cs/cs_conditions.asp


    You can also require in the condition that the position must be flat.
    https://ninjatrader.com/support/help...etposition.htm
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi ChelseaB,

      Thanks for the response, but seem like if we use else it might not be the same as then. Since the next bar will also be trend == 1 and the order will fill again as a long position. Do you have an example where we can say if previous trend is -1 and current trend is +1 then entry long? That way it wont cause entry everytime we start the strategy at unwanted position?

      Comment


        #4
        Hello Taylor,

        Are you asking how to find the value from the previous bar?

        Use 1 as the bars Ago index.

        For example:
        if (AuSuperTrendU111.Trend[1] == -1 && AuSuperTrendU111.Trend[0] ==1)
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CaptainJack, 05-29-2026, 05:09 AM
        0 responses
        245 views
        0 likes
        Last Post CaptainJack  
        Started by CaptainJack, 05-29-2026, 12:02 AM
        0 responses
        157 views
        0 likes
        Last Post CaptainJack  
        Started by charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        165 views
        1 like
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        250 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        201 views
        0 likes
        Last Post CarlTrading  
        Working...
        X