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 burtoninlondon, Today, 12:38 AM
      0 responses
      10 views
      0 likes
      Last Post burtoninlondon  
      Started by AaronKoRn, Yesterday, 09:49 PM
      0 responses
      14 views
      0 likes
      Last Post AaronKoRn  
      Started by carnitron, Yesterday, 08:42 PM
      0 responses
      11 views
      0 likes
      Last Post carnitron  
      Started by strategist007, Yesterday, 07:51 PM
      0 responses
      13 views
      0 likes
      Last Post strategist007  
      Started by StockTrader88, 03-06-2021, 08:58 AM
      44 responses
      3,983 views
      3 likes
      Last Post jhudas88  
      Working...
      X