public override void OnTick(params Tick[] t) { channel.HandleNextTick(t[0]); foreach (var indicator in indicatorList) { indicator.Value.HandleNextTick(t[0]); } if (prevTick != null) { if (IAccountManager.ExistsLongPositionForSymbol(t[0].Symbol)) { if (indicatorList["EMA"][0] < channel.LOW(0)) { IAccountManager.ClosePosition(t[0].Symbol); } } if (IAccountManager.ExistsShortPositionForSymbol(t[0].Symbol)) { if (indicatorList["EMA"][0] > channel.HI(0)) { IAccountManager.ClosePosition(t[0].Symbol); } } //Volatility high if (indicatorList["HVOL"][0] > 40) { if (!IAccountManager.ExistsPositionForSymbol(t[0].Symbol)) { if (indicatorList["EMA"][0] > channel.HI(0) && indicatorList["EMA"][1] < channel.HI(1)) { IAccountManager.PlaceMarketOrder(t[1].Symbol, 10000, Position.PositionSide.Long, STOPLEVEL); } } if (!IAccountManager.ExistsPositionForSymbol(t[0].Symbol)) { if (indicatorList["EMA"][0] < channel.LOW(0) && indicatorList["EMA"][1] > channel.LOW(1)) { IAccountManager.PlaceMarketOrder(t[1].Symbol, 10000, Position.PositionSide.Short, STOPLEVEL); } } } } prevTick = t[0]; }
public override void OnTick(params Tick[] t) { STOPLEVEL = 50 * t[0].BidOpen / 10000; LIMITLEVEL = 100 * t[0].BidOpen / 10000; int POSIZE = (int)(((AccountManager)IAccountManager).CurrentBalance); QSP.HandleNextTick(t[0]); foreach (var indicator in indicatorList) { indicator.Value.HandleNextTick(t[0]); } //Check Spread Cost before trading if ((t[0].AskClose - t[0].BidClose <= .0005)) { //Volatility high if (indicatorList["HVOL"][0] > 90) { if (indicatorList["GENESIS"][0] < -1 * (indNumber - 0.5) && indicatorList["GENESIS"][1] > -1 * (indNumber - 0.5) && indicatorList["EMA"][0] < indicatorList["GDEMA"][0]) { if (!IAccountManager.ExistsPositionForSymbol(t[0].Symbol)) { IAccountManager.PlaceMarketOrder(t[0].Symbol, POSIZE, Position.PositionSide.Short, STOPLEVEL, LIMITLEVEL); } } } } if (IAccountManager.ExistsLongPositionForSymbol(t[0].Symbol)) { } if (IAccountManager.ExistsShortPositionForSymbol(t[0].Symbol)) { } }