Advertisement
Maurizio-Ciullo

BIAS ANALYZER 60m [INDICATORE] QTA Mastermind

May 11th, 2025 (edited)
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.                         // BIAS ANALYZER 60m [INDICATORE] QTA Mastermind
  2. // Vedi Video 1 Cartella Mastermind QTA
  3.  
  4. // Impostare il timeframe a 60 minuti !!!
  5. // Questo indicatore calcola la somma positiva o negativa di tutte le ore dal passato fini ad oggi, ma potremmo anche avere anni molto forti come variazione e anni molto deboli
  6. // quindi dopo averlo lanciato per tutto lo storico bisogna spulciare il dataframe di anno in anno salvandosi i risultati per capire se il mercato è ancora coerente con il bias in atto !!!.
  7.  
  8.  
  9. const: MaxBarsAllowed(50);
  10.  
  11. array: countPerHour[23](0),
  12.        deltaSumPerHour[23](0),
  13.        avgPerHour[23](0),
  14.        cumPerHour[23](0);
  15.  
  16. var: maxSessionBars(0), barsThisSession(0), ix(0), currentHour(0);
  17.  
  18. if d <> d[1] then begin
  19.     maxSessionBars = MaxList(barsThisSession, maxSessionBars);
  20.     barsThisSession = 0;
  21.  
  22.     if maxSessionBars > 0 then begin
  23.         maxSessionBars = IFF(maxSessionBars < MaxBarsAllowed, maxSessionBars, MaxBarsAllowed);
  24.  
  25.         for ix = 0 to 23 begin
  26.             if countPerHour[ix] > 0 then
  27.                 avgPerHour[ix] = deltaSumPerHour[ix] / countPerHour[ix];
  28.             if ix > 0 then
  29.                 cumPerHour[ix] = avgPerHour[ix] + cumPerHour[ix - 1];
  30.         end;
  31.  
  32.         for ix = 0 to 23 begin
  33.             if countPerHour[ix] > 0 then begin
  34.                 Plot1[maxSessionBars - ix + 1](avgPerHour[ix] * BigPointValue, "Avg $ Movement");
  35.             end;
  36.         end;
  37.     end;
  38. end;
  39.  
  40. // Mostra la tabella oraria nel Commentary SOLO sull?ultima barra
  41. if LastBarOnChart then begin
  42.     var: tableHTML(""),
  43.          bestIx(0), worstIx(0),
  44.          bestVal(-999999.0), worstVal(999999.0),
  45.          val(0);
  46.  
  47.     // Trova migliore e peggiore media in $
  48.     for ix = 0 to 23 begin
  49.         if countPerHour[ix] > 0 then begin
  50.             val = avgPerHour[ix] * BigPointValue;
  51.             if val > bestVal then begin
  52.                 bestVal = val;
  53.                 bestIx = ix;
  54.             end;
  55.             if val < worstVal then begin
  56.                 worstVal = val;
  57.                 worstIx = ix;
  58.             end;
  59.         end;
  60.     end;
  61.  
  62.     // Genera tabella
  63.     tableHTML = "<style>table{font-size:11px;border-collapse:collapse;}th{background:#eee;}td,th{border:1px solid #999;padding:4px 6px;text-align:center;} .green{background:#e1f5e1;font-weight:bold;} .red{background:#fce4e4;font-weight:bold;}</style>";
  64.     tableHTML = tableHTML + "<table><tr><th>Ora</th><th>Media Punti</th><th>Media $</th></tr>";
  65.  
  66.     for ix = 0 to 23 begin
  67.         if countPerHour[ix] > 0 then begin
  68.             val = avgPerHour[ix] * BigPointValue;
  69.             if ix = bestIx then
  70.                 tableHTML = tableHTML + "<tr class='green'>"
  71.             else if ix = worstIx then
  72.                 tableHTML = tableHTML + "<tr class='red'>"
  73.             else if avgPerHour[ix] > 0 then
  74.                 tableHTML = tableHTML + "<tr style='background:#f0fff0;'>"
  75.             else if avgPerHour[ix] < 0 then
  76.                 tableHTML = tableHTML + "<tr style='background:#fff0f0;'>"
  77.             else
  78.                 tableHTML = tableHTML + "<tr style='background:#f8f8f8;'>";
  79.  
  80.             tableHTML = tableHTML +
  81.                 "<td>" + numtostr(ix, 0) + ":00</td>" +
  82.                 "<td>" + numtostr(avgPerHour[ix], 3) + "</td>" +
  83.                 "<td>" + numtostr(val, 2) + "</td></tr>";
  84.         end;
  85.     end;
  86.  
  87.     tableHTML = tableHTML + "</table>";
  88.     CommentaryCL(tableHTML);
  89. end;
  90.  
  91. ///////// !!! MULTICHARTS /////////
  92. // Aggiorna i dati per l'ora corrente
  93. //currentHour = HoursFromDateTime(datetime);  // !!! MULTICHARTS
  94.  
  95.  
  96. /////////  !!! TRADESTATION  /////////
  97. // ATTENZIONE SE L'INDICATORE RICHIEDE PIù BARRE: APPLICARE L'INIDICATORE AL GRAFICO / TASTO DESTRO SUL GRAFICO/ STUDIES / EDIT STUDIES / STATUS / CUSTOMIZES / GENERAL /
  98. /// MAXIMUM OF BARS STUDY WILL REFERENCE / USER DEFINED 1000 O UN NUMERO CONGRUO A FAR CARICARE L'INDICATORE QUASI DALL'INIZIO ALLA FINE DI TUTTO LO STORICO
  99. // Aggiorna i dati per l'ora corrente
  100. currentHour = IntPortion(Time / 100);      // !!! TRADESTATION      
  101.  
  102.  
  103. if currentHour < MaxBarsAllowed then begin
  104.     countPerHour[currentHour] = countPerHour[currentHour] + 1;
  105.     deltaSumPerHour[currentHour] = deltaSumPerHour[currentHour] + (c - c[1]);
  106. end;
  107.  
  108. barsThisSession = barsThisSession + 1;
  109.  
  110. ////////////////////////////////////    ////////////////////////////////////    ////////////////////////////////////    ////////////////////////////////////
  111.  
  112. // Aggiunto Personalmente il Print Debug !!!
  113. if LastBarOnChart then begin
  114.     Print("Medie punti per ora:");
  115.     Print("00: ", NumToStr(avgPerHour[0], 3)); // Cambia i decimali del print ultimo numero prima della chiusura dell'ultima parentesi tonda !!!
  116.     Print("01: ", NumToStr(avgPerHour[1], 3));
  117.     Print("02: ", NumToStr(avgPerHour[2], 3));
  118.     Print("03: ", NumToStr(avgPerHour[3], 3));
  119.     Print("04: ", NumToStr(avgPerHour[4], 3));
  120.     Print("05: ", NumToStr(avgPerHour[5], 3));
  121.     Print("06: ", NumToStr(avgPerHour[6], 3));
  122.     Print("07: ", NumToStr(avgPerHour[7], 3));
  123.     Print("08: ", NumToStr(avgPerHour[8], 3));
  124.     Print("09: ", NumToStr(avgPerHour[9], 3));
  125.     Print("10: ", NumToStr(avgPerHour[10], 3));
  126.     Print("11: ", NumToStr(avgPerHour[11], 3));
  127.     Print("12: ", NumToStr(avgPerHour[12], 3));
  128.     Print("13: ", NumToStr(avgPerHour[13], 3));
  129.     Print("14: ", NumToStr(avgPerHour[14], 3));
  130.     Print("15: ", NumToStr(avgPerHour[15], 3));
  131.     Print("16: ", NumToStr(avgPerHour[16], 3));
  132.     Print("17: ", NumToStr(avgPerHour[17], 3));
  133.     Print("18: ", NumToStr(avgPerHour[18], 3));
  134.     Print("19: ", NumToStr(avgPerHour[19], 3));
  135.     Print("20: ", NumToStr(avgPerHour[20], 3));
  136.     Print("21: ", NumToStr(avgPerHour[21], 3));
  137.     Print("22: ", NumToStr(avgPerHour[22], 3));
  138.     Print("23: ", NumToStr(avgPerHour[23], 3));
  139. end;
  140.  
  141. // Aggiunto Personalmente il Print Debug !!!
  142. if LastBarOnChart then begin
  143.     Print("Medie in $ per ora:");
  144.     Print("00: ", NumToStr(avgPerHour[0] * BigPointValue, 2));  // Cambia i decimali del print ultimo numero prima della chiusura dell'ultima parentesi tonda !!!
  145.     Print("01: ", NumToStr(avgPerHour[1] * BigPointValue, 2));
  146.     Print("02: ", NumToStr(avgPerHour[2] * BigPointValue, 2));
  147.     Print("03: ", NumToStr(avgPerHour[3] * BigPointValue, 2));
  148.     Print("04: ", NumToStr(avgPerHour[4] * BigPointValue, 2));
  149.     Print("05: ", NumToStr(avgPerHour[5] * BigPointValue, 2));
  150.     Print("06: ", NumToStr(avgPerHour[6] * BigPointValue, 2));
  151.     Print("07: ", NumToStr(avgPerHour[7] * BigPointValue, 2));
  152.     Print("08: ", NumToStr(avgPerHour[8] * BigPointValue, 2));
  153.     Print("09: ", NumToStr(avgPerHour[9] * BigPointValue, 2));
  154.     Print("10: ", NumToStr(avgPerHour[10] * BigPointValue, 2));
  155.     Print("11: ", NumToStr(avgPerHour[11] * BigPointValue, 2));
  156.     Print("12: ", NumToStr(avgPerHour[12] * BigPointValue, 2));
  157.     Print("13: ", NumToStr(avgPerHour[13] * BigPointValue, 2));
  158.     Print("14: ", NumToStr(avgPerHour[14] * BigPointValue, 2));
  159.     Print("15: ", NumToStr(avgPerHour[15] * BigPointValue, 2));
  160.     Print("16: ", NumToStr(avgPerHour[16] * BigPointValue, 2));
  161.     Print("17: ", NumToStr(avgPerHour[17] * BigPointValue, 2));
  162.     Print("18: ", NumToStr(avgPerHour[18] * BigPointValue, 2));
  163.     Print("19: ", NumToStr(avgPerHour[19] * BigPointValue, 2));
  164.     Print("20: ", NumToStr(avgPerHour[20] * BigPointValue, 2));
  165.     Print("21: ", NumToStr(avgPerHour[21] * BigPointValue, 2));
  166.     Print("22: ", NumToStr(avgPerHour[22] * BigPointValue, 2));
  167.     Print("23: ", NumToStr(avgPerHour[23] * BigPointValue, 2));
  168. end;
  169.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement