• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stop not working in Real Time

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

    Stop not working in Real Time

    I have a Strategy that submits an order followed by an unmanaged stop. The strategy works as designed in backtest but when I try running it in realtime with IB Simulated envirment the stop does not get submitted. Here is the effected statements statements.
    protected override void Initialize()
    {
    CalculateOnBarClose = true;
    BarsRequired = 25;
    TraceOrders = false;
    ExitOnClose = true;
    Unmanaged = true;

    // for speed set to true
    ExcludeTradeHistoryInBacktest = false;

    Add(PeriodType.Minute,SecBarLen);


    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {

    if(BarsInProgress == 0)
    {
    MinBars();
    }
    else
    {
    HourBars();
    }


    } // End On Bar Update

    private void HourBars()
    {
    // Market is Long -- Test for exit
    if (Position.MarketPosition == MarketPosition.Long)
    {
    entryOrder = SubmitOrder(0, OrderAction.Sell, OrderType.Market, Quanity, 0, 0, "L", "ExitLong");
    }

    // Market is Short -- Test for exit
    if (Position.MarketPosition == MarketPosition.Short)
    {
    entryOrder = SubmitOrder(0, OrderAction.Buy, OrderType.Market, Quanity, 0, 0, "S", "ExitShort");
    }


    } // End HourBars
    private void MinBars()
    {

    if (Position.MarketPosition == MarketPosition.Long)
    {

    entryOrder = SubmitOrder(0, OrderAction.Sell, OrderType.Stop, Quanity, 0, NewStop, "L", "BreakLong");



    } // End Long
    if (Position.MarketPosition == MarketPosition.Short)
    {

    entryOrder = SubmitOrder(0, OrderAction.Buy, OrderType.Stop, Quanity, 0, NewStop, "S", "BreakShort");
    //

    } // End Short


    } // End of MinBars

    #2
    Reposted in Strategy where it should have been. GB

    Comment


      #3
      Thanks, just replied on your repost there.
      BertrandNinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by ChazJ, Today, 02:54 PM
      1 response
      3 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by Boonfly8, Today, 02:04 PM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_PaulH  
      Started by Branpo, Today, 01:25 PM
      5 responses
      11 views
      0 likes
      Last Post NinjaTrader_ChrisL  
      Started by aslane, Today, 12:47 PM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by HavasuTrader, Today, 12:30 PM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_PatrickG  
      Working...
      X