// Filter Name :   HF-512 FREE
// User: Mostafa Ejarestaghi
// UPDATE: 1401/01/15
// version : 1.1.1
// ------------ site inormation -------------
// website : www.hooshefaal.ir
// Email : hooshefaal@gmail.com
//Telegram Channel : @hooshefaal
//Telegram Support : @hooshefaal_support
// Instagram Page :  @hooshefaal.ir
//whatsapp number :  09364549266
// --------------END---------------
/*
فیلتر نوسان گیری


*/
true == function () {
    //------------------COMMAND START----------------------- 
    Hooshefaal();
    (cfield0) = "";
    (cfield1) = "";
    (cfield2) = "";
    
   
    if ([ih][0].PClosing != (pc) && [ih][0].ZTotTran != (tno) && [ih][0].QTotCap != (tval)) {
        var len = [ih].length;
        if (typeof [ih][0].fixed == 'undefined') {
          for (var i = len; i > 0; i--) {
            if (typeof [ih][i] == 'undefined') {
              [ih][i] = {};
            }
            [ih][i].PriceFirst = [ih][i - 1].PriceFirst;
            [ih][i].PClosing = [ih][i - 1].PClosing;
            [ih][i].PDrCotVal = [ih][i - 1].PDrCotVal;
            [ih][i].ZTotTran = [ih][i - 1].PriceFirst;
            [ih][i].QTotTran5J = [ih][i - 1].QTotTran5J;
            [ih][i].QTotCap = [ih][i - 1].QTotCap;
            [ih][i].PriceChange = [ih][i - 1].PriceChange;
            [ih][i].PriceMin = [ih][i - 1].PriceMin;
            [ih][i].PriceMax = [ih][i - 1].PriceMax;
            [ih][i].PriceYesterday = [ih][i - 1].PriceYesterday;
          }
          [ih][0].fixed = 1;
        }
        [ih][0].PriceFirst = (pf);
        [ih][0].PClosing = (pc);
        [ih][0].PDrCotVal = (pl);
        [ih][0].ZTotTran = (tno);
        [ih][0].QTotTran5J = (tvol);
        [ih][0].QTotCap = (tval);
        [ih][0].PriceChange = (pcc);
        [ih][0].PriceMin = (pmin);
        [ih][0].PriceMax = (pmax);
        [ih][0].PriceYesterday = (py);
      }
      var i;
      var buy_ratio = Math.round(((((ct).Buy_I_Volume / (ct).Buy_CountI) * (pc)) / 10000000) * 10) / 10;
      var sell_ratio = Math.round(((((ct).Sell_I_Volume / (ct).Sell_CountI) * (pc)) / 10000000) * 10) / 10;
      var buy_power = Math.round((((ct).Buy_I_Volume / (ct).Buy_CountI) / ((ct).Sell_I_Volume / (ct).Sell_CountI)) * 100) / 100;
      var moneyVal = ((ct).Buy_I_Volume - (ct).Sell_I_Volume) * (pc);
      moneyVal = ((moneyVal / 10) / 1000000).toFixed(2);
  
      if (isNaN(buy_ratio)) {
          buy_ratio = 0;
      }
      if (isNaN(sell_ratio)) {
          sell_ratio = 0;
      }
      if (isNaN(buy_power)) {
          buy_power = 0;
      }
      if (isNaN(moneyVal)) {
          moneyVal = 0;
      }
  
      var MoneyColor = "";
      if (moneyVal > 0) {
          MoneyColor = "green";
      }
      if (moneyVal < 0) {
          MoneyColor = "red";
      }
  
  
      (cfield0) = buy_power;
      (cfield1) = "<span style='opacity: 0.8;border-top: 1px solid #C0C0C0;border-left: 1px solid #000000;width:100%;display:inline-block;background:#ffffff;text-align: center;color:" + MoneyColor + ";font-weight: bold;' title='ورود و خروج پول'>&nbsp" + moneyVal + "</span>";;
  
      function avg_Hajm(start, day) {
  
          var sum = 0;
      
          for (var i = start; i < day; i++) {
      
            sum = sum + [ih][i].QTotTran5J;
      
          }
      
          var avg = sum / day;
      
          return avg;
      
        }
    
      if ([ih][0].PriceFirst >= (tmin) && [ih][0].PriceFirst < (tmin) * 1.01) {
        if ([ih][0].PDrCotVal < [ih][0].PriceYesterday && [ih][0].PDrCotVal > 1.04 * (tmin)) {
        return true;
        }
        else
          if ([ih][0].PDrCotVal > 1.005 * [ih][0].PriceYesterday && [ih][0].PDrCotVal < 1.01 * [ih][0].PriceYesterday) {
        return true;
          }
          else
            if ([ih][0].PDrCotVal > 1.02 * [ih][0].PriceYesterday && VV < 0.5) {
              return true;
            }
            else
              if ([ih][0].PDrCotVal > 1.029 * [ih][0].PriceYesterday && VV >= 1 && [ih][0].PDrCotVal == (tmax)) {
            return true;
              }
              else
                if ((ct).Buy_I_Volume > avg_Hajm(1, 22) && G >= 1 && (ct).Buy_I_Volume > 0.9 * (tvol) && ee >= 1 && [ih][0].PDrCotVal == (tmax) && SBS >= 1) {
                 return true;
                }
                else
                  return false;
      }
   

}()
//=========================END FUNCTION =========================
function Hooshefaal() {
    var HelpLink = "https://www.hooshefaal.ir/tse-filter-hf-512/";
    var FilterName = "HF-512";

    var column1 = "قدرت خریدار", column2 = "ورود پول", column3 = "", column4 = "", column5 = "";
    var my_data_title0 = '<div style = "direction:rtl;";>';
    my_data_title0 += ' <span style = "border: 1px solid gray;width: 100%;display: inline-block;text-align: center;color: #000;background: #FFAB73;font-weight: normal;"> ' + column1 + '</span>'
    my_data_title0 += '<span style="left: 10px;direction: rtl; display: inline-block; background: #F6F7BF;font-weight: normal; text-align: center;border: 0 solid red;border-radius: 6px; padding: 3px;top: 42%;position: fixed;font-family: Tahoma; font-size: 12px; background-color: #FFD700 !important;  box-shadow: 0 2px 5px rgb(0 0 0 / 50%);color: Blue; width: 150px;animation: NotificationAnim 2s infinite linear;"><a href="https://www.hooshefaal.ir/category/vip-filter/gold/" title="فیلتر های طلایی سایت هوش فعال" target="_blank"><b>💎فیلتر های ویژه💎</b></a> </span>';
    my_data_title0 += '<span style="left: 10px;direction: rtl;display: inline-block;background: #F6F7BF;font-weight: normal;text-align: center;border: 0 solid red;border-radius: 6px;padding: 3px;top: 45%;position: fixed;font-family: Tahoma;font-size: 12px;background-color: #06FF00 !important;box-shadow: 0 2px 5px rgb(0 0 0 / 50%);color: Blue;width: 150px;animation: NotificationAnim 2s infinite linear;"><a href="https://www.hooshefaal.ir/category/%d9%81%db%8c%d9%84%d8%aa%d8%b1-%d9%86%d9%88%db%8c%d8%b3%db%8c-%d8%a8%d9%88%d8%b1%d8%b3/free-filter/"title="دانلود رایگان فیلتر های بورسی" target="_blank">دانلود فیلترهای رایگان</a></span>';
    my_data_title0 += '<span style="left: 10px;direction: rtl; display: inline-block; background: #F6F7BF;font-weight: normal; text-align: center;border: 0 solid red;border-radius: 6px; padding: 3px;top: 48%;position: fixed;font-family: Tahoma; font-size: 12px; background-color: #06FF00 !important;  box-shadow: 0 2px 5px rgb(0 0 0 / 50%);color: Blue; width: 150px;animation: NotificationAnim 2s infinite linear;"><a href="https://www.hooshefaal.ir/category/indicator-download/" title=" دانلود رایگان اندیکاتور" target="_blank">دانلود رایگان اندیکاتور </a> </span>';
    my_data_title0 += '<span style="left: 10px;direction: rtl; display: inline-block; background: #F6F7BF;font-weight: normal; text-align: center;border: 0 solid red;border-radius: 6px; padding: 3px;top: 51%;position: fixed;font-family: Tahoma; font-size: 12px; background-color: #A4EBF3 !important;  box-shadow: 0 2px 5px rgb(0 0 0 / 50%);color: Blue; width: 150px;animation: NotificationAnim 2s infinite linear;">سفارش <a href="https://www.hooshefaal.ir/expert-order/" title="سفارش اکسپرت" target="_blank">اکسپرت</a> و <a href="https://www.hooshefaal.ir/tsetmc-filter-order/" title="سفارش فیلتر" target="_blank">فیلتر </a> </span>';
    my_data_title0 += '<span style="left: 10px;direction: rtl; display: inline-block; background: #F6F7BF;font-weight: normal; text-align: center;border: 0 solid red;border-radius: 6px; padding: 3px;top: 54%;position: fixed;font-family: Tahoma; font-size: 12px; background-color: #A4EBF3 !important;  box-shadow: 0 2px 5px rgb(0 0 0 / 50%);color: Blue; width: 150px;animation: NotificationAnim 2s infinite linear;"><a href="https://t.me/hooshefaal/" title="کانال تلگرام هوش فعال" target="_blank">کانال تلگرام هوش فعال</a> </span>';
    my_data_title0 += '<span style="left: 10px;direction: rtl; display: inline-block; background: #F6F7BF;font-weight: normal; text-align: center;border: 0 solid red;border-radius: 6px; padding: 3px;top: 57%;position: fixed;font-family: Tahoma; font-size: 12px; background-color: #ffad00 !important;  box-shadow: 0 2px 5px rgb(0 0 0 / 50%);color: Blue; width: 150px;animation: NotificationAnim 2s infinite linear;"><a href="https://www.youtube.com/channel/UCMWCAmtUbiZcF4d7vZVtjfg" title="کانال یوتیوب هوش فعال" target="_blank">یوتیوب هوش فعال </a> </span>';
    my_data_title0 += '<span style="left: 10px;direction: rtl; display: inline-block; background: #F6F7BF;font-weight: normal; text-align: center;border: 0 solid red;border-radius: 6px; padding: 3px;top: 60%;position: fixed;font-family: Tahoma; font-size: 12px; background-color: #ffcc00 !important;  box-shadow: 0 2px 5px rgb(0 0 0 / 50%);color: Blue; width: 150px;animation: NotificationAnim 2s infinite linear;"><a href="https://www.aparat.com/vitanet" title="کانال آپارات  هوش فعال" target="_blank">آپارات هوش فعال </a> </span>';
    my_data_title0 += '<span style="left: 10px;direction: rtl; display: inline-block; background: #F6F7BF;font-weight: normal; text-align: center;border: 0 solid red;border-radius: 6px; padding: 3px;top: 63%;position: fixed;font-family: Tahoma; font-size: 12px; background-color: #ffff00 !important;  box-shadow: 0 2px 5px rgb(0 0 0 / 50%);color: Blue; width: 150px;animation: NotificationAnim 2s infinite linear;"><b><a href="' + HelpLink + '" title="لینک آموزش شیوه استفاده از این فیلتر" target="_blank">راهنمای این فیلتر</a> </b></span>';
    my_data_title0 += '<span style="left: 10px;direction: rtl; display: inline-block; background: #F6F7BF;font-weight: normal; text-align: center;border: 0 solid red;border-radius: 6px; padding: 3px;top: 66%;position: fixed;font-family: Tahoma; font-size: 25px; background-color: #ff5;  box-shadow: 0 2px 5px rgb(0 0 0 / 50%);color: Blue !important; width: 150px;animation: NotificationAnim 2s infinite linear;"><a href="' + HelpLink + '" title=" سایت  هوش فعال" target="_blank"><b>هوش فعال</b><br><b>' + FilterName + '</b></a> </span></div>';

    var my_data_title1 = '<span style = "border: 1px solid gray;width: 100%;display: inline-block;text-align: center;color: #000;background: #FFD384;font-weight: normal;"> ' + column2 + '</span>'
    var my_data_title2 = '<span style = "border: 1px solid gray;width: 100%;display: inline-block;text-align: right;color: #000;background: #FFF9B0;font-weight: normal;"> ' + column3 + '</span>'

    //cfield Titel
    var cfield0_title = my_data_title0, cfield1_title = my_data_title1, cfield2_title = my_data_title2;
    //Columns width
    var wc0 = "100px", wc1 = "100px", wc2 = "1200px";

    var title = document.getElementsByClassName("t0head");
    for (var i = 0; i < title.length; i++) {
        if (title[i].outerHTML.includes("cfield0")) {
            title[i].innerHTML = cfield0_title;
            // title[i].style.width = wc0;
            title[i].style.fontWeight = "normal";
        }

        else if (title[i].outerHTML.includes("cfield1")) {
            title[i].innerHTML = cfield1_title;
            // title[i].style.width = wc1;
            title[i].style.fontWeight = "normal";
        }
        else if (title[i].outerHTML.includes("cfield2")) {
            title[i].innerHTML = cfield2_title;
            //title[i].style.width = wc2;
            title[i].style.fontWeight = "normal";
        }
    }

}

