Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

EnterLongStop market order problem

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

    EnterLongStop market order problem

    Good afternoon,
    I need a help please, my strategy does not let me enter on a price of previous candle using EnterLongStopMarket.

    I honestly do not understand why, the entry order and price should be correct

    entryOrder_1 = EnterLongStopMarket(0, false, 1,Open[1], "F1_entry" + a);

    I have attached error message from output window and Log tab, bellow is my code.
    CODE
    Code:
            protected override void OnBarUpdate()
            {
                  if (CurrentBar < 20)
                   return;
    
        if (High[0] > High[1] && High[1] > High[2] && Low[0] > Low[1] && Low[1] > Low[2] & Open[0] > Close[2] & Open[0] < Close[0] & Open[2] < Close[2]  
                  
         //&& Position.MarketPosition == MarketPosition.Flat
         //&& IsFirstTickOfBar
            //&& BarsInProgress == 0      
            )
        {    
        ++a;
            
            
        entryOrder_1 = EnterLongStopMarket(0, false, 1,Open[1], "F1_entry" + a);
            
         Draw.ArrowUp(this, "F1" + a, true, 0, Low[0] - TickSize, Brushes.Lime);
         
         barLong = CurrentBar;
     
        }          
            
            
    
      
        }
    on state change
    Code:
        protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
                    Description                                = @"Sample  Using OnOrderUpdate() and OnExecution() methods to submit protective  orders";
                    Name                                    = "audusdtest";
                    Calculate                               = Calculate.OnBarClose; // Calculate.OnEachTick; // Calculate.OnBarClose
                    EntriesPerDirection                     = 100;
                    EntryHandling                           = EntryHandling.AllEntries;
                    IsExitOnSessionCloseStrategy            = true;
                    ExitOnSessionCloseSeconds               = 30;
                    IsFillLimitOnTouch                      = false;
                    MaximumBarsLookBack                     = MaximumBarsLookBack.TwoHundredFiftySix;
                    OrderFillResolution                     = OrderFillResolution.Standard;
                    Slippage                                = 1;
                    StartBehavior                           = StartBehavior.WaitUntilFlat;
                    TimeInForce                             = TimeInForce.Gtc;
                    TraceOrders                             = true;
                    RealtimeErrorHandling                   = RealtimeErrorHandling.StopCancelClose;
                    StopTargetHandling                      = StopTargetHandling.PerEntryExecution;
                    BarsRequiredToTrade = 10;
      }
      else if (State == State.Configure)
      {
      
      }
    
    }
    Does anybody know why it is not working?

    Thank you
    Attached Files

    #2
    Hello Filip88,

    Thank you for your note.

    Stop orders entered to close to the current bid/ask are going to be rejected by the broker/exchange, and even the SIM101 account in NinjaTrader is going to simulate this rejection.

    Stop orders should be placed far enough from the current market so that by the time they hit the exchange, that stop price is not invalid. For example, last bars open was 50.50, current bid is 50.49 and current offer 50.50, you submit a EnterLongStop at 50.50, this would trigger the stop immediately and should have been sent as a market order, thus rejected.

    If you swap,

    Code:
     entryOrder_1 = EnterLongStopMarket(0, false, 1,Open[1], "F1_entry" + a);
    for,

    Code:
     entryOrder_1 = EnterLongStopMarket(0, false, 1,[B]Open[1]+5*TickSize[/B], "F1_entry" + a);
    Or include logic to only submit the order if the current ask is more than 2-5 ticks below last bars open your order should be submitted. For example,

    Code:
    if(Open[1] - 5*TickSize > GetCurrentAsk())
     entryOrder_1 = EnterLongStopMarket(0, false, 1,Open[1], "F1_entry" + a);
    See GetCurrentAsk,


    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      now i understand, thank you

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by alifarahani, Today, 09:40 AM
      6 responses
      31 views
      0 likes
      Last Post alifarahani  
      Started by Waxavi, Today, 02:10 AM
      1 response
      17 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Started by Kaledus, Today, 01:29 PM
      5 responses
      14 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by Waxavi, Today, 02:00 AM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Started by gentlebenthebear, Today, 01:30 AM
      3 responses
      17 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X