Hi,
Can anyone help with my plot text attempt?
I am trying to get values in the Plot Text box. At the moment it 
only shows zeros.
 
//aProblemLoop.afl

//Buy/Sell Rules
Buy=Cross(MA(C,7),MA(C,15));
Sell=0;
per=0;
Lookback=100;
function CheckMACross( per, Lookback ) 
 { 
   result = False; 
   Cma = MA( C, per ); 
   bar = BarCount -1 - Lookback; 
   if( Close[ bar  ] < Cma[ bar ] ) 
   { 
     while( bar < BarCount ) 
     { 
        if( Close[ bar ] > Cma[ bar ] ) 
       { 
          result = True; 
     } 
 
       bar++; 
     } 
   } 
 
   return result; 
 }

period=0; 
function DCBelowMALine() // To find if Daily Close was below MA line
 { 
  found = False; 

  for ( period = 3; period <= 75 AND NOT found; period++) 
  { 
CurrentMA=MA(Close,period);
PriceBelowMA=Close<CurrentMA;
barsbelowMA=Sum(PriceBelowMA,75);
 if(barsBelowMA[BarCount-1]==0)     
found = True;//break out of loop   
  }
if(found)
Plot(CurrentMA,"Red MA=$"+WriteVal
(CurrentMA,1.2),colorRed,styleThick|styleNoLabel);
  return period;
}
//Plot Text
dist=4.5*ATR(10);
for (i=0; i<BarCount; i++)
{
if(Buy[i])PlotText("Buy\nCross Up "+"\nRed MA Period="+period[i] 
+"\nROC(C,50)="+WriteVal(ROC(C[i],50),1.2)+"\nClose= $"+WriteVal(C
[i],1.2),i,L[i]-dist[i],colorGreen);
if(Sell[i])PlotText("[EMAIL PROTECTED] $"+WriteVal(C[i],1.2)+" ",i,H[i] +dist
[i],colorRed);
}
Plot(C,"Close",1,64);
Plot(MA(C,7),"MA7",colorYellow);
Plot(MA(C,15),"MA20",colorBlue);
Title=Name()+"  "+Date()+"   Period= "+dcbelowmaline();

Any assistance would be greatly appreciated. My coding ability is 
mainly "cut and paste".
Peter

Reply via email to