The Orders are sent to the order manager and then immediately cancelled. I can only assume it has something to do with the Multi TF code I have added.
Although I have referred to it as "Multi Timeframe" I am actually using range bars of two periods (20 and 50 Range) Tick on Forex.
Code is Below:
protected override void Initialize() { SetProfitTarget("DonLa", CalculationMode.Ticks, WT1L); SetProfitTarget("DonSa", CalculationMode.Ticks, WT1S); ExitOnClose = false; CalculateOnBarClose = false; ClearOutputWindow(); Add(PeriodType.Range,50); //Added Second Time-Frame to Collect Data for Trend - Array Index is 1 } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { if (FirstTickOfBar) { trend = SMA(BarsArray[1],10)[0]; // Calculate the Trend Print(Instrument.FullName+":"+Position.MarketPosition+":"+Time); Print("Trend: "+trend); //Print(Bars.BarsSinceSession+":"+Time); // MA Entry Long if ( Close[currentBar] > SMA(Close,14)[currentBar] && Close[currentBar] > Open[currentBar] && Close[previousBar] <= SMA(Close,14)[previousBar] && Close[currentBar] >= trend ) { //Print ("MarketPosFromLong:"+Position.MarketPosition+":"+Position.Quantity); if (Position.MarketPosition == MarketPosition.Flat) { EnterLongLimit(wSingleOrderQuantity, Close[0]+(2*TickSize), "MALa"); Print ("EnterLong: "+Instrument.FullName+":"+Position.MarketPosition+":"+Position.AvgPrice+":"+Bars.BarsSinceSession+":"+Time); } //Always put a stop loss in! SetStopLoss(CalculationMode.Ticks, wStopL); } // MA Entry Short if ( Close[currentBar] < SMA(Close,14)[currentBar] && Close[currentBar] < Open[currentBar] && Close[previousBar] >= SMA(Close,14)[previousBar] && Close[currentBar] <= trend ) { //Print ("MarketPosFromShort:"+Position.MarketPosition+":"+Position.Quantity); if (Position.MarketPosition == MarketPosition.Flat) { EnterShortLimit(wSingleOrderQuantity, Close[0]-(2*TickSize), "DonSa"); //EnterShortLimit(wSingleOrderQuantity, Close[0]-(2*TickSize), "DonSb"); Print ("EnterShort: "+Instrument.FullName+":"+Position.MarketPosition+":"+Position.AvgPrice+":"+Bars.BarsSinceSession+":"+Time); } //Always put a stop loss in! SetStopLoss(CalculationMode.Ticks, wStopS); } } }
Comment