Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Checking my Stop

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

    Checking my Stop

    Hello,

    I am trying to get the code to check if the stop is filled. If it is filled, I want to enter in the direction of the stop. However, the code is not working. would you please help me finding the mistake:

    protected override void OnBarUpdate()
    {
    if (stopOrder01 != null && stopOrder01.Filled > 0)
    {
    EnterShort(Convert.ToInt32(Order01LotSize + Order02LotSize + Order03LotSize), "S11");
    SetStopLoss("S11", CalculationMode.Ticks, Order03SL, false);
    SetProfitTarget("S11", CalculationMode.Ticks, Order03PT, false);
    }
    }

    #2
    Hello Jorge.andres.o,

    Thanks for your post.

    You will need to use debug prints to check your work.

    Is the code reaching your Enter Short method?

    Please confirm by placing a print beside the order entry method.

    If the code is not reaching your EnterShort method, you will need to check the logic controlling this entry.

    Is stopOrder01 null?

    Is stopOrder.Filled greater than 0?

    Please confirm with a print for these properties that is placed just before your condition is evaluated.

    Debugging Tips - https://ninjatrader.com/support/help...script_cod.htm

    As another tip, if your order submission methods are being reached but the order is not submitting, please follow the TraceOrders feedback for a hint as to why the order was ignored.

    TraceOrders - https://ninjatrader.com/support/help...raceorders.htm

    I also suggest calling Set methods when the strategy is flat, and before the next entry order is submitted. Set methods prep NinjaTrader to submit target and stop when an associated Enter order comes back as filled. If the Enter method is processed and comes back as filled immediately, the order target and stop might be ignored. They should not be submitted after an Enter method.

    Please see the example below for properly using Set methods in OnBarUpdate.

    SamplePriceModification - https://ninjatrader.com/support/help...of_stop_lo.htm

    We look forward to assisting.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Bidder, Today, 09:16 PM
    0 responses
    11 views
    0 likes
    Last Post Bidder
    by Bidder
     
    Started by connorgrant5, Today, 07:12 PM
    0 responses
    18 views
    0 likes
    Last Post connorgrant5  
    Started by Trader_55, Today, 06:01 PM
    1 response
    15 views
    0 likes
    Last Post NinjaTrader_EricB  
    Started by aotubusen, Today, 04:28 PM
    0 responses
    19 views
    0 likes
    Last Post aotubusen  
    Started by amaltais, Today, 03:35 PM
    2 responses
    23 views
    0 likes
    Last Post amaltais  
    Working...
    X