Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Move stop to Break Even error

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

    Move stop to Break Even error

    I am unable to move my stop to breakeven after the 1st contract is filled, even though my code prints to the output window correctly, the stop order does not change in the DOM. I turned on trace orders and, it shows there is an error. Can someone help me fix this issue?

    Output window shows:
    2/24/2014 7:33:53 AM Ignored internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Price Value=1847 Currency=0 Simulated=False' Reason='Another SetStopTarget() method call has already submitted a stop/target order'
    Move long stop b/e1847


    Code:
    protected override void Initialize()
            {
    
                           CalculateOnBarClose = false;
    			EntriesPerDirection = 2;
    			EntryHandling 		= EntryHandling.UniqueEntries;
    			SetProfitTarget("a",CalculationMode.Ticks,12);
    			SetProfitTarget("b",CalculationMode.Ticks,8);
    			//SetStopLoss(CalculationMode.Ticks,8);
    			
    			
            }
    
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate()
            {
                // Condition set 1
                if(!Historical){
    				if(Position.MarketPosition == MarketPosition.Flat)
    				{
    					Random rnd = new Random();
    					if(rnd.Next(10) >= 5){
    						SetStopLoss("a",CalculationMode.Ticks,8,false);
    						SetStopLoss("b",CalculationMode.Ticks,8,false);
    						EnterLongLimit(Close[0],"a"); 
    						EnterLongLimit(Close[0],"b");
    						filledOne = true;
    						
    					}else{
    						SetStopLoss("a",CalculationMode.Ticks,8,false);
    						SetStopLoss("b",CalculationMode.Ticks,8,false);
    						EnterShortLimit(Close[0],"a");
    						EnterShortLimit(Close[0],"b");
    						filledOne = true;
    						
    					}
    				}
    				else{
    					if(Position.Quantity == 1 && filledOne){
    						if(Position.MarketPosition == MarketPosition.Long && Close[0] > Position.AvgPrice + 1){
    							SetStopLoss("b",CalculationMode.Price,Position.AvgPrice,false);
    							filledOne = false;
    							Print("Move long stop b/e" + Position.AvgPrice);
    						}
    						else if(Position.MarketPosition == MarketPosition.Short && Close[0] < Position.AvgPrice - 1){
    							SetStopLoss("b",CalculationMode.Price,Position.AvgPrice,false);
    							filledOne = false;
    							Print("Move short stop b/e" + Position.AvgPrice);
    						}
    
    					}
    				}
    			}
    			
            }
    Last edited by habibalex; 03-09-2014, 04:31 PM.

    #2
    Hello habibalex,

    Thank you for your post.

    Can you provide the full strategy code in it's .cs file format to test further on my end? Can you also provide your log and trace files so I may investigate this error message further? In addition, please advise what instrument, period type and interval you are testing the strategy on.

    You can do this by going to the Control Center-> Help-> Mail to Support-> ensure the log and trace option is enabled and attach the strategy's .cs file to your response. You will find the file under (My) Documents\NinjaTrader 7\bin\Custom\Strategy. Please place 'ATTN: Patrick - 1032148' in the subject line and a reference to this thread in the body of the e-mail: http://www.ninjatrader.com/support/f...ad.php?t=64505

    Comment


      #3
      sorry for the late reply, i am sending it right now

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      633 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      364 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      105 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      567 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      568 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X