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
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); } } } } }
Comment