|
Calculate daily indicator in intra day script
#461912
08/29/16 10:43
08/29/16 10:43
|
Joined: Aug 2016
Posts: 66
dr_panther
OP
Junior Member
|
OP
Junior Member
Joined: Aug 2016
Posts: 66
|
How can I calculate a daily indicator in a intra day script. I tried this:
BarPeriod = 60;
TimeFrame = frameSync(24);
ATR = ATR(10) ;
TimeFrame = frameSync(1);
// more hourly stuff
and get the error: Error 041: Inconsistent series! Any help apriciated. dr_panther
|
|
|
Re: Calculate daily indicator in intra day script
[Re: dr_panther]
#461951
08/30/16 17:46
08/30/16 17:46
|
Joined: Aug 2016
Posts: 66
dr_panther
OP
Junior Member
|
OP
Junior Member
Joined: Aug 2016
Posts: 66
|
Here is a full code, please can someone give me a hint, what I am doing wrong.
static int debug = 1;
var dailyATR() {
TimeFrame = 4; // when this line is commented, it works fine
var atr10=ATR (10);
if(debug && Bar > LookBack)
debug = msg("\ndailATR()\nATR10 %f\nTimeFrame %d\nStartDate: %d\nStop:%.4f \nTrail: %.4f,\nBarPeriod %.0f\nLoopback %d",
atr10, TimeFrame, StartDate , Stop, Trail, BarPeriod, LookBack);
return atr10;
}
function run()
{
//set(LOGFILE);
set(STEPWISE);
StartDate = 20160101;
EndDate = 20160825;
StartWeek = 10000;
Stop = PIP*25;
Trail = PIP*25;
BarPeriod = 60;
LookBack = 60*4 ;
asset("EUR/USD");
TimeFrame = 1;
vars Price = series(price());
if (hour() == 0){
var dailyATR = dailyATR();
var hourlyATR=ATR (10);
if(debug && Bar > LookBack)
debug = msg("\nrun()\nATR10_daily %f\nATR10_hourly %f\nTimeFrame %d\nStartDate: %d\nStop:%.4f \nTrail: %.4f,\nBarPeriod %.0f\nLoopback %d",
dailyATR ,hourlyATR, TimeFrame, StartDate , Stop, Trail, BarPeriod, LookBack);
}
}
|
|
|
Re: Calculate daily indicator in intra day script
[Re: dr_panther]
#461953
08/30/16 19:18
08/30/16 19:18
|
Joined: Aug 2016
Posts: 66
dr_panther
OP
Junior Member
|
OP
Junior Member
Joined: Aug 2016
Posts: 66
|
Answering my own question, as it seems to be a general problem, I still don't understand. However I had to move the calculation of the ATR outside of the if clause. Can someone comment, why this is needed.
static int debug = 1;
var dailyATR() {
TimeFrame = 4;
var atr10=ATR (10);
return atr10;
}
function run()
{
//set(LOGFILE);
set(STEPWISE);
StartDate = 20160101;
EndDate = 20160825;
StartWeek = 10000;
Stop = PIP*25;
Trail = PIP*25;
BarPeriod = 60;
LookBack = 60*4 ;
asset("EUR/USD");
var dailyATR = dailyATR();
TimeFrame = 1;
var hourlyATR=ATR (10);
if (hour() == 0){
if(debug && Bar > LookBack)
debug = msg("\nrun()\nATR10_daily %f\nATR10_hourly %f\nTimeFrame %d\nStartDate: %d\nStop:%.4f \nTrail: %.4f,\nBarPeriod %.0f\nLoopback %d",
dailyATR ,hourlyATR, TimeFrame, StartDate , Stop, Trail, BarPeriod, LookBack);
}
}
|
|
|
|