Advertisement
Maurizio-Ciullo

Indicatore Z-Score Con Strategia

Aug 26th, 2023
928
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {{ INIZIO INDICATORE }}
  2. Inputs: ThresholdValue(0), zscore(0);
  3. Variables: EntryPrice(0), ExitPrice(0), Difference(0), Result(0);
  4.  
  5. condition1 = close > Average(close, 21);
  6. condition2 = close < Average(close, 21);
  7.  
  8. If condition1 and EntryPrice = 0 Then
  9.     EntryPrice = Close
  10. else If condition2 Then Begin
  11.     ExitPrice = Close;  
  12.     if EntryPrice <> 0 then
  13.     begin
  14.         Difference = ExitPrice - EntryPrice;
  15.         EntryPrice = 0;
  16.         ExitPrice = 0;
  17.     end;
  18. End;
  19. {{ FINE INDICATORE }}
  20.  
  21. if zscore = 1 then
  22. begin
  23.     if close > Average(close, 21) and Difference < 0 then
  24.         buy next bar at market
  25.     else
  26.         sell next bar at market;
  27. end
  28. else
  29. begin
  30.     if close > Average(close, 21) then
  31.         buy next bar at market
  32.     else if close < Average(close, 21) then
  33.         sell next bar at market;
  34. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement