Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.





    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by mjairg, 07-20-2023, 11:57 PM
    3 responses
    213 views
    1 like
    Last Post PaulMohn  
    Started by TheWhiteDragon, 01-21-2019, 12:44 PM
    4 responses
    543 views
    0 likes
    Last Post PaulMohn  
    Started by GLFX005, Today, 03:23 AM
    0 responses
    3 views
    0 likes
    Last Post GLFX005
    by GLFX005
     
    Started by XXtrader, Yesterday, 11:30 PM
    2 responses
    12 views
    0 likes
    Last Post XXtrader  
    Started by Waxavi, Today, 02:10 AM
    0 responses
    7 views
    0 likes
    Last Post Waxavi
    by Waxavi
     
    Working...
    X