I have been running this strategy for some time now and i noticed something strange I can't explain, your advise is very welcome.
Basically I have a time filter, I want the strategy only to take long/short entries between 6am Monday and 6pm Friday and clear all positions at 6pm on Friday, in order to not carry risk over the week-end. Below is the code i am using:
protected override void OnBarUpdate()
{
//Enter long
if (CrossAbove(FisherTransform(period).Value,0,1)
&& tradeok == 1)
{
EnterLong();
}
//Enter short
if (CrossBelow(FisherTransform(period).Value,0,1)
&& tradeok == 1)
{
EnterShort();
}
[B]//Time filter
else
if[/B] (Time[0].DayOfWeek == DayOfWeek.Sunday)
{
tradeok = 0;
}
[B]else
if[/B] (Time[0].DayOfWeek == DayOfWeek.Monday
&& ToTime(Time[0]) < ToTime(6, 0, 0))
{
tradeok = 0;
}
[B]else
if[/B] (Time[0].DayOfWeek == DayOfWeek.Friday
&& ToTime(Time[0]) >= ToTime(16, 0, 0))
{
tradeok = 0;
}
else
{
tradeok = 1;
}
}

Comment