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 timmbbo, Today, 08:59 AM
    1 response
    2 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by KennyK, 05-29-2017, 02:02 AM
    2 responses
    1,281 views
    0 likes
    Last Post marcus2300  
    Started by fernandobr, Today, 09:11 AM
    0 responses
    3 views
    0 likes
    Last Post fernandobr  
    Started by itrader46, Today, 09:04 AM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_Clayton  
    Started by bmartz, 03-12-2024, 06:12 AM
    5 responses
    33 views
    0 likes
    Last Post NinjaTrader_Zachary  
    Working...
    X