Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SetTrailStop vs. SetStopLoss?

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

    SetTrailStop vs. SetStopLoss?


    Hi there, I'm having a problem with SetTrailStop. If my code is:

    SetProfitTarget(CalculatioMode.Ticks, 10);
    SetStopLoss(CalculationMode.Ticks, 10);
    EnterShort():

    then all is good. However, if I go with SetTrailStop instead, of


    SetProfitTarget(CalculatioMode.Ticks, 10);
    SetTrailStop(CalculationMode.Ticks, 10);
    EnterShort():

    then I get errors:

    Stop price can not be changed above the market, aeffected order: Sell 1 StopMarket
    Strategy submitted an order tha generated the following error: Unable to change order. Strategy has sent cancel request, attempted to close the position and terminate itself.


    Obviously, something is going on that I don't understand. Can you explain why SetTrailStop is failing me? Thanks,






    #2
    Hello, thanks for writing in. It looks like the error is coming from a Sell stop market order, which would be attached to a buy order. Make sure you are setting a unique stop loss for each entry order e.g.

    //SetTrailStop(string fromEntrySignal, CalculationMode mode, double value, bool isSimulatedStop)
    SetTrailStop("LongEntry", CalculationMode.Ticks, 10, false);
    EnterLong("LongEntry");

    //and also for the short entry

    SetTrailStop("ShortEntry", CalculationMode.Ticks, 10, false);
    EnterShort("ShortEntry");​

    Comment


      #3

      Chris, thanks, although apparently I'm still getting the same error. I get error messages:

      Strategy submitted an order that generate the following error: Unable to change order. Strategy has sent cancel requests, attempted to close the position and terminate itself.
      Stop price can't be changed below the market.

      I'm using the SampleMAStrategy. The relevant code is:


      else if (State == State.Configure) {
      SetProfitTarget("MyTrade", CalculationMode.Ticks, 6, false);
      SetTrailStop("MyTrade", CalculationMode.Ticks, 6, false);
      }

      .....

      if (CrossAbove(smaFast, smaSlow, 1))
      EnterLong("MyTrade");
      else if (CrossBelow(smaFast, smaSlow, 1))
      EnterShort("MyTrade");


      Your thoughts on how to correct? Thanks,


      Comment


        #4
        Hi, you should make the signal names unique:

        SetProfitTarget("MyLongTrade", CalculationMode.Ticks, 6, false);
        SetTrailStop("MyLongTrade", CalculationMode.Ticks, 6, false);​
        SetProfitTarget("MyShortTrade", CalculationMode.Ticks, 6, false);
        SetTrailStop("MyShortTrade", CalculationMode.Ticks, 6, false);​


        if (CrossAbove(smaFast, smaSlow, 1))
        EnterLong("MyLongTrade");
        else if (CrossBelow(smaFast, smaSlow, 1))
        EnterShort("MyShortTrade");
        ​​

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        66 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        141 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        76 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        47 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        51 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X