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

Order Reversal not resetting stop even.

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

    Order Reversal not resetting stop even.

    Hi,
    I have a stop even set on my automated strategy. It measures if the close of the current bar exceeds a certain value and adjusts the stop loss.

    My strategy makes position reversals more often than pure exits. I noticed that when a reversal occurs, the stop is not resetted to the standard one.

    This causes the stop even to be triggered by the previous movement and adjust the stop loss for the one that follows after the reversal.

    I am attaching a screenshot to show the example. In this case there were the following executions:

    1. Short - which was not profitable
    2. Long (reversed the short) - which was profitable and activated the stop even
    3. Short - which was not profitable and stop even (which was activated from previous movement) was hit (0.3% from entry price). Normal Stop is 0.7%.

    Currently the code has one reset on the stop even, which checks if 1 bar ago position was long and current bar position is short (and vice versa). When these conditions are met, the stop loss to be resetted....however I can't seem to find how to do that.

    Any input will be very much appreciated.



    And here is the code of the stopeven in my strategy.



    if (Position.MarketPosition == MarketPosition.Flat)
    {
    SetStopLoss("", CalculationMode.Percent, StopLoss, false);
    }

    else if (Position.MarketPosition == MarketPosition.Long)
    {// Once the price is greater than entry price+ ticks, set stop loss to breakeven
    if (Close[0] > Position.AvgPrice + StopEvenOffset * TickSize)
    {
    SetStopLoss(CalculationMode.Percent, StopEven);
    }}

    else if (Position.MarketPosition == MarketPosition.Short)
    {// Once the price is greater than entry price- ticks, set stop loss to breakeven
    if (Close[0] < Position.AvgPrice - StopEvenOffset * TickSize)
    {
    SetStopLoss(CalculationMode.Percent, StopEven);
    }}
    Attached Files
    Last edited by nikolaalx; 07-10-2014, 06:00 AM.

    #2
    Hello nikolaalx,

    Thank you for your post.

    Since, you are reversing positions on the same bar, the MarketPosition.Flat would not get called and reset your StopLoss()

    You will need to build a condition to reset your StopLoss or reset it in the same condition when you enter into the positions
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Thanks I have added it as an additional action for each of my entries and that solved it.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by arvidvanstaey, Today, 02:19 PM
      4 responses
      11 views
      0 likes
      Last Post arvidvanstaey  
      Started by samish18, 04-17-2024, 08:57 AM
      16 responses
      61 views
      0 likes
      Last Post samish18  
      Started by jordanq2, Today, 03:10 PM
      2 responses
      9 views
      0 likes
      Last Post jordanq2  
      Started by traderqz, Today, 12:06 AM
      10 responses
      18 views
      0 likes
      Last Post traderqz  
      Started by algospoke, 04-17-2024, 06:40 PM
      5 responses
      48 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X