I am trying to call from an indicator running on intraday data an external study calculating on daily data. The external study returns three values It seems to work on historical bars but in real time it gets confused, especially at the change of the day.
The code looks like this:
var xMyStudy=null;
var MyStudy10=null;
var MyStudy11=null;
var MyStudy12=null;
var MyVar=-1;
var aMyArray= new Array(3);
var bInit=false;
function main(input1,input2){
var vState = getBarState();
if(vState == BARSTATE_ALLBARS)
{
if (bInit==false){
if (xMyStudy == null) xMyStudy = efsExternal( "MyStudy.efs", input1,input2,inv("D") ) ;
bInit=true;
}//end bInit
}//end if FIRST BAR
if(vState == BARSTATE_NEWBAR)
{
if (xMyStudy != null) {
if (MyStudy10 != null)
MyVar=MyStudy10[0];
else if (MyStudy10 == null)
MyStudy10 = getSeries( xMyStudy, 0 );
if (MyStudy11 == null)
MyStudy11 = getSeries( xMyStudy, 1 );
if (MyStudy12 == null)
MyStudy12 = getSeries( xMyStudy, 2 );
} // end xMyStudy !=null
aMyArray[0]=MyStudy 10.getValue(0);
aMyArray[1]=MyStudy 11.getValue(0);
aMyArray[2]=MyStudy 12.getValue(0);
}//end if EACH BAR
return aMyArray;
}//end Main
My guess is that it is not calling updates to the daily study at the right time.
Any ideas?????
Thanks,
The code looks like this:
var xMyStudy=null;
var MyStudy10=null;
var MyStudy11=null;
var MyStudy12=null;
var MyVar=-1;
var aMyArray= new Array(3);
var bInit=false;
function main(input1,input2){
var vState = getBarState();
if(vState == BARSTATE_ALLBARS)
{
if (bInit==false){
if (xMyStudy == null) xMyStudy = efsExternal( "MyStudy.efs", input1,input2,inv("D") ) ;
bInit=true;
}//end bInit
}//end if FIRST BAR
if(vState == BARSTATE_NEWBAR)
{
if (xMyStudy != null) {
if (MyStudy10 != null)
MyVar=MyStudy10[0];
else if (MyStudy10 == null)
MyStudy10 = getSeries( xMyStudy, 0 );
if (MyStudy11 == null)
MyStudy11 = getSeries( xMyStudy, 1 );
if (MyStudy12 == null)
MyStudy12 = getSeries( xMyStudy, 2 );
} // end xMyStudy !=null
aMyArray[0]=MyStudy 10.getValue(0);
aMyArray[1]=MyStudy 11.getValue(0);
aMyArray[2]=MyStudy 12.getValue(0);
}//end if EACH BAR
return aMyArray;
}//end Main
My guess is that it is not calling updates to the daily study at the right time.
Any ideas?????
Thanks,
Comment