I'm attempting to convert the Kase Permission Stochastic from Tradestation 
where it works just fine to AFL and I seem to be struggling. 

The code I have is giving  condition1 as true no matter what values I have for 
XpermK and XpermD. 

I have tried wrting the tests for condition1 etc in a number of different ways 
to no avail. Most grateful for a view on what I'm doing wrong. Herewith my 
latest attempt:


XPermK = Value1 = Value2 = Value3 = Value4 = 0;

XTK = XTDF = XTDS = XPermD = 0;

XPermLong = XPermShort = 0;

Condition1 = Condition2=Condition3 = False; 

Condition1s = Condition2s=Condition3s = False; 

Color = 0;

Xlength = 5;

Length = 9;

 

Synthetic = Xlength * Length;

Value1 = LLV(Low, Synthetic);

Value2 = HHV(High, Synthetic) - Value1;

 

XTK = IIf(Value2 > 0, (C -Value1)/Value2 * 100.0, 0.);

 

for (i=0; i< BarCount; i++)

{

       if ( i <= Xlength)

       {

              XTDF[i] = XTK[i];

              XTDS[i] = XTDF[i]; 

       }

       else

       {

              XTDF[i] = XTDF[i-Xlength] + 0.5 *( XTK[i] - XTDF[i-Xlength]);

              XTDS[i] = ((XTDS[i-Xlength]*2 )+XTDF[i])/3.0;

       }

} 

 

XPermK = MA(MA(XTDF,3),2);

XPermD = MA(MA(XTDS,3),2);

EnableTextOutput(True);

for (i=0; i< BarCount; i++)

{

//XpermLong

 

       if (XpermD[i] >= 75.0 AND XPermK[i] >= 75.0 AND (abs(XPermK[i] - 
XpermD[i]) <= 2.0)

              {

                     Condition1[i] = True;

              }

              else

                     Condition1[i]= False;

 

       if(XpermD[i] < 25 AND XPermK[i] < 25 AND (XPermK[i] - XpermD[i]) > 2)

              {

                     Condition2[i]= True;

              }

              else

              Condition2[i]= False;

 

 

       if(XPermK[i] >25 AND XPermK[i] > XPermD[i])

              {

                     Condition3[i] = True;

              }

              else

                     Condition3[i] = False;

       

        if(Condition1[i] = True OR Condition2[i] = True OR Condition3[i] = True)

              {

                     XpermLong[i] = 1;

              }

              else

                     XpermLong[i] = 0;

 

//XPermShort

 

        if(XpermD[i] < 25 AND XPermK[i] < 25 AND abs(XPermK[i] - XpermD[i]) < 2)

              {

                     Condition1s[i]=True;

              }

              else

                     Condition1s[i]=False;

 

       if(XpermD[i] > 75 AND XPermK[i] > 75 AND (XPermD[i] - XpermK[i]) > 2)

              {

                     Condition2s[i]= True;

              }

              else

                     Condition2s[i]= False;

       

              if(XPermK[i] < 75 AND XPermK[i] < XPermD[i])

                     {

                            Condition3s[i] = True;

              }

              else

                     Condition3s[i] = False;

       

       if(Condition1s[i] = True OR Condition2s[i] = True OR Condition3s[i] = 
True)

              {

                     XpermShort[i] = 1;

              }

              else

                     XpermShort[i] = 0;

 

       if (Xpermlong[i] = 1)

       {

              Color[i] = colorGreen;

              Value4[i] = 100;

       }

       else

              if (XPermshort[i] = 1)

              {

                     Color[i] = colorRed;

                     Value4[i] = -100;

              }

       else

              {

                     Color[i] = colorBlue;

                     Value4[i] = 0;

              }

}

 

"XPermK = " + WriteVal(XPermK);

"XPermD = " + WriteVal(XpermD);

"XpermShort =" + WriteVal(XpermShort);

"XpermLong =" + WriteVal(XpermLong);

"Condition1 = " + WriteVal(Condition1);  

"Condition2 = " + WriteVal(Condition2);  

"Condition3 = " + WriteVal(Condition3);  

"Condition1s = " + WriteVal(Condition1s);  

"Condition2s = " + WriteVal(Condition2s);  

"Condition3s = " + WriteVal(Condition3s);  

"Value4 = " + WriteVal(Value4);

 

 

Plot(Value4,"KPerm",Color,styleThick); 

Reply via email to