• 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

Swing stops being placed too far

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

    Swing stops being placed too far

    https://gyazo.com/b73eec101025291b2c9dcf4d0d8b4481

    They are appearing way to far away and the stops arent trailing, not sure whats going on my code looks good

    // Swing Stops

    if(Position.MarketPosition == MarketPosition.Long)
    {
    SetStopLoss(CalculationMode.Ticks, Swing(5).SwingLow[0] - 3 * TickSize);
    }

    if(Position.MarketPosition == MarketPosition.Short)
    {
    SetStopLoss(CalculationMode.Ticks, Swing(5).SwingHigh[0] + 3 * TickSize);
    }

    //Breakeven at 10 ticks then plus 2 ticks

    if (Position.MarketPosition == MarketPosition.Long
    && Close[0] >= Position.AvgPrice + 9 * TickSize)

    {
    SetStopLoss(Position.AvgPrice + 2 * TickSize);
    }

    if (Position.MarketPosition == MarketPosition.Short
    && Close[0] < Position.AvgPrice - 9 * TickSize)
    {
    SetStopLoss(Position.AvgPrice - 2 * TickSize);
    }

    //Trail behind Adaptive Moving Average by 2 ticks, after 12 ticks

    if (Position.MarketPosition == MarketPosition.Long
    && Close[0] > Position.AvgPrice + 12 * TickSize)
    {
    SetStopLoss(CalculationMode.Ticks, KAMA(2, 10, 30)[0] - 2 * TickSize);
    }

    if (Position.MarketPosition == MarketPosition.Short
    && Close[0] < Position.AvgPrice - 12 * TickSize)
    {
    SetStopLoss(CalculationMode.Ticks, KAMA(2, 10, 30)[0] + 2 * TickSize);
    }

    #2
    Hello brucelevy,

    If you are going to placing the stop at a specific price, then use CalculationMode.Price and do not use CalculationMode.Ticks.

    You are setting the stop thousands of ticks below the entry.

    SetStopLoss(CalculationMode.Price, Swing(5).SwingLow[0] - 3 * TickSize);


    Also, for a trail to work you have to know the current price that the stop is set to. Attached is an example that demonstrates.
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      How would it be adapted for swings instead of fixed stops and trailing on an indicator rather than by a fixed amount

      Comment


        #4
        Hello brucelevy,

        In the example I posted, this moves the stop by calling it with a new price.

        For this you would supply the new swing price calculation. Each time you call SetStopLoss this moves the stop loss to the new price.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Ok, I will try to figure it out.

          What if price is declining and the system buys but tries to put stops below the previous swing low, which in a declining market would be higher than the current swing low and higher than the buy entry point. This is causing me to have errors which disable the strategy. Are there any threads explaining this, has anyone published a robust swing stop system thread

          Comment


            #6
            Hello brucelevy,

            I am not aware of an existing strategy based on the swing indicator.

            When placing a sell stop, check the current bid price. If the price you are going to use is greater than the bid price do not allow this price to be used.

            double myPrice;

            if (myPrice <= GetCurrentBid())
            {
            SetStopLoss(CalculationMode.Price, myPrice);
            }
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by claxxical, Today, 10:00 PM
            0 responses
            5 views
            0 likes
            Last Post claxxical  
            Started by ct, Today, 08:13 PM
            0 responses
            6 views
            0 likes
            Last Post ct
            by ct
             
            Started by Lumbeezl, Today, 05:17 PM
            0 responses
            6 views
            0 likes
            Last Post Lumbeezl  
            Started by wishing, Today, 03:33 PM
            0 responses
            10 views
            0 likes
            Last Post wishing
            by wishing
             
            Started by ATMtrader0001, Today, 01:48 PM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_PaulH  
            Working...
            X