Originally Posted By: jcl

Better find out the reason of the error 45, and fix it. In your case it's calling dayHigh/Low before the market day is over. You cannot know the high of a day already in the morning. Thus do not call those functions until the EndMarket hour is over.


Thanks for the explanations.

I think i have sorted the other problems just still not understanding why the the dayHigh/dayLow is not working? I know you have explained it but my apologise, I am still unable to figure it out, although i know its probably something quite simple..

I thought that if i have set the start and end market for the dayhigh and daylow then when using (UTC,0) then this should work as it reverts to the first hour of trading 8 till 9 am and calculates the high/low of the day(first hour trading)?

Could you point out specifically in the code what is incorrect and where am i calling the functions before EndMarket = 900; is over? And possibly if you don't mind the solution this so i can finally "get it".

Many Thanks.

Quote:

function run()
{

BarPeriod = 15;
LookBack = 1000;
set(TICKS);

vars Price = series(price());
var DH = dayHigh (UTC,0);
var DL = dayLow (UTC,0);

StartMarket = 800;
EndMarket = 900;

var Range = DH-DL;
var Close = timeOffset(UTC,0,16,30);
var Open = timeOffset(UTC,0,8,00);
var StartTrade = timeOffset(UTC,0,9,00);
var Now = timeOffset(UTC,0,0,00);

if (Now > Close)
exitLong();

if (Now > Close)
exitShort();

asset("UK100");

Stop = Range;

TakeProfit = Range;

if (Range > 40*PIP)
Margin = 0;

if (*Price > DH && NumOpenLong <1 && Now > StartTrade && Now < Close)
enterLong();

else if (*Price < DL && NumOpenShort <1 && Now > StartTrade && Now < Close)
enterShort();

}