Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy exits the trade on the next bar after entry

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

    Strategy exits the trade on the next bar after entry

    I just created an automated strategy using Ninjascript. And the challenge is for some reason, the strategy ends up placing an exit trade on the very next bar after entering the trade. I checked and double checked my strategy, but there is nothing that is wrong codewise. I am even able to compile the strategy without any issues.

    Does anyone know what could be causing issue like this? A picture of some of the trades is attached.

    Very much appreciate you help in advance.
    Attached Files

    #2
    pandyav, the strategy exits as your long exit trade criteria is met, there's no discretion here in evaluating the implemented conditions by code. You would need to find out via debugging why the exit is placed this early, what condition do you exactly use for the exit? Is there any reference to BarsSinceEntry to ensure it could only trigger after a certain # of bars in the trade?
    BertrandNinjaTrader Customer Service

    Comment


      #3
      can you post the exit logic

      Comment


        #4
        Originally posted by pandyav View Post
        I just created an automated strategy using Ninjascript. And the challenge is for some reason, the strategy ends up placing an exit trade on the very next bar after entering the trade. I checked and double checked my strategy, but there is nothing that is wrong codewise. I am even able to compile the strategy without any issues.

        Does anyone know what could be causing issue like this? A picture of some of the trades is attached.

        Very much appreciate you help in advance.
        Your code is essentially like this:
        Code:
        CalculateOnBarClose = true;//or the blank default
        Code:
        if (entryConditions) EnterLong(...);
        ExitLong();
        Define your exit conditions to be subject to some conditions. If you have already done so, then most likely, you have terminated the if condition with a semi-colon, turning it into a null statement, hence running the Exit() command on every bar.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by algospoke, Yesterday, 06:40 PM
        2 responses
        22 views
        0 likes
        Last Post algospoke  
        Started by ghoul, Today, 06:02 PM
        3 responses
        14 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by jeronymite, 04-12-2024, 04:26 PM
        3 responses
        45 views
        0 likes
        Last Post jeronymite  
        Started by Barry Milan, Yesterday, 10:35 PM
        7 responses
        21 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by AttiM, 02-14-2024, 05:20 PM
        10 responses
        181 views
        0 likes
        Last Post jeronymite  
        Working...
        X