Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Reversing Break Even Logic

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

    Reversing Break Even Logic

    Hello,Support!

    I`m trying to reverse the BE logic,so it should trigger when the price goes below entry(if long) and above entry(if short).

    Here`s the original logic snippet:

    Code:
    if(Position.MarketPosition == MarketPosition.Long)
    			{					
    				
    				//*****************************
    				// 			BreakEven
    				//*****************************
    				double bePrice = Position.AvgPrice + this.iAutoBreakEvenTicks * TickSize;												
    				
    				if(
    					// BE turned on via input
    					this.iAutoBreakEvenTicks != 0 
    					// price moved for breakeven						
    					&& Close[0] > bePrice && bePrice != 0
    					)
    				{			
    					
    					double nPrice = Position.AvgPrice + this.iBreakEvenPlusTicks * TickSize;										
    					for(int i = 1 ; i <= 3 ; i++)
    					{
    						if(tVars.iStopOrder[i] != null)
    						{
    							if(nPrice > tVars.iStopOrder[i].StopPrice)							
    								SubmitTargStop(sBIP, i, tVars.iStopOrder[i].FromEntrySignal, tVars.iStopOrder[i].Quantity, 0, nPrice);																			
    						}						
    					}									
    				}
    I`m trying to reverse the logic by doing this:

    Code:
    if(Position.MarketPosition == MarketPosition.Long)
    			{					
    				
    				//*****************************
    				// 			BreakEven
    				//*****************************
    				double bePrice = Position.AvgPrice - this.iAutoBreakEvenTicks * TickSize;												
    				
    				if(
    					// BE turned on via input
    					this.iAutoBreakEvenTicks != 0 
    					// price moved for breakeven						
    					&& Close[0] < bePrice && bePrice != 0
    					)
    				{			
    					
    					double nPrice = Position.AvgPrice - this.iBreakEvenPlusTicks * TickSize;										
    					for(int i = 1 ; i <= 3 ; i++)
    					{
    						if(tVars.iTargOrder[i] != null)
    						{
    							if(nPrice > tVars.iTargOrder[i].LimitPrice)							
    								SubmitTargStop(sBIP, i, tVars.iTargOrder[i].FromEntrySignal, tVars.iTargOrder[i].Quantity, 0, nPrice);																			
    						}						
    					}									
    				}
    Im also trying to get the Target order to be adjusted to the BE level instead of the Stop order,as per original logic.

    Nothing seems to work properly.What am i doing wrong?Any advices appreciated!

    Thanks!

    #2
    Hello,

    Thanks for your post.

    Just to clarify, if you are in a long position you want to change the breakeven trigger to be less than the breakeven/entry price?

    Typically a breakeven stop is used when you are in a positive position to protect against loss.

    Comment


      #3
      Originally posted by NinjaTrader_Paul View Post
      Hello,

      Thanks for your post.

      Just to clarify, if you are in a long position you want to change the breakeven trigger to be less than the breakeven/entry price?

      Typically a breakeven stop is used when you are in a positive position to protect against loss.
      I want the target order to be trigered and moved to the entry level,when i`m in negative position.

      Comment


        #4
        Hello,

        Thanks for your reply.

        A breakeven stop, in the case of a long position typically would be a stop order below price. If I understand you correctly, you want to move the target, which would typically be a limit order, to the entry price.

        You would want to move the target order.

        Comment


          #5
          Originally posted by NinjaTrader_Paul View Post
          Hello,

          Thanks for your reply.

          A breakeven stop, in the case of a long position typically would be a stop order below price. If I understand you correctly, you want to move the target, which would typically be a limit order, to the entry price.

          You would want to move the target order.
          I try exactly that as you may see in the second example in this post:



          To move the target order but it doesn`t work

          Comment


            #6
            Hello,

            Thanks for your reply.

            We do not know how SubmitTargStop() is going to handle the operators you submit to it. You need to debug your script if it is not performing as you need.

            If this is not your script, then please contact the developer.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            601 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            347 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            103 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            559 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            558 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X