Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Indicatore Study Calcolo Punti Ogni Sessione //
- // Esempio Futures @S Soia //
- // * IMPOSTA ORA SESSIONI / GIORNI SESSIONI / BPV / SESSIONE GRAFICO COME EXCHANGE TIME / SESSIONE GRAFICO COME SESSION HOUR * //
- // * SE LE CANDELE NON ESISTONO SIA IN ENTRY CHE IN EXIT LA SESSIONE NON SARÀ CONTEGGIATA * //
- // === Sessioni & Analisi @S Soia ===
- // SESSIONI (OPEN DOM) - (CLOSE VEN) (CLOSE EVERY SESSION FOR 5 SESSIONS) / StartSession(1920), EndSession(1320);
- // === Sessioni & Analisi @S Soia ===
- // --- Input Orari Sessioni ---
- Inputs:
- StartTimeSession(1915), // ora inizio sessione
- EndTimeSession(1320); // ora fine sessione
- // --- Input Giorni Sessioni (0=Domenica, 1=Lunedì, ..., 6=Sabato) ---
- Inputs:
- StartDaySession1(0), EndDaySession1(1), // Domenica -> Lunedì
- StartDaySession2(1), EndDaySession2(2), // Lunedì -> Martedì
- StartDaySession3(2), EndDaySession3(3), // Martedì -> Mercoledì
- StartDaySession4(3), EndDaySession4(4), // Mercoledì -> Giovedì
- StartDaySession5(4), EndDaySession5(5), // Giovedì -> Venerdì
- StartDaySession6(5), EndDaySession6(6), // Venerdì -> Sabato
- StartDaySession7(6), EndDaySession7(0), // Sabato -> Domenica
- BPV(50); // Big Point Value
- // --- Variabili Sessioni ---
- Vars:
- SessioStart1(0), SessioEnd1(0),
- SessioStart2(0), SessioEnd2(0),
- SessioStart3(0), SessioEnd3(0),
- SessioStart4(0), SessioEnd4(0),
- SessioStart5(0), SessioEnd5(0),
- SessioStart6(0), SessioEnd6(0),
- SessioStart7(0), SessioEnd7(0),
- SessNum(0),
- SessionOpen(false), InSession(false),
- ExitFound(false),
- MyEntryPrice(0), MyExitPrice(0),
- TradeEntryDate(0), TradeExitDate(0),
- TradeEntryTime(0), TradeExitTime(0),
- ChangePoints(0), ChangeDollars(0),
- // Variabili per medie e contatori
- Sum1(0), Sum2(0), Sum3(0), Sum4(0), Sum5(0), Sum6(0), Sum7(0),
- SumDollars1(0), SumDollars2(0), SumDollars3(0), SumDollars4(0), SumDollars5(0), SumDollars6(0), SumDollars7(0),
- Count1(0), Count2(0), Count3(0), Count4(0), Count5(0), Count6(0), Count7(0);
- // --- Definizione Sessioni basate su input ---
- SessioStart1 = IFF(Time = StartTimeSession AND DayOfWeek(Date) = StartDaySession1, 1, 0);
- SessioEnd1 = IFF(Time = EndTimeSession AND DayOfWeek(Date) = EndDaySession1, 1, 0);
- SessioStart2 = IFF(Time = StartTimeSession AND DayOfWeek(Date) = StartDaySession2, 1, 0);
- SessioEnd2 = IFF(Time = EndTimeSession AND DayOfWeek(Date) = EndDaySession2, 1, 0);
- SessioStart3 = IFF(Time = StartTimeSession AND DayOfWeek(Date) = StartDaySession3, 1, 0);
- SessioEnd3 = IFF(Time = EndTimeSession AND DayOfWeek(Date) = EndDaySession3, 1, 0);
- SessioStart4 = IFF(Time = StartTimeSession AND DayOfWeek(Date) = StartDaySession4, 1, 0);
- SessioEnd4 = IFF(Time = EndTimeSession AND DayOfWeek(Date) = EndDaySession4, 1, 0);
- SessioStart5 = IFF(Time = StartTimeSession AND DayOfWeek(Date) = StartDaySession5, 1, 0);
- SessioEnd5 = IFF(Time = EndTimeSession AND DayOfWeek(Date) = EndDaySession5, 1, 0);
- SessioStart6 = IFF(Time = StartTimeSession AND DayOfWeek(Date) = StartDaySession6, 1, 0);
- SessioEnd6 = IFF(Time = EndTimeSession AND DayOfWeek(Date) = EndDaySession6, 1, 0);
- SessioStart7 = IFF(Time = StartTimeSession AND DayOfWeek(Date) = StartDaySession7, 1, 0);
- SessioEnd7 = IFF(Time = EndTimeSession AND DayOfWeek(Date) = EndDaySession7, 1, 0);
- // --- Apertura sessione ---
- If SessioStart1 = 1 or SessioStart2 = 1 or SessioStart3 = 1 or SessioStart4 = 1 or
- SessioStart5 = 1 or SessioStart6 = 1 or SessioStart7 = 1 Then Begin
- SessionOpen = true;
- ExitFound = false;
- // Determina numero sessione
- If SessioStart1 = 1 Then SessNum = 1;
- If SessioStart2 = 1 Then SessNum = 2;
- If SessioStart3 = 1 Then SessNum = 3;
- If SessioStart4 = 1 Then SessNum = 4;
- If SessioStart5 = 1 Then SessNum = 5;
- If SessioStart6 = 1 Then SessNum = 6;
- If SessioStart7 = 1 Then SessNum = 7;
- MyEntryPrice = Open;
- TradeEntryDate = Date;
- TradeEntryTime = Time;
- End;
- // --- Fine sessione ---
- If SessionOpen and (SessioEnd1 = 1 or SessioEnd2 = 1 or SessioEnd3 = 1 or SessioEnd4 = 1 or
- SessioEnd5 = 1 or SessioEnd6 = 1 or SessioEnd7 = 1) Then Begin
- ExitFound = true;
- MyExitPrice = Close;
- TradeExitDate = Date;
- TradeExitTime = Time;
- ChangePoints = MyExitPrice - MyEntryPrice;
- ChangeDollars = ChangePoints * BPV;
- // Aggiorna somme e contatori solo se sessione chiusa correttamente
- If SessNum = 1 then Begin Sum1 = Sum1 + ChangePoints; SumDollars1 = SumDollars1 + ChangeDollars; Count1 = Count1 + 1; End
- Else If SessNum = 2 then Begin Sum2 = Sum2 + ChangePoints; SumDollars2 = SumDollars2 + ChangeDollars; Count2 = Count2 + 1; End
- Else If SessNum = 3 then Begin Sum3 = Sum3 + ChangePoints; SumDollars3 = SumDollars3 + ChangeDollars; Count3 = Count3 + 1; End
- Else If SessNum = 4 then Begin Sum4 = Sum4 + ChangePoints; SumDollars4 = SumDollars4 + ChangeDollars; Count4 = Count4 + 1; End
- Else If SessNum = 5 then Begin Sum5 = Sum5 + ChangePoints; SumDollars5 = SumDollars5 + ChangeDollars; Count5 = Count5 + 1; End
- Else If SessNum = 6 then Begin Sum6 = Sum6 + ChangePoints; SumDollars6 = SumDollars6 + ChangeDollars; Count6 = Count6 + 1; End
- Else If SessNum = 7 then Begin Sum7 = Sum7 + ChangePoints; SumDollars7 = SumDollars7 + ChangeDollars; Count7 = Count7 + 1; End;
- // Print sessione chiusa
- Print("Session: ", SessNum:0:0,
- " | Entry Price: ", MyEntryPrice:0:2,
- " | Entry Date: ", TradeEntryDate,
- " | Entry Time: ", TradeEntryTime,
- " | Exit Price: ", MyExitPrice:0:2,
- " | Exit Date: ", TradeExitDate,
- " | Exit Time: ", TradeExitTime,
- " | Change (pts): ", ChangePoints:0:3,
- " | Change ($): ", ChangeDollars:0:2,
- " | Day ", DayOfWeek(TradeEntryDate):0:0);
- // Plot sessione
- Plot1(MyEntryPrice, "SessStart");
- Plot2(MyExitPrice, "SessEnd");
- SessionOpen = false;
- End;
- // --- Controllo sessioni annullate (entry o exit mancante) ---
- If SessionOpen and LastBarOnChart Then Begin
- Print("Session: ", SessNum:0:0, " | SESSIONE ANNULLATA per mancata apertura o chiusura");
- SessionOpen = false;
- End;
- // --- Medie finali ---
- If LastBarOnChart Then Begin
- Print("----------------------------");
- If Count1 > 0 Then Print("Media Sessione 1: ", (Sum1 / Count1):0:3, " pts");
- If Count2 > 0 Then Print("Media Sessione 2: ", (Sum2 / Count2):0:3, " pts");
- If Count3 > 0 Then Print("Media Sessione 3: ", (Sum3 / Count3):0:3, " pts");
- If Count4 > 0 Then Print("Media Sessione 4: ", (Sum4 / Count4):0:3, " pts");
- If Count5 > 0 Then Print("Media Sessione 5: ", (Sum5 / Count5):0:3, " pts");
- If Count6 > 0 Then Print("Media Sessione 6: ", (Sum6 / Count6):0:3, " pts");
- If Count7 > 0 Then Print("Media Sessione 7: ", (Sum7 / Count7):0:3, " pts");
- Print("----------------------------");
- If Count1 > 0 Then Print("Media $ Sessione 1: ", (SumDollars1 / Count1):0:3, " $");
- If Count2 > 0 Then Print("Media $ Sessione 2: ", (SumDollars2 / Count2):0:3, " $");
- If Count3 > 0 Then Print("Media $ Sessione 3: ", (SumDollars3 / Count3):0:3, " $");
- If Count4 > 0 Then Print("Media $ Sessione 4: ", (SumDollars4 / Count4):0:3, " $");
- If Count5 > 0 Then Print("Media $ Sessione 5: ", (SumDollars5 / Count5):0:3, " $");
- If Count6 > 0 Then Print("Media $ Sessione 6: ", (SumDollars6 / Count6):0:3, " $");
- If Count7 > 0 Then Print("Media $ Sessione 7: ", (SumDollars7 / Count7):0:3, " $");
- Print("----------------------------");
- End;
Advertisement
Add Comment
Please, Sign In to add comment