Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

EnterLongLimit only if price hit or above X.

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

    EnterLongLimit only if price hit or above X.

    I am developing a strategy, where it will enter long limit, when the price hit above X. However, if price at that moment is below X, EnterLongLimit will just take the X price (expensive price), which is not what I intended.


    This is my code snippet:

    Code:
    protected override void OnBarUpdate()
    {
    	EnterLongLimit(54.2, "");
    	SetProfitTarget(CalculationMode.Price, 54.36);
    }
    I am testing on CL 04-15 from 1st January 2015 till 20th January 2015, and this is the bar chart I got, see attachment. I don't want it to enter position, if the price is below X.

    So, m question is, how to let the strategy to enter market, only when the price is higher than or equal to X? I tried if Close[0] >= X, but in backtest, the Close[0] is referring to the close of bar, instead of the price at that moment.

    Thanks, and sorry if my question is not clear enough. I will provide more info and explanation if needed.
    Attached Files

    #2
    Hello vhanded,

    Limit orders fill at the specified price or better.

    If you place a buy limit order way above the market it fills immediately. This is true even of manual orders that you place (try placing a buy limit order way above market on the SuperDOM).

    If you want to ensure that the order is not placed unless the price is below a certain amount, make this a condtion.

    If (Close[0] < 50.1)
    {
    EnterLongLimit(54.2, "");
    }
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      I just found out about EnterLongStop and EnterShortStop. Why can't we use these?

      Comment


        #4
        Hello vhanded,
        Yes you could absolutely use EnterLongStop or EnterShortStop if you are wanting to place a predefined market order before the price reaches that point.

        An example of how you could use this is below:
        if (Close[0] > 50.1)
        {
        EnterLongStop(54.2 "')
        }
        In addition you could use EnterLongStopLimit() or EnterShortStopLimit as an order method.
        I have provided a link on EnterLongStopLimit() here, http://www.ninjatrader.com/support/h...gstoplimit.htm
        In addition here is alink on EnterShortStopLimit() http://www.ninjatrader.com/support/h...tstoplimit.htm
        Cody B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        648 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        369 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        108 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        572 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        573 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X