Logic to check the current bar open, close, high and low and see if high of the bar have formed Wick and place a trade long or short.
Any syntax error causing it or something missing in the code. I build this using some Youtube videos but something is not right.
Any help would be appreciated.
Thanks,
protected override void OnBarUpdate()
{
if (BarsInProgress != 0)
return;
if (CurrentBars[0] < 1)
return;
Print("I am in NO trade.");
if ((Close[0] == Low[0] && Open[0] > Close[0] && High[0] > Open[0] && CrossAbove(Close, MY_EMA, 1)))
{
EnterLong(Convert.ToInt32(DefaultQuantity), @"Buy");
Print("I am in LONG trade.");
}
if ((Close[0] == High[0] && Open[0] < Close[0] && High[0] > Open[0] && CrossBelow(Close, MY_EMA, 1)))
{
EnterShort(Convert.ToInt32(DefaultQuantity), @"Sell");
Print("I am in SHORT trade.");
}
// Set 6
// if (BarsSinceExitExecution(0, "", 0) == 1)
// {
// Draw.Text(this, Convert.ToString(CurrentBars[0]), Convert.ToString(SystemPerformance.AllTrades.Trade sPerformance.Currency.CumProfit) + @" $", 0, (Low[0] + (25 * TickSize)) );
// }
}
Comment