I played around with it, no matter what I tried the strategy didnt seem profitable to me but here is the base code if you wish to play around with it. My only query is should "VolFac" be a var or a series. Seems more logical to me this should be a series of different vol factors unless the VF function causes the "VolFac" variable to change all the time otherwise wouldnt it only compare against the same vol factor value every comparision?

Quote:

int FridayStopHour = 16;
int SlowVolatilityOffset = 3;

var VF(int Fa, int Sa)
{
var sumF = 0.0, sumS = 0.0;
int i;

for (i = 1; i <= Fa; i++)
sumF += priceClose(i) - priceOpen(i);
for (i = 1; i <= Sa; i++)
sumS += abs(priceClose(i + SlowVolatilityOffset) - priceOpen(i + SlowVolatilityOffset));

return((sumF / Fa) / (sumS / Sa));
}

bool IsTradeTime()
{
if (dow(0) >= 5 && FridayStopHour >= 0 && hour(0) >= FridayStopHour)
return(false);
else
return(true);
}

function run() {
set(TICKS+TESTNOW);
BarPeriod = 15;
LookBack = 100;

int FastVolatilityBase = 5;
int SlowVolatilityBase = 58;
var VolatilityFactor = 2.2;
int ProfitLossVolatilityBase = 46;
var VolFac = VF(FastVolatilityBase, SlowVolatilityBase);

Stop = 0.16*ATR(ProfitLossVolatilityBase);
TakeProfit = 0.43*ATR(ProfitLossVolatilityBase);

if(IsTradeTime()&& abs(VolFac) > VolatilityFactor) {

if(VolFac > 0.0)
enterLong();
else if(VolFac < 0.0)
enterShort();
}
}