if (CrossAbove(EMA(9), EMA(34), 1))
to
if (CrossAbove(EMA(9), EMA(34), 0))
and included the conditions ToTime coded as such:
if (ToTime(Time[0]) >= 61500 && ToTime(Time[0]) <= 111500)
if (ToTime(Time[0]) >= 131500 && ToTime(Time[0]) <= 161500)
if (ToTime(Time[0]) >= 191500 && ToTime(Time[0]) <= 231500)
Now the the trading strategy is always exiting the trade once entered, paying the spread.
I am trying to eneter into One position on the 9 Crossing the 34 EMA with no look back period and only trading from 6:15 AM to 11:15AM and 13:15PM to 16:15PM and from 19:15PM to 23:15PM
I've posted my coding below if anyone is so kind enough to please point me out my mistakes.
///<summary>
/// Called on each bar update event (incoming tick)
///</summary>
protectedoverridevoid OnBarUpdate()
{
// Condition set 1
if (CrossAbove(EMA(9), EMA(34), 0))
{
}
// Condition set 2
if (ToTime(Time[0]) >= 61500 && ToTime(Time[0]) <= 111500)
if (ToTime(Time[0]) >= 131500 && ToTime(Time[0]) <= 161500)
if (ToTime(Time[0]) >= 191500 && ToTime(Time[0]) <= 231500)
{
}
EnterLong(DefaultQuantity, "");
// Condition set 4
if (CrossBelow(EMA(9), EMA(34), 0))
{
}
// Condition set 5
if (ToTime(Time[0]) >= 61500 && ToTime(Time[0]) <= 111500)
if (ToTime(Time[0]) >= 131500 && ToTime(Time[0]) <= 161500)
if (ToTime(Time[0]) >= 191500 && ToTime(Time[0]) <= 231500)
{
}
EnterShort(DefaultQuantity, "");
}


Comment