Maurizio-Ciullo

Indicatore Study Calcolo Punti Ogni Sessione

Dec 9th, 2025 (edited)
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.                                                                                 // Indicatore Study Calcolo Punti Ogni Sessione //
  3.                                                                                    //  Esempio Futures @S Soia  //
  4.  
  5. // * IMPOSTA ORA SESSIONI / GIORNI SESSIONI / BPV / SESSIONE GRAFICO COME EXCHANGE TIME /   SESSIONE GRAFICO COME SESSION HOUR * //                                                                            
  6. // * SE LE CANDELE NON ESISTONO SIA IN ENTRY CHE IN EXIT LA SESSIONE NON SARÀ CONTEGGIATA * //                                                                            
  7.  
  8.  
  9. // === Sessioni & Analisi @S Soia ===
  10. // SESSIONI (OPEN DOM) - (CLOSE VEN) (CLOSE EVERY SESSION FOR 5 SESSIONS) / StartSession(1920), EndSession(1320);
  11. // === Sessioni & Analisi @S Soia ===
  12.  
  13. // --- Input Orari Sessioni ---
  14. Inputs:
  15.     StartTimeSession(1915),   // ora inizio sessione
  16.     EndTimeSession(1320);     // ora fine sessione
  17.  
  18. // --- Input Giorni Sessioni (0=Domenica, 1=Lunedì, ..., 6=Sabato) ---
  19. Inputs:
  20.     StartDaySession1(0), EndDaySession1(1),  // Domenica -> Lunedì
  21.     StartDaySession2(1), EndDaySession2(2),  // Lunedì -> Martedì
  22.     StartDaySession3(2), EndDaySession3(3),  // Martedì -> Mercoledì
  23.     StartDaySession4(3), EndDaySession4(4),  // Mercoledì -> Giovedì
  24.     StartDaySession5(4), EndDaySession5(5),  // Giovedì -> Venerdì
  25.     StartDaySession6(5), EndDaySession6(6),  // Venerdì -> Sabato
  26.     StartDaySession7(6), EndDaySession7(0),  // Sabato -> Domenica
  27.     BPV(50); // Big Point Value
  28.  
  29. // --- Variabili Sessioni ---
  30. Vars:
  31.     SessioStart1(0), SessioEnd1(0),
  32.     SessioStart2(0), SessioEnd2(0),
  33.     SessioStart3(0), SessioEnd3(0),
  34.     SessioStart4(0), SessioEnd4(0),
  35.     SessioStart5(0), SessioEnd5(0),
  36.     SessioStart6(0), SessioEnd6(0),
  37.     SessioStart7(0), SessioEnd7(0),
  38.  
  39.     SessNum(0),
  40.     SessionOpen(false), InSession(false),
  41.     ExitFound(false),
  42.  
  43.     MyEntryPrice(0), MyExitPrice(0),
  44.     TradeEntryDate(0), TradeExitDate(0),
  45.     TradeEntryTime(0), TradeExitTime(0),
  46.     ChangePoints(0), ChangeDollars(0),
  47.  
  48.     // Variabili per medie e contatori
  49.     Sum1(0), Sum2(0), Sum3(0), Sum4(0), Sum5(0), Sum6(0), Sum7(0),
  50.     SumDollars1(0), SumDollars2(0), SumDollars3(0), SumDollars4(0), SumDollars5(0), SumDollars6(0), SumDollars7(0),
  51.     Count1(0), Count2(0), Count3(0), Count4(0), Count5(0), Count6(0), Count7(0);
  52.    
  53. // --- Definizione Sessioni basate su input ---
  54. SessioStart1 = IFF(Time = StartTimeSession AND DayOfWeek(Date) = StartDaySession1, 1, 0);
  55. SessioEnd1   = IFF(Time = EndTimeSession   AND DayOfWeek(Date) = EndDaySession1,   1, 0);
  56.  
  57. SessioStart2 = IFF(Time = StartTimeSession AND DayOfWeek(Date) = StartDaySession2, 1, 0);
  58. SessioEnd2   = IFF(Time = EndTimeSession   AND DayOfWeek(Date) = EndDaySession2,   1, 0);
  59.  
  60. SessioStart3 = IFF(Time = StartTimeSession AND DayOfWeek(Date) = StartDaySession3, 1, 0);
  61. SessioEnd3   = IFF(Time = EndTimeSession   AND DayOfWeek(Date) = EndDaySession3,   1, 0);
  62.  
  63. SessioStart4 = IFF(Time = StartTimeSession AND DayOfWeek(Date) = StartDaySession4, 1, 0);
  64. SessioEnd4   = IFF(Time = EndTimeSession   AND DayOfWeek(Date) = EndDaySession4,   1, 0);
  65.  
  66. SessioStart5 = IFF(Time = StartTimeSession AND DayOfWeek(Date) = StartDaySession5, 1, 0);
  67. SessioEnd5   = IFF(Time = EndTimeSession   AND DayOfWeek(Date) = EndDaySession5,   1, 0);
  68.  
  69. SessioStart6 = IFF(Time = StartTimeSession AND DayOfWeek(Date) = StartDaySession6, 1, 0);
  70. SessioEnd6   = IFF(Time = EndTimeSession   AND DayOfWeek(Date) = EndDaySession6,   1, 0);
  71.  
  72. SessioStart7 = IFF(Time = StartTimeSession AND DayOfWeek(Date) = StartDaySession7, 1, 0);
  73. SessioEnd7   = IFF(Time = EndTimeSession   AND DayOfWeek(Date) = EndDaySession7,   1, 0);
  74.  
  75. // --- Apertura sessione ---
  76. If SessioStart1 = 1 or SessioStart2 = 1 or SessioStart3 = 1 or SessioStart4 = 1 or
  77.    SessioStart5 = 1 or SessioStart6 = 1 or SessioStart7 = 1 Then Begin
  78.  
  79.     SessionOpen = true;
  80.     ExitFound = false;
  81.  
  82.     // Determina numero sessione
  83.     If SessioStart1 = 1 Then SessNum = 1;
  84.     If SessioStart2 = 1 Then SessNum = 2;
  85.     If SessioStart3 = 1 Then SessNum = 3;
  86.     If SessioStart4 = 1 Then SessNum = 4;
  87.     If SessioStart5 = 1 Then SessNum = 5;
  88.     If SessioStart6 = 1 Then SessNum = 6;
  89.     If SessioStart7 = 1 Then SessNum = 7;
  90.  
  91.     MyEntryPrice = Open;
  92.     TradeEntryDate = Date;
  93.     TradeEntryTime = Time;
  94. End;
  95.  
  96. // --- Fine sessione ---
  97. If SessionOpen and (SessioEnd1 = 1 or SessioEnd2 = 1 or SessioEnd3 = 1 or SessioEnd4 = 1 or
  98.                     SessioEnd5 = 1 or SessioEnd6 = 1 or SessioEnd7 = 1) Then Begin
  99.     ExitFound = true;
  100.     MyExitPrice = Close;
  101.     TradeExitDate = Date;
  102.     TradeExitTime = Time;
  103.     ChangePoints = MyExitPrice - MyEntryPrice;
  104.     ChangeDollars = ChangePoints * BPV;
  105.  
  106.     // Aggiorna somme e contatori solo se sessione chiusa correttamente
  107.     If SessNum = 1 then Begin Sum1 = Sum1 + ChangePoints; SumDollars1 = SumDollars1 + ChangeDollars; Count1 = Count1 + 1; End
  108.     Else If SessNum = 2 then Begin Sum2 = Sum2 + ChangePoints; SumDollars2 = SumDollars2 + ChangeDollars; Count2 = Count2 + 1; End
  109.     Else If SessNum = 3 then Begin Sum3 = Sum3 + ChangePoints; SumDollars3 = SumDollars3 + ChangeDollars; Count3 = Count3 + 1; End
  110.     Else If SessNum = 4 then Begin Sum4 = Sum4 + ChangePoints; SumDollars4 = SumDollars4 + ChangeDollars; Count4 = Count4 + 1; End
  111.     Else If SessNum = 5 then Begin Sum5 = Sum5 + ChangePoints; SumDollars5 = SumDollars5 + ChangeDollars; Count5 = Count5 + 1; End
  112.     Else If SessNum = 6 then Begin Sum6 = Sum6 + ChangePoints; SumDollars6 = SumDollars6 + ChangeDollars; Count6 = Count6 + 1; End
  113.     Else If SessNum = 7 then Begin Sum7 = Sum7 + ChangePoints; SumDollars7 = SumDollars7 + ChangeDollars; Count7 = Count7 + 1; End;
  114.  
  115.  
  116.     // Print sessione chiusa
  117.     Print("Session: ", SessNum:0:0,
  118.           " | Entry Price: ", MyEntryPrice:0:2,
  119.           " | Entry Date: ", TradeEntryDate,
  120.           " | Entry Time: ", TradeEntryTime,
  121.           " | Exit Price: ", MyExitPrice:0:2,
  122.           " | Exit Date: ", TradeExitDate,
  123.           " | Exit Time: ", TradeExitTime,
  124.           " | Change (pts): ", ChangePoints:0:3,
  125.           " | Change ($): ", ChangeDollars:0:2,
  126.           " | Day ", DayOfWeek(TradeEntryDate):0:0);
  127.  
  128.     // Plot sessione
  129.     Plot1(MyEntryPrice, "SessStart");
  130.     Plot2(MyExitPrice, "SessEnd");
  131.  
  132.     SessionOpen = false;
  133. End;
  134.  
  135. // --- Controllo sessioni annullate (entry o exit mancante) ---
  136. If SessionOpen and LastBarOnChart Then Begin
  137.     Print("Session: ", SessNum:0:0, " | SESSIONE ANNULLATA per mancata apertura o chiusura");
  138.     SessionOpen = false;
  139. End;
  140.  
  141. // --- Medie finali ---
  142. If LastBarOnChart Then Begin
  143.     Print("----------------------------");
  144.     If Count1 > 0 Then Print("Media Sessione 1: ", (Sum1 / Count1):0:3, " pts");
  145.     If Count2 > 0 Then Print("Media Sessione 2: ", (Sum2 / Count2):0:3, " pts");
  146.     If Count3 > 0 Then Print("Media Sessione 3: ", (Sum3 / Count3):0:3, " pts");
  147.     If Count4 > 0 Then Print("Media Sessione 4: ", (Sum4 / Count4):0:3, " pts");
  148.     If Count5 > 0 Then Print("Media Sessione 5: ", (Sum5 / Count5):0:3, " pts");
  149.     If Count6 > 0 Then Print("Media Sessione 6: ", (Sum6 / Count6):0:3, " pts");
  150.     If Count7 > 0 Then Print("Media Sessione 7: ", (Sum7 / Count7):0:3, " pts");
  151.     Print("----------------------------");
  152.     If Count1 > 0 Then Print("Media $ Sessione 1: ", (SumDollars1 / Count1):0:3, " $");
  153.     If Count2 > 0 Then Print("Media $ Sessione 2: ", (SumDollars2 / Count2):0:3, " $");
  154.     If Count3 > 0 Then Print("Media $ Sessione 3: ", (SumDollars3 / Count3):0:3, " $");
  155.     If Count4 > 0 Then Print("Media $ Sessione 4: ", (SumDollars4 / Count4):0:3, " $");
  156.     If Count5 > 0 Then Print("Media $ Sessione 5: ", (SumDollars5 / Count5):0:3, " $");
  157.     If Count6 > 0 Then Print("Media $ Sessione 6: ", (SumDollars6 / Count6):0:3, " $");
  158.     If Count7 > 0 Then Print("Media $ Sessione 7: ", (SumDollars7 / Count7):0:3, " $");
  159.     Print("----------------------------");
  160. End;
  161.  
Advertisement
Add Comment
Please, Sign In to add comment