Hello all, below is a snippet of code. the uses a staticvar and then sets
the static var into the variable "onshort" when I run an exploration,
"onshort" is always set to 1 and I can't figure out why? can anyone help? it
would be greatly appreciated.

thanks

for( i = 0; i < BarCount; i++ )
{
      if ( Short [ i ]  )
    {    priceatshort = ShortPrice[ i ];
        shortAdjusted[ i ] = 1;
        shortPriceAdjusted[ i ] = ShortPrice[ i ];
        TrailStopArrayS[ i ] = TrailingStopS[ i ];

        for (j = i+delay ; j < BarCount; j++)
        {   Shorton[j]=1;
            TrailStopArrayS[ j ] = TrailingStopS[ j ];
              if( High[ j ] >= TrailStopArrayS[ j ] )
            {   Shorton[j]=0;
                Cover[ j ] = 1;
                CoverPrice[ j ] =  TrailStopArrayS[ j ] ;
                i = j;
                break;
            }

            if (j == BarCount - 1)
            {   i = BarCount;  }
         }
    }
}

if(Shorton[BarCount-1]==0)

{StaticVarSet("onshort",0);}
else if(Shorton[BarCount-1]==1)

{StaticVarSet("onshort",1);}


Onshort= StaticVarGet("onshort");
if( IsNull( onshort)) StaticVarSet("onshort",0);
Onshort= StaticVarGet("onshort");

Reply via email to