// Filter Name :   HF-516 FREE
// User: Mostafa Ejarestaghi
// UPDATE: 1402/09/21
// 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";
  }
  var up = "";
  var down = "";
  c = ((tmax) / (py)).toFixed(2);
  d = ((tmin) / (py)).toFixed(2);
  a = Math.floor([ih][1].PClosing * c) //tmax آستانه بالا
  b = Math.ceil([ih][1].PClosing * d) //tmin آستانه پایین
  if (a < 5000) {
    up = a;
    down = b;
  } else if (a > 5000 && a < 20000) {
    up = Math.floor(a / 10) * 10;
    down = Math.ceil(b / 10) * 10;
  } else if (a > 20000) {
    up = Math.floor(a / 50) * 50;
    down = Math.ceil(b / 50) * 50;
  }


  (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>";;
  var strResult = "<span style='opacity: 0.8;border-top: 1px solid #C0C0C0;border-left: 1px solid #000000;width:100px;display:inline-block;background:#fc779f;text-align: center;color:;font-weight: bold;' title=' آستانه پایین'>&nbsp" + down + "</span>";;
  strResult += "<span style='opacity: 0.8;border-top: 1px solid #C0C0C0;border-left: 1px solid #000000;width:100px;display:inline-block;background:#f7b90c;text-align: center;color:;font-weight: bold;' title=' اسنانه بالا '>&nbsp" + up + "</span>";;
  (cfield2) = strResult;

  return true;

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

  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";
    }
  }

}

