protected override void OnBar()
{
var volumne = Math.Floor(Account.Equity * (VolumePercent / 100));
if (Account.Equity > (Account.Balance + (Account.Balance * (Profiteer / 100))))
foreach (var openedPosition in Positions)
{
ClosePosition(openedPosition);
}
if (_stochastic.PercentK.Last(2) > _stochastic.PercentD.Last(2) && _stochastic.PercentK.Last(1) < _stochastic.PercentD.Last(1))
{
Print("_stochastic.PercentD.Last(1) {0}", _stochastic.PercentD.Last(1));
Print("_stochastic.PercentD.Last(2) {0}", _stochastic.PercentD.Last(2));
if (_stochastic.PercentD.Last(2) > Up_Level && _stochastic.PercentK.Last(2) > Up_Level)
{
ExecuteMarketOrder(TradeType.Sell, Symbol.Name, volumne, "DragonStochastic", StopLoss, TakeProfit);
}
}
if (_stochastic.PercentK.Last(2) < _stochastic.PercentD.Last(2) && _stochastic.PercentK.Last(1) > _stochastic.PercentD.Last(1))
{
Print("_stochastic.PercentD.Last(1) {0}", _stochastic.PercentD.Last(1));
Print("_stochastic.PercentD.Last(2) {0}", _stochastic.PercentD.Last(2));
if (_stochastic.PercentD.Last(2) < Down_Level && _stochastic.PercentK.Last(2) < Down_Level)
{
ExecuteMarketOrder(TradeType.Buy, Symbol.Name, volumne, "DragonStochastic", StopLoss, TakeProfit);
}
}
}