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 Max238, Today, 01:28 AM
        3 responses
        30 views
        0 likes
        Last Post Max238
        by Max238
         
        Started by timko, Today, 06:45 AM
        2 responses
        12 views
        0 likes
        Last Post NinjaTrader_ChristopherJ  
        Started by habeebft, Today, 07:27 AM
        0 responses
        4 views
        0 likes
        Last Post habeebft  
        Started by Tim-c, Today, 03:54 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by rocketman7, Today, 01:00 AM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X