Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stop Entry Working

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

    Stop Entry Working

    I am having a challenge with the entry conditions in a strategy. Lets say once the indicator give the buy signal I place a stop order 10 pips above the market. As long as the indicator continues to give the buy signal I would like to keep the original order working. How do I go about this?

    Example:

    Code:
    if((ToTime(Time[0]) >= 020000) && (ToTime(Time[0]) <= 140000)  && (Indicator1[0] > Indicator1[1]) && Indicator1[1] < Indicator1[2]))
    {
      Order placement based on High of bar when the signal was first true.
    }
    now as long as each new instance of Indicator1 is greater than the previous bar Indicator1 I would like the order to remain placed at the High + 10 pips of the first bar where the entry logic was valid. Meaning if on the 3rd bar after the if statement above is true the order would be place at High[3] + 10 pips.

    Thanks!

    GT

    #2
    GreenTrade,

    Hard set the value into a variable and then just keep calling that variable.

    Untested code. You will have to determine a point in time to reset that bool variable too.
    Code:
    if(ToTime()..... Indicator[0] > Indicator[1])
    {
          if (firstBarOfOrder)
          {
               limitPrice = High[0];
               firstBarOfOrder = false;
          }
          EnterLongLimit(.....limitPrice....);
    }
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      As always thank you for your help with this. I understand the concept of what you are saying and know what I need to do now. One issue I have is since the variable limitPrice (your code sample) is inside of the if(firstBarOfOrder) brackets it is not know during the EnterLongLimit line. I attempted to put this idea to use and when compiling get the error message "The name 'limitPrice' does not exist in the current context." Any thought on how to get this to work?

      Thanks!

      GT

      Comment


        #4
        Declare the variable in the variables region of your code.

        private double limitPrice = 0;
        Josh P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        558 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        324 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        545 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        547 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X