Hi how is possible monitoring if the trade is open i use this code but not work

function enterLong()
{
if(!isPosOpen(1, Long))
{
enterLong(1);
printf("Entered long position");
}
}

function exitLong()
{
if(isPosOpen(1, Long))
{
exitLong();
printf("Exited long position");
}
}

anyone can helpme ?