Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Break Even

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

    Break Even

    I have trouble to get my auto break even code to work with forex, working with ticks.
    I attached a sample code. Could you please have a look at it and tell what is wrong with it? Thanks a lot!
    Attached Files

    #2
    Hello moon_121,

    Thank you for your post.

    At first glance I do not see any items. Are there any errors in the Log tab of the NinjaTrader Control Center?

    Please refer to the following link for methods to debug your NinjaScript code: http://www.ninjatrader.com/support/f...ead.php?t=3418

    I look forward to your response.

    Comment


      #3
      Flat

      Hi Patrick,
      i find it a bit strange, that my the auto break even seems to draw the strategy performance down instead of lifting it. I get the best performance, if the break even trigger is so far of, that the break even never kicks in.
      An if the break even kicks in, the amount of trades more than doubles.
      I'm wondering if that has anything to do with the setup of a strategy.
      Do I need to create a flat state to level the PnL?
      Do I need to define "Open PnL: "
      And how do I prevent the strategy to enter again in the position that was stopped by a break even one bar ago?

      Code:
      // Beginning of Auto-Break-Even
                  // If not flat print our unrealized PnL
                    if (Position.MarketPosition != MarketPosition.Flat)
                    Print("Open PnL: " + Position.GetProfitLoss(Close[0], PerformanceUnit.Points));
              
                  if (Position.GetProfitLoss(Close[0], PerformanceUnit.Points) > trigger * TickSize)
                  {
                  SetStopLoss(CalculationMode.Price, Position.AvgPrice + 1 * TickSize);
                  }
                  // Ende of Auto-Break-Even

      Comment


        #4
        Originally posted by moon_121 View Post
        Hi Patrick,
        i find it a bit strange, that my the auto break even seems to draw the strategy performance down instead of lifting it. I get the best performance, if the break even trigger is so far of, that the break even never kicks in.
        An if the break even kicks in, the amount of trades more than doubles.
        I'm wondering if that has anything to do with the setup of a strategy.
        Do I need to create a flat state to level the PnL?
        Do I need to define "Open PnL: "
        And how do I prevent the strategy to enter again in the position that was stopped by a break even one bar ago?

        Code:
        // Beginning of Auto-Break-Even
                    // If not flat print our unrealized PnL
                      if (Position.MarketPosition != MarketPosition.Flat)
                      Print("Open PnL: " + Position.GetProfitLoss(Close[0], PerformanceUnit.Points));
         
                    if (Position.GetProfitLoss(Close[0], PerformanceUnit.Points) > trigger * TickSize)
                    {
                    SetStopLoss(CalculationMode.Price, Position.AvgPrice + 1 * TickSize);
                    }
                    // Ende of Auto-Break-Even
        This might open your eyes as to why? (NB: I am still too much of a scaredy-cat, not to use stops myself, just so you know).

        Last edited by koganam; 01-11-2013, 11:57 AM.

        Comment


          #5
          @koganam
          Nice interview. I noticed the same with stops. I usually set them way back and pull them up to break even if I feel insecure about a position. Probably a bad idea for the performance, but its let me sleep a bit sounder.
          Last edited by moon_121; 01-11-2013, 12:32 PM.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by sidlercom80, 10-28-2023, 08:49 AM
          166 responses
          2,233 views
          0 likes
          Last Post sidlercom80  
          Started by thread, Yesterday, 11:58 PM
          0 responses
          1 view
          0 likes
          Last Post thread
          by thread
           
          Started by jclose, Yesterday, 09:37 PM
          0 responses
          6 views
          0 likes
          Last Post jclose
          by jclose
           
          Started by WeyldFalcon, 08-07-2020, 06:13 AM
          10 responses
          1,414 views
          0 likes
          Last Post Traderontheroad  
          Started by firefoxforum12, Yesterday, 08:53 PM
          0 responses
          11 views
          0 likes
          Last Post firefoxforum12  
          Working...
          X