I'm trying to test a simple price action strategy that I read about on another forum. I seem to be having trouble with the hour() function. Specifically, I want to close all open trades on Friday afternoon, and I used the scrip from the Tips and Hacks section of the manual.
Oddly, Zorro never evaluates to true the comparison if(dow()==5 and hour()>=17). It does however evaluate the comparison if(dow()==5) as I would expect.
Any suggestions as to what I could be doing wrong? Full script below:
function run()
{
BarPeriod = 1440;
LookBack = 100;
TimeFrame = 5; //weekly bars
bool W1;
if (priceOpen(1) < priceClose(1)) //previous bar was an up bar
W1 = true;
else W1 = false;
TimeFrame = 20; //monthly bars
bool M1;
if (priceOpen(1) < priceClose(1)) //previous bar was an up bar
M1 = true;
else M1 = false;
TimeFrame = 1;
Lots = 1;
if (W1 == true and M1 == true and priceOpen(1) > priceClose(1) and NumOpenLong < 1) { //monthly and weekly bars are up, daily bar is down
Stop = 2*ATR(20);
Trail = 2*ATR(20);
TakeProfit = 5*ATR(20);
TrailLock = 25;
Entry = priceHigh(1);
enterLong();
}
if (W1 == false and M1 == false and priceOpen(1) < priceClose(1) and NumOpenShort < 1) { //monthly and weekly bars are down, daily bar is up
Stop = 2*ATR(20);
Trail = 2*ATR(20);
TakeProfit = 5*ATR(20);
TrailLock = 25;
Entry = priceLow(1);
enterShort();
}
if(dow() == 5 and hour() >= 17)
{
exitLong("*");
exitShort("*");
}
}