Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

EnterLongLimit()

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

    EnterLongLimit()

    The EnterLongLimit() order method allows for a string signalName to be set.

    I'm guessing the answer will be no but thought I'd ask anyway: is there a way to set (or modify) the EnterLongLimit() string name after the actual order has been executed?

    #2
    Hello newuser,

    Thank you for your post.

    There would not be a means to change the signalName after execution.

    What are you attempting to achieve with this idea?

    Comment


      #3
      Hi Patrick,

      Thanks for the reply. I had an idea to get the Order ID from OnExecution and use that value in the signal name (for the entry, stop and profit) as a way of tracking trades.

      I wanted to do that because I have a strategy where the same condition set generates multiple open trades and I was having trouble implementing a breakeven strategy using BarsSinceEntry....but I since came up with another solution.

      I've actually had so much grief with this that I thought I'd post the solution just in case other users are having the same issue. I kind of thought it would be a common thing but I didn't find a similar issue anywhere and so I had to piece together a solution from several different sources.

      So I started by using an integer user variable that incremented if my conditions were met and then passed that count into the signal name like so:

      Code:
      private int count=0;
      
      if (//conditions)
      { count++;
        EnterLongLimit("Long"+count); }
      
      if (BarsSinceEntry()==1)
      { //execute code }
      The problem with this approach is the count iterates every time the conditions are met, so if the conditions are met on 2 consecutive bars then at BarsSinceEntry() == 1 the count value will be out of sync by 1 and will no longer reference the initial trade from the first bar. I fixed this with a user defined boolean variable:

      Code:
      if (//conditions)
      { count++;
        EnterLongLimit("Long"+count);
        trigger = true; }
      else { trigger = false }
      
      if (trigger = true)
      {  if (BarsSinceEntry("Long"+(count-1)) == 1)
         { // execute code }
      }
      
      else if (trigger = false)
      {  if (BarsSinceEntry("Long"+count) == 1)
         { // execute code }
      }
      Now the code syncs the signal names perfectly. If the conditions were met on the second bar it deducts one from the integer value used to reference the signal name (and if not then it doesn't).

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      607 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      353 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      105 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      560 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      561 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X