• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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 Coursocied67, Today, 04:02 AM
        0 responses
        1 view
        0 likes
        Last Post Coursocied67  
        Started by TheGameOfProbabilities, 07-18-2019, 06:56 AM
        7 responses
        35 views
        0 likes
        Last Post DaveS
        by DaveS
         
        Started by scfnkysx, Today, 12:30 AM
        0 responses
        4 views
        0 likes
        Last Post scfnkysx  
        Started by jimloforkocv, Today, 12:16 AM
        0 responses
        4 views
        0 likes
        Last Post jimloforkocv  
        Started by claxxical, Yesterday, 10:00 PM
        0 responses
        8 views
        0 likes
        Last Post claxxical  
        Working...
        X