I have a program which i only want to run during the following hours:
start at Session1Start (150000)
end at Session1End (170000)
My program only takes trades during these times but it will not exit the trade if it is already in the trade at 170000. I believe this is because it is not looking at the program after 170000 when it tells it to exit if still in the trade! Please help! Thank you very much!
here is the code
if ((ToTime(Time[0]) <= Session1Start || ToTime(Time[0]) >= Session1End))
{
return;
}
if ((ToTime(Time[0]) >= Session1Start && ToTime(Time[0]) <= Session1End))
{
enter here w certain conditions
}
if (Position.MarketPosition == MarketPosition.Short
&& ToTime(Time[0]) <= Session1Start || ToTime(Time[0]) >= Session1End )
{
ExitShort("short");
}
if (Position.MarketPosition == MarketPosition.Long
&& ToTime(Time[0]) <= Session1Start || ToTime(Time[0]) >= Session1End )
{
ExitLong("long");
}
Comment