this the code that can get buy sell signal in a graph (fncharts) i am new to java and please let me know what is worng with my code here
var n = Param(1);
var max = Max(High(),n);
var min = Min(Low(),n);
var close = Close();
var percentR = CreateArray(max.length);
var avd = if((i>max) && (i<min));
var avn = if(avd!=0,avd,1);
var tsl = if(avn==1,max,min);
AddGraph(tsl,-0.05,100);
var begin=Param(2)+Param(3);
for(var i=begin; i<percentR.length; i++){
if((percentR[i-1] < signal[i-1]) && (percentR[i]>signal[i]))
AddBuySignal(i);
else
if((percentR[i-1] > signal[i-1]) && (percentR[i]<signal[i]))
AddSellSignal(i);
Thanks in advance