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 SalmaTrader, 07-07-2026, 10:26 PM
            0 responses
            45 views
            0 likes
            Last Post SalmaTrader  
            Started by CarlTrading, 07-05-2026, 01:16 PM
            0 responses
            22 views
            0 likes
            Last Post CarlTrading  
            Started by CaptainJack, 06-17-2026, 10:32 AM
            0 responses
            14 views
            0 likes
            Last Post CaptainJack  
            Started by kinfxhk, 06-17-2026, 04:15 AM
            0 responses
            20 views
            0 likes
            Last Post kinfxhk
            by kinfxhk
             
            Started by kinfxhk, 06-17-2026, 04:06 AM
            0 responses
            22 views
            0 likes
            Last Post kinfxhk
            by kinfxhk
             
            Working...
            X