Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

enterlong cummulatively

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

    enterlong cummulatively

    i have a code that allow adding position progressively.

    like

    int shares = 0;
    protected override void OnBarUpdate()
    {
    if(A){
    enterlong(1, "initial");
    shares = 1;
    }
    if(B){
    enterlong(1,"add");
    shares = shares +1
    }

    if(C){
    entershort(shares , "exit");
    shares = 0;
    }
    }



    The problem is when i do backtesting, it has me "initial 1 @0.9095". And the next trade is exit 4 @0.9100, Close position 1 @0.9100. There should be another 3 "add 1 @***". Actually, the "add" trades never show up in the whole backtesting period even though I am very confident that the if(B) statement is triggered a lot (otherwise, exit won't sell more than 1).

    Cam some one tell me why it does not add position?

    #2
    Hi Sunjoke,

    Thank you for posting and welcome to the forums!

    Are you using Unique Entries for your backtest parameters?

    What is your Entries Per Direction set to?

    I would suggest adding a DrawDot() to the IF condition B to see if indeed this is being met.
    Additionally, add TraceOrders to the Initialize section of the code so that you can see if orders are getting ignored and why.
    TraceOrders
    DrawObjects

    Thank you
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Cal View Post
      Hi Sunjoke,

      Thank you for posting and welcome to the forums!

      Are you using Unique Entries for your backtest parameters?

      What is your Entries Per Direction set to?

      I would suggest adding a DrawDot() to the IF condition B to see if indeed this is being met.
      Additionally, add TraceOrders to the Initialize section of the code so that you can see if orders are getting ignored and why.
      TraceOrders
      DrawObjects

      Thank you
      The reason was that I did not set entry per direction. After setting that, it is resolved. thanks.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by wzgy0920, 04-20-2024, 06:09 PM
      2 responses
      26 views
      0 likes
      Last Post wzgy0920  
      Started by wzgy0920, 02-22-2024, 01:11 AM
      5 responses
      32 views
      0 likes
      Last Post wzgy0920  
      Started by wzgy0920, Yesterday, 09:53 PM
      2 responses
      49 views
      0 likes
      Last Post wzgy0920  
      Started by Kensonprib, 04-28-2021, 10:11 AM
      5 responses
      191 views
      0 likes
      Last Post Hasadafa  
      Started by GussJ, 03-04-2020, 03:11 PM
      11 responses
      3,231 views
      0 likes
      Last Post xiinteractive  
      Working...
      X