Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy only entering long trades

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

    Strategy only entering long trades

    protected override void Initialize()
    {
    EntriesPerDirection = 1;
    CalculateOnBarClose = true;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    {
    //Check for open positions
    if (Position.MarketPosition == MarketPosition.Flat)
    {
    //Long Entry
    if (RSI(14,3)[0]>50);
    {
    //Calc Long Entry Price
    EnterLongLimit();
    SetProfitTarget();
    SetStopLoss();
    }
    if (RSI(14,3)[0]<50);
    {
    //Enter Short on Market Order
    EnterShortLimit();
    SetProfitTarget();
    SetStopLoss();
    }

    I am only getting long trades and for some reason it is still entering bids when RSI is below 50

    #2
    Hello,
    With your if statements before the order entry commands you have a semicolon at the end of the if statement. This runs the check and then does nothing. Then the strategy is told to enterlong on every bar update. As there is always a buy limit order being placed the strategy can not place a sell limit order as this would go against the internal order handling rules(Internal Order Handling Rules)

    If you remove the semicolons after your if statements you should see the strategy place the buy limit and sell limit orders correctly.

    Please let us know if we can be of any other assistance.
    Cody B.NinjaTrader Customer Service

    Comment


      #3
      Thank you!

      Still very new to the coding process, need to be better about paying attention to the details!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      86 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      48 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      29 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      32 views
      0 likes
      Last Post TheRealMorford  
      Started by Mindset, 02-28-2026, 06:16 AM
      0 responses
      67 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X