Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BarsSinceExitExecution Question

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

    BarsSinceExitExecution Question

    In my strategy under certain conditions I scale in. In these instances, when the "scale in" position closes, I would also like to close the original position early instead of waiting for it to hit its original profit target so I added the following code;

    if(BarsSinceExitExecution(@"Long Scale In") == 0);

    {
    ExitLong(@"TrendBot Long");
    }

    When this code is implemented, the original position (TrendBot Long) closes on the same bar that it opens on without the Scale In Position ever opening. It seems as if the BarsSinceExitExecution is being applied to the TrendBot Long position and not to the Long Scale In position. What am I missing to only apply the BarsSinceExitExecution to the Long Scale In position?

    Thanks for any help with this.

    #2
    Hello Safetrader,

    It is possible the signal name you used was not found, have you tried to print the value of BarsSinceExitExecution to see what the value was at that time?

    == 0 implies that the exit was on the same bar, if you want it later you need to use greater than 0.

    When this code is implemented, the original position (TrendBot Long) closes on the same bar that it opens on without the Scale In Position ever opening.
    If you are having problems with the scale in position not being opened that may relate to the entry logic as well. Prints would be the best suggestion to verify all conditions you made are working as you had expected.





    Comment

    Latest Posts

    Collapse

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