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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      63 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      35 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      54 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      61 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      48 views
      0 likes
      Last Post CarlTrading  
      Working...
      X