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 cmoran13, Yesterday, 01:02 PM
        0 responses
        29 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        21 views
        0 likes
        Last Post PaulMohn  
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        160 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        95 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        148 views
        2 likes
        Last Post CaptainJack  
        Working...
        X