public void OnBar() { double atrNow = StandardIndicators.ATR(Datasets[60], Period1); double atrTotal = StandardIndicators.ATR(Datasets[60], 100); double?volatilityLogMA12 = GetData(Asset.Name, Timeframe, "VOLATILITY_LOG_MA_12"); double?volumeLogMA12 = GetData(Asset.Name, Timeframe, "VOLUME_LOG_MA_12"); double?bbandsUpper = GetData(Asset.Name, Timeframe, "BBANDS_UP"); double?bbandsLower = GetData(Asset.Name, Timeframe, "BBANDS_LOW"); double lastMove = Math.Abs(Datasets[60][Period1 + 1].AskClose - Datasets[60][1].AskClose) / Asset.Pip; double?bbRange = (bbandsUpper - bbandsLower) / Asset.Pip; double stop = 75 * Asset.Pip; double jump = (Datasets[60][Period1 + 1].AskClose - Datasets[60][Period2 + 1].AskClose) / Datasets[60][Period1 + 1].AskClose; PushToSeries("jump", Math.Abs(jump)); PushToSeries("jumpOffset", GetSeries("jump")[Period2]); double jumpSma = StandardIndicators.SMA(GetSeries("jump"), 100); if (OpenTradeCount > 0 && (Ask > bbandsUpper || Ask < bbandsLower)) { CloseAllTrades(CurrentBar, Asset.Name); } /* * //Diagnostic Stuff here * if (CurrentBar.OpenTime <= new DateTime(2019, 02, 08) || CurrentBar.OpenTime >= new DateTime(2019, 02, 14)) * return; * * Console.WriteLine(CurrentBar.OpenTime.AddHours(1).ToString("yy-MM-dd HH:mm") + ":" + * Ask + ", atrnow:" + atrNow + ", atrtot:" + atrTotal + ", " + * ", bU:" + bbandsUpper + ", bL" + bbandsLower + ", " + + jump + " " + jump_sma* jump_factor); */ //if (OpenTradeCount == 0 && (lastMove < Asset.Pip * 10) && (volatilityLogMA12 > -0.1 || (volumeLogMA12 >= 0.96 && volumeLogMA12 <= 0.99))) if (OpenTradeCount == 0 && lastMove < 12.7 && (volumeLogMA12 >= 0.95 && volumeLogMA12 <= 0.98) && (bbRange > 81.92 && bbRange < 214) && CurrentBar.OpenTime.AddMinutes(60).Hour < 10) //if (OpenTradeCount == 0) { double tradeSize = size;// + (ClosedTrades.Sum(x=> x.Profit) / 100000); //if (volatilityLogMA12 > -0.1 && volumeLogMA12 >= 0.96 && volumeLogMA12 <= 0.99) // tradeSize = size * 2; if (atrNow < (atrTotal * 0.8) && jump > jumpSma * JumpFactor && (Ask < bbandsUpper - Asset.Pip * 5)) { Trade trade = ExecuteTrade(Trade.TradeDirection.LONG, tradeSize, stop, 0); //Tag the trade with know values at the time of trade execution to use for data relationship analysis trade.TradeData = new double?[] { Period1, Period2, JumpFactor, jumpSma, volatilityLogMA12, volumeLogMA12, atrNow, atrTotal, lastMove, bbRange }; } if (atrNow < (atrTotal * 0.8) && jump < -(jumpSma * JumpFactor) && (Ask > bbandsLower + Asset.Pip * 5)) { Trade trade = ExecuteTrade(Trade.TradeDirection.SHORT, tradeSize, stop, 0); //Tag the trade with know values at the time of trade execution to use for data relationship analysis trade.TradeData = new double?[] { Period1, Period2, JumpFactor, jumpSma, volatilityLogMA12, volumeLogMA12, atrNow, atrTotal, lastMove, bbRange }; } } }
public static void DrawIndicator(StandardIndicators indicator, Vector3 position, float time, float scale, Vector2 offset, Color tint) { DrawIndicator(StandardFrames[indicator], position, time, scale, offset, tint); }