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 Option Whisperer, Today, 09:55 AM
      1 response
      11 views
      0 likes
      Last Post bltdavid  
      Started by port119, Today, 02:43 PM
      0 responses
      1 view
      0 likes
      Last Post port119
      by port119
       
      Started by Philippe56140, Today, 02:35 PM
      0 responses
      3 views
      0 likes
      Last Post Philippe56140  
      Started by 00nevest, Today, 02:27 PM
      0 responses
      1 view
      0 likes
      Last Post 00nevest  
      Started by Jonafare, 12-06-2012, 03:48 PM
      5 responses
      3,986 views
      0 likes
      Last Post rene69851  
      Working...
      X