Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

StopLoss error

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

    StopLoss error

    Hi,

    I got the following error in my strategy:-

    Code:
    **NT** Stop/target handling for strategy 'MyCustomFXStrategy2v7alt' set to 'ByStrategyPosition' since currency based stop order was placed.
    After this message showed up in the log and output, my strategy just entered and exitted the trade at the same time and price.

    What went wrong?

    Regards

    Kay Wai

    #2
    Kay, those are likely unrelated, for a currency based order ByStrategyPosition would simply be used, since it applies to the complete position.

    It looks like the entry / exit issue is related to your other posts - is the stop loss value as you would expect from the TraceOrders / debug output?

    Comment


      #3
      Hi Bertrand,

      This is one I wanted to do:-

      Code:
      [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]
      if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#000000] (((Position.AvgPrice-LongStopLoss)*[/COLOR][/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]100000[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#000000]) < LongStopLossAlt)[/COLOR]
      {
      SetStopLoss(CalculationMode.Price, LongStopLoss);
      }
      [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]else
      [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]{
      SetStopLoss(CalculationMode.Ticks, [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]12[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]);
      }
      [/SIZE][/FONT][/SIZE][/FONT]
      In the latter SetStopLoss, I had placed a value of $120 and that is when the "error" showed up in the log. So I changed it to "ticks" instead but it isn't what I really want.

      Regards

      Kay Wai

      Comment


        #4
        If you set it to the currency value and then run the strategy 'ByStrategyPosition' that should work without giving you a log error.

        Comment


          #5
          Hi Bertrand,

          That was the line that showed up in the log window. It was an orange colored line. Error or no error, there was a message. So, I used "ticks" instead which is not really what I wanted to so.

          Regards

          Kay Wai

          Comment


            #6
            Kay, so it's working like you would expect if you use 'ByStrategyPosition'?

            Comment


              #7
              Well I didn't like the orange message in my log, so I recoded it. Now, I don't get the orange message.

              Didn't affect the remainder of my code. Some of my positions are still entered and exited at the same price.

              Comment


                #8
                Correct, the error is likely not related to your stop loss issues seen.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                673 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                379 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                111 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                577 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                582 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X