There is a simple strategy code. What it does it simply wants to fade the main instrument when instrument's in background added via Add() method, price moves specified amount of points-ticks within specified number of bars. And it is simple reversal - enters when conditions are met and reverses when conditions met for opposite direction.
Let's say I load a strategy on ES 03-09 chart and via Add i want to add 'MSFT'. As soon as MSFT price moves up 10 cents within last 2 bars, I want to short ES and hold it until MSFT price will do 10 cent downmovement, then reverse.
Also I want MSFT price check on bar close, and enter ES intrabar.
protected override void Initialize()
{
CalculateOnBarClose = false;
Add(bsym, bperiodtype, bvalue);
}
protected override void OnBarUpdate()
{
if (BarsInProgress == 1 && FirstTickOfBar)
{
if (High[1] >= MIN(Low, lookback)[2] + priceoffset && Close[1] >= Median[1])
{
DrawDot(CurrentBar.ToString()+"s", true, 0, Highs[0][0] + 2*TickSize, Color.Red);
if (entryOrder == null) entryOrder = EnterShort(0,tradingsize,"sell");
}
if (Low[1] <= MAX(High, lookback)[2] - priceoffset && Close[1] <= Median[1])
{
DrawDot(CurrentBar.ToString()+"b", true, 0, Lows[0][0] - 2*TickSize, Color.Green);
if (entryOrder == null) entryOrder = EnterLong(0,tradingsize,"buy");
}
}
}
protected override void OnOrderUpdate(IOrder order)
{
if (entryOrder != null && entryOrder.Token == order.Token)
{
Print(order.ToString());
if (order.OrderState == OrderState.Filled)
entryOrder = null;
}
}
Order='NT-00270/Sim101' Name='sell' State=PendingSubmit Instrument='ES 03-09' Action=SellShort Limit price=0 Stop price=0 Quantity=1 Strategy='ChrisFade' Type=Market Tif=Gtc Oco='' Filled=0 Fill price=0 Token='565260144e0a412394871ca578b301ed' Gtd='12/1/2099 12:00:00 AM'
Order='NT-00270/Sim101' Name='sell' State=Accepted Instrument='ES 03-09' Action=SellShort Limit price=0 Stop price=0 Quantity=1 Strategy='ChrisFade' Type=Market Tif=Gtc Oco='' Filled=0 Fill price=0 Token='565260144e0a412394871ca578b301ed' Gtd='12/1/2099 12:00:00 AM'
Order='NT-00270/Sim101' Name='sell' State=Working Instrument='ES 03-09' Action=SellShort Limit price=0 Stop price=0 Quantity=1 Strategy='ChrisFade' Type=Market Tif=Gtc Oco='' Filled=0 Fill price=0 Token='565260144e0a412394871ca578b301ed' Gtd='12/1/2099 12:00:00 AM'
Order='NT-00270/Sim101' Name='sell' State=Filled Instrument='ES 03-09' Action=SellShort Limit price=0 Stop price=0 Quantity=1 Strategy='ChrisFade' Type=Market Tif=Gtc Oco='' Filled=1 Fill price=768 Token='565260144e0a412394871ca578b301ed' Gtd='12/1/2099 12:00:00 AM'
Order='NT-00272/Sim101' Name='buy' State=PendingSubmit Instrument='ES 03-09' Action=Buy Limit price=0 Stop price=0 Quantity=1 Strategy='ChrisFade' Type=Market Tif=Gtc Oco='' Filled=0 Fill price=0 Token='d41927a62477439b941db2ca375bd61a' Gtd='12/1/2099 12:00:00 AM'
Order='NT-00272/Sim101' Name='buy' State=Accepted Instrument='ES 03-09' Action=Buy Limit price=0 Stop price=0 Quantity=1 Strategy='ChrisFade' Type=Market Tif=Gtc Oco='' Filled=0 Fill price=0 Token='d41927a62477439b941db2ca375bd61a' Gtd='12/1/2099 12:00:00 AM'
Order='NT-00272/Sim101' Name='buy' State=Working Instrument='ES 03-09' Action=Buy Limit price=0 Stop price=0 Quantity=1 Strategy='ChrisFade' Type=Market Tif=Gtc Oco='' Filled=0 Fill price=0 Token='d41927a62477439b941db2ca375bd61a' Gtd='12/1/2099 12:00:00 AM'
Order='NT-00272/Sim101' Name='buy' State=PendingCancel Instrument='ES 03-09' Action=Buy Limit price=0 Stop price=0 Quantity=1 Strategy='ChrisFade' Type=Market Tif=Gtc Oco='' Filled=0 Fill price=0 Token='d41927a62477439b941db2ca375bd61a' Gtd='12/1/2099 12:00:00 AM'
Order='NT-00272/Sim101' Name='buy' State=Cancelled Instrument='ES 03-09' Action=Buy Limit price=0 Stop price=0 Quantity=1 Strategy='ChrisFade' Type=Market Tif=Gtc Oco='' Filled=0 Fill price=0 Token='d41927a62477439b941db2ca375bd61a' Gtd='12/1/2099 12:00:00 AM'
What am I missing? Am I looking for my phone while I am talking on it?
As you can see from attached pictures, it receives a lot of buy and sell signals, but at some point just stops executing.
Usually tthat happens as soon as real time data start coming in, sometimes even before - still on historical data
Thank you much.

Comment