فیلتر واگرایی rsi رایگان
-
توضیحات
-
کپی فیلتر
-
کامنت ها
فیلتر واگرایی در rsi
true==function()
{
var findpivot = function(day)
{
var dayp = 0;
var type = 0;
var pivot = [];
var count = 0;
for (var j = 1;j<=day;j++)
{
if(j<=4)
for (var k = j-1;k<=j+3;k++)
{
if(typeof [ih][j] == "undefined" ||typeof [ih][k] == "undefined")continue;
if([ih][j].PDrCotVal>[ih][k].PDrCotVal)
{
count ++
}
if([ih][j].PDrCotVal<[ih][k].PDrCotVal)
{
count --
}
if(k==j+3&&type===0)
{
//pivot +
if(count>=4)
{
type = 1;
dayp=j;
pivot.push(type);
pivot.push(dayp);
}
//pivot -
if(count<=-4)
{
type = -1;
dayp=j
pivot.push(type)
pivot.push(dayp)
}
count = 0;
}
}
//start pivot
if(j>4)
for (var i = j-4;i<=j+4;i++)
{
if(typeof [ih][j] == "undefined" ||typeof [ih][i] == "undefined")continue;
if([ih][j].PDrCotVal>[ih][i].PDrCotVal)
{
count ++
}
if([ih][j].PDrCotVal<[ih][i].PDrCotVal)
{
count --
}
if(i==j+4)
{
//pivot +
if(count>=7)
{
type = 1;
dayp=j;
pivot.push(type);
pivot.push(dayp);
}
//pivot -
if(count<=-7)
{
type = -1;
dayp=j
pivot.push(type)
pivot.push(dayp)
}
count = 0;
}
}
//end pivot
}
return pivot
};
function rsi(day,start){
var len = [ih].length;
for(var i=0;i<len-1;i++){
[ih][i].Change=[ih][i].PDrCotVal-[ih][i+1].PDrCotVal;
if([ih][i].Change>=0){
[ih][i].Gain=[ih][i].Change;
[ih][i].Loss=0;
}else{
[ih][i].Gain=0;
[ih][i].Loss=(-1)*[ih][i].Change;
}
}
var SumGain=0;
var SumLoss=0;
for(var i=len-1-day;i<len-1;i++){
SumGain+=[ih][i].Gain;
SumLoss+=[ih][i].Loss;
}
var FirstAvgGain=SumGain/day;
var FirstAvgLoss=SumLoss/day;
for(var i=len-1-day;i>=0;i--){
if(i==len-1-day){
[ih][i].AvgGain=FirstAvgGain;
[ih][i].AvgLoss=FirstAvgLoss;
}else{
[ih][i].AvgGain=(([ih][i+1].AvgGain*(day-1))+[ih][i].Gain)/day;
[ih][i].AvgLoss=(([ih][i+1].AvgLoss*(day-1))+[ih][i].Loss)/day;
}
[ih][i].RS=[ih][i].AvgGain/[ih][i].AvgLoss;
[ih][i].RSI=100-(100/(1+[ih][i].RS));
}
return ([ih][start].RSI).toFixed(2);
}
var divergence = function(per)
{
var lptype=0;
var lpdate=0;
var pivot = [];
pivot = findpivot(per)
if(pivot.length>1)
{
lptype=pivot[0]
lpdate=pivot[1]
}
if(lptype<0)
{
var lpprice =[ih][lpdate].PDrCotVal
var lprsi =rsi(14,lpdate)
var daychek =[]
var day = 0
var chprice = 0
var chrsi = 0
var rp = 0
var rr = 0
var dif = 0
var rpf = 0
var rrf = 0
var diff = 0
var dayf = 0
var difchek = 0
var rep1 = "ندارد"
var rep2 = "0"
var rep3 = 0
for(var i = 0; i<pivot.length;i+=2)
{
if(pivot[i]<0)
daychek.push(pivot[i+1])
}
for(k=0;k<daychek.length;k++)
{
day = daychek[k]
chprice = [ih][day].PDrCotVal
chrsi = rsi(14,day)
rp = (((lpprice-chprice)/chprice)*100).toFixed(2)
rr = (lprsi-chrsi).toFixed(2)
dif = (Math.abs(rp)+Math.abs(rr)).toFixed(2)
if(dif>difchek)
{
difchek=dif
dayf = day
diff = dif
rrf = rr
rpf = rp
}
}
if (dayf != 0)
{
if(rpf<0&&rrf>0)
{
rep1 = "normal positive divergence"
rep2 = lpdate + "and" + dayf
rep3 = diff
}
if(rpf>0&&rrf<0)
{
rep1 = "hieden positive divergence"
rep2 = lpdate + "and" + dayf
rep3 = diff
}
}
return [rep1,rep2,rep3]
}
if(lptype>0)
{
var lpprice =[ih][lpdate].PDrCotVal
var lprsi =rsi(14,lpdate)
var daychek =[]
var day = 0
var chprice = 0
var chrsi = 0
var rp = 0
var rr = 0
var dif = 0
var rpf = 0
var rrf = 0
var diff = 0
var dayf = 0
var difchek = 0
var rep1 = "ندارد"
var rep2 = "0"
var rep3 = 0
for(var i = 0; i<pivot.length;i+=2)
{
if(pivot[i]>0)
daychek.push(pivot[i+1])
}
for(k=0;k<daychek.length;k++)
{
day = daychek[k]
chprice = [ih][day].PDrCotVal
chrsi = rsi(14,day)
rp = (((lpprice-chprice)/chprice)*100).toFixed(2)
rr = (lprsi-chrsi).toFixed(2)
dif = (Math.abs(rp)+Math.abs(rr)).toFixed(2)
if(dif>difchek)
{
difchek=dif
dayf = day
diff = dif
rrf = rr
rpf = rp
}
}
if (dayf != 0)
{
if(rpf<0&&rrf>0)
{
rep1 = "hieden negative divergence"
rep2 = lpdate + "and" + dayf
rep3 = diff
}
if(rpf>0&&rrf<0)
{
rep1 = "normal negative divergence"
rep2 = lpdate + "and" + dayf
rep3 = diff
}
}
return [rep1,rep2,rep3]
}
if(lptype==0)
{
return lptype;
}
};
var final = []
final = divergence(50)
if(final[2]>25)
{
return true;
}
}()
کد فیلتر
true==function()
{
var findpivot = function(day)
{
var dayp = 0;
var type = 0;
var pivot = [];
var count = 0;
for (var j = 1;j<=day;j++)
{
if(j<=4)
for (var k = j-1;k<=j+3;k++)
{
if(typeof [ih][j] == "undefined" ||typeof [ih][k] == "undefined")continue;
if([ih][j].PDrCotVal>[ih][k].PDrCotVal)
{
count ++
}
if([ih][j].PDrCotVal<[ih][k].PDrCotVal)
{
count --
}
if(k==j+3&&type===0)
{
//pivot +
if(count>=4)
{
type = 1;
dayp=j;
pivot.push(type);
pivot.push(dayp);
}
//pivot -
if(count<=-4)
{
type = -1;
dayp=j
pivot.push(type)
pivot.push(dayp)
}
count = 0;
}
}
//start pivot
if(j>4)
for (var i = j-4;i<=j+4;i++)
{
if(typeof [ih][j] == "undefined" ||typeof [ih][i] == "undefined")continue;
if([ih][j].PDrCotVal>[ih][i].PDrCotVal)
{
count ++
}
if([ih][j].PDrCotVal<[ih][i].PDrCotVal)
{
count --
}
if(i==j+4)
{
//pivot +
if(count>=7)
{
type = 1;
dayp=j;
pivot.push(type);
pivot.push(dayp);
}
//pivot -
if(count<=-7)
{
type = -1;
dayp=j
pivot.push(type)
pivot.push(dayp)
}
count = 0;
}
}
//end pivot
}
return pivot
};
function rsi(day,start){
var len = [ih].length;
for(var i=0;i<len-1;i++){
[ih][i].Change=[ih][i].PDrCotVal-[ih][i+1].PDrCotVal;
if([ih][i].Change>=0){
[ih][i].Gain=[ih][i].Change;
[ih][i].Loss=0;
}else{
[ih][i].Gain=0;
[ih][i].Loss=(-1)*[ih][i].Change;
}
}
var SumGain=0;
var SumLoss=0;
for(var i=len-1-day;i<len-1;i++){
SumGain+=[ih][i].Gain;
SumLoss+=[ih][i].Loss;
}
var FirstAvgGain=SumGain/day;
var FirstAvgLoss=SumLoss/day;
for(var i=len-1-day;i>=0;i--){
if(i==len-1-day){
[ih][i].AvgGain=FirstAvgGain;
[ih][i].AvgLoss=FirstAvgLoss;
}else{
[ih][i].AvgGain=(([ih][i+1].AvgGain*(day-1))+[ih][i].Gain)/day;
[ih][i].AvgLoss=(([ih][i+1].AvgLoss*(day-1))+[ih][i].Loss)/day;
}
[ih][i].RS=[ih][i].AvgGain/[ih][i].AvgLoss;
[ih][i].RSI=100-(100/(1+[ih][i].RS));
}
return ([ih][start].RSI).toFixed(2);
}
var divergence = function(per)
{
var lptype=0;
var lpdate=0;
var pivot = [];
pivot = findpivot(per)
//مشخص کردن روز و نوع آخرین پیووت تشکیل شده
//دنبال واگرایی در پیووت های ماژور هستیم فقط یک استثنا داریم که اگر آخرین پیووت تشکیل شده
//مینور باشد اونم در نظر میگیریم
if(pivot.length>1)
{
lptype=pivot[0]
lpdate=pivot[1]
}
//اگر آخرین پیووت تشکیل شده دره باشد
if(lptype<0)
{
var lpprice =[ih][lpdate].PDrCotVal
var lprsi =rsi(14,lpdate)
var daychek =[]
var day = 0
var chprice = 0
var chrsi = 0
var rp = 0
var rr = 0
var dif = 0
var rpf = 0
var rrf = 0
var diff = 0
var dayf = 0
var difchek = 0
var rep1 = "ندارد"
var rep2 = "0"
var rep3 = 0
//از صفر شروع کردیم که دی چک خالی نمونه
for(var i = 0; i<pivot.length;i+=2)
{
if(pivot[i]<0)
daychek.push(pivot[i+1])
}
for(k=0;k<daychek.length;k++)
{
day = daychek[k]
chprice = [ih][day].PDrCotVal
chrsi = rsi(14,day)
rp = (((lpprice-chprice)/chprice)*100).toFixed(2)
rr = (lprsi-chrsi).toFixed(2)
dif = (Math.abs(rp)+Math.abs(rr)).toFixed(2)
if(dif>difchek)
{
difchek=dif
dayf = day
diff = dif
rrf = rr
rpf = rp
}
}
if (dayf != 0)
{
if(rpf<0&&rrf>0)
{
rep1 = "normal positive divergence"
rep2 = lpdate + "and" + dayf
rep3 = diff
}
if(rpf>0&&rrf<0)
{
rep1 = "hieden positive divergence"
rep2 = lpdate + "and" + dayf
rep3 = diff
}
}
return [rep1,rep2,rep3]
}
//اگر آخرین پیووت تشکیل شده قله باشد
if(lptype>0)
{
var lpprice =[ih][lpdate].PDrCotVal
var lprsi =rsi(14,lpdate)
var daychek =[]
var day = 0
var chprice = 0
var chrsi = 0
var rp = 0
var rr = 0
var dif = 0
var rpf = 0
var rrf = 0
var diff = 0
var dayf = 0
var difchek = 0
var rep1 = "ندارد"
var rep2 = "0"
var rep3 = 0
//از صفر شروع کردیم که دی چک خالی نمونه
for(var i = 0; i<pivot.length;i+=2)
{
if(pivot[i]>0)
daychek.push(pivot[i+1])
}
for(k=0;k<daychek.length;k++)
{
day = daychek[k]
chprice = [ih][day].PDrCotVal
chrsi = rsi(14,day)
rp = (((lpprice-chprice)/chprice)*100).toFixed(2)
rr = (lprsi-chrsi).toFixed(2)
dif = (Math.abs(rp)+Math.abs(rr)).toFixed(2)
if(dif>difchek)
{
difchek=dif
dayf = day
diff = dif
rrf = rr
rpf = rp
}
}
if (dayf != 0)
{
if(rpf<0&&rrf>0)
{
rep1 = "hieden negative divergence"
rep2 = lpdate + "and" + dayf
rep3 = diff
}
if(rpf>0&&rrf<0)
{
rep1 = "normal negative divergence"
rep2 = lpdate + "and" + dayf
rep3 = diff
}
}
return [rep1,rep2,rep3]
}
if(lptype==0)
{
return lptype;
}
};
var final = []
final = divergence(50)
if(final[2]>25)
{
return true;
}
}()
هنوز بازخوردی برای این محصول ثبت نشده است
برچسب ها
دوره های تخصصی
دستهبندیها
راههای ارتباطی
محصول به سبد خرید اضافه شد
توجه داشته باشید امکان خطا در خروجی وجود دارد