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 zstheorist, Today, 07:52 PM
      0 responses
      3 views
      0 likes
      Last Post zstheorist  
      Started by pmachiraju, 11-01-2023, 04:46 AM
      8 responses
      149 views
      0 likes
      Last Post rehmans
      by rehmans
       
      Started by mattbsea, Today, 05:44 PM
      0 responses
      5 views
      0 likes
      Last Post mattbsea  
      Started by RideMe, 04-07-2024, 04:54 PM
      6 responses
      33 views
      0 likes
      Last Post RideMe
      by RideMe
       
      Started by tkaboris, Today, 05:13 PM
      0 responses
      5 views
      0 likes
      Last Post tkaboris  
      Working...
      X