Maurizio-Ciullo

Study Azionario Nasdaq Multiticker Trend Long 1440 Min

Apr 2nd, 2026
62
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3.                                                         // ============================================================
  4.                                                         // *** STUDY AZIONARIO NASDAQ MULTI TICKER TREND LONG 1440 MIN  *** //
  5.                                                         // ============================================================
  6.  
  7.  
  8. // ============================================================
  9. // TIPO STRATEGIA: TREND
  10. // STRUMENTO: AZIONARIO NASDAQ MULTI TICKER
  11. // TICKER: TRADESTATION 100 TICKER NASDAQ CSV IN CARTELLA
  12. // TIMEFRAME: 1440 MIN
  13. // DATI: TRADESTATION DAL 01/01/2006 AL 01/04/2026
  14. // SESSIONI: EXCHANGE TIME
  15. // LUN-LUN 09:30 - 16:00 SESSION END YES
  16. // MAR-MAR 09:30 - 16:00 SESSION END YES
  17. // MER-MER 09:30 - 16:00 SESSION END YES
  18. // GIO-GIO 09:30 - 16:00 SESSION END YES
  19. // VEN-VEN 09:30 - 16:00 SESSION END YES
  20. // MINI PAUSA : NO
  21. // BARS BACK: 200
  22. // COMMISSIONI SVILUPPO: 0
  23. // COMMISSIONI DOPO SVILUPPO: 1$, 2$ TOT, 2 TICK SLIPPAGE
  24. // POSITION SIZE SVILUOPPO 10000 / CLOSE
  25. // CORRELAZIONI STRUMENTI:  S&P 500 / RUSSEL 2000
  26. // ============================================================
  27.  
  28. // ==================LONG======================================
  29. // DESCRIZIONE INGRESSO: UNA PERCENTUALE DEI TITOLI NASDAQ È SOPRA NUOVI 52W HIGH / CLOSE > SMA / SUPERTREND / PATTERN INCLUSIONE SETTIMANALE / PATTERN ESCLUSIONE SETTIMANALE
  30. // DESCRIZIONE USCITA: CLOSE CROSS UNDER LEADLINE2 E CONVERSIONELINE > LEADLINE / NO SUPERTREND / TRAILING STOP PERCENTUALE
  31. // ESCLUSIONI: MESI/GIORNI/ORE NESSUNA
  32. // ============================================================
  33.    
  34.  
  35.    
  36. // ==============================           ==============================          ==============================          ==============================
  37. // ============================================================================
  38. // MARKET REGIME HLIDX - INDICATOR VERSION
  39. // ============================================================================
  40.  
  41. Inputs:
  42.     Len(10),
  43.     UseEMA(1),
  44.     OffsetPct(50);
  45.  
  46. Vars:
  47.     Highs(0),
  48.     Lows(0),
  49.     Ratio(0),
  50.     HLIDX(0),
  51.     BreadthOK(false);
  52.  
  53. // =========================
  54. // CALCOLO SOLO SE DATA2 DISPONIBILE
  55. // =========================
  56. If BarNumber of Data2 >= Len then begin
  57.  
  58.     Highs = High of Data2;
  59.     Lows  = Low of Data2;
  60.  
  61.     // Ratio
  62.     If (Highs + Lows) > 0 then
  63.         Ratio = Highs / (Highs + Lows)
  64.     else
  65.         Ratio = 0;
  66.  
  67.     // Smooth
  68.     If UseEMA = 1 then
  69.         HLIDX = XAverage(Ratio, Len) * 100
  70.     else
  71.         HLIDX = Average(Ratio, Len) * 100;
  72.  
  73.     // Regime boolean (stesso della strategy)
  74.     If HLIDX > OffsetPct then
  75.         BreadthOK = true
  76.     else
  77.         BreadthOK = false;
  78.  
  79. end
  80. else begin
  81.     HLIDX = 0;
  82.     BreadthOK = false;
  83. end;
  84.  
  85. // ============================================================================
  86. // PLOT MARKET REGIME HLIDX - INDICATOR VERSION
  87. // ============================================================================
  88.  
  89. // linea indice
  90. Plot1(HLIDX, "HLIDX");
  91.  
  92. // linea soglia regime
  93. Plot2(OffsetPct, "Threshold");
  94.  
  95. // colore regime ON/OFF identico alla strategy
  96. If BreadthOK then
  97.     SetPlotColor(1, Green)
  98. else
  99.     SetPlotColor(1, Red);
  100.    
  101. // ==============================           ==============================          ==============================          ==============================
  102. // ============================================================================
  103. // SIMPLE MOVING AVERAGE – INDICATOR VERSION
  104. // ============================================================================
  105.  
  106. Inputs:
  107.     LongLen(200);        
  108. Vars:
  109.     LongMA(0);
  110.    
  111. LongMA = Average(Close, LongLen);
  112.  
  113. // ============================================================================
  114. // PLOT SIMPLE MOVING AVERAGE
  115. // ============================================================================
  116.  
  117. Plot3(LongMA, "LongMA");
  118. SetPlotColor(3, Yellow);
  119.  
  120. // ==============================           ==============================          ==============================          ==============================
  121. // ============================================================================
  122. // ICHIMOKU – INDICATOR VERSION
  123. // ============================================================================
  124.  
  125. // =========================
  126. // INPUTS
  127. // =========================
  128.  
  129. Inputs:
  130.     ConversionPeriods(9),       // Periodi per la linea di conversione (Tenkan)
  131.     BasePeriods(26),            // Periodi per la linea base (Kijun)
  132.     TenkanLen(5),               // Periodi per calcolo slope Tenkan
  133.     LeadLine2LowPeriods(26),    // Periodi low per Leading Span 2 (più veloce)
  134.     SpanBPeriods(52);           // Periodi high-low per Span B
  135.  
  136. // =========================
  137. // VARS
  138. // =========================
  139. Vars:    
  140.     ConversionLine(0),          // Linea di conversione (Tenkan)
  141.     BaseLine(0),                // Linea base (Kijun)
  142.     LeadLine1(0),               // Leading Span 1
  143.     LeadLine2(0),               // Leading Span 2
  144.     SpanA(0),                   // Span A
  145.     Kijun(0),                   // Kijun temporanea
  146.     Tenkan(0),                  // Tenkan temporanea
  147.     Slope(0);                   // Slope Tenkan
  148.  
  149. // =========================
  150. // CALCOLI DONCHIAN LINES
  151. // =========================
  152. ConversionLine = (Lowest(Low, ConversionPeriods) + Highest(High, ConversionPeriods)) / 2;
  153. BaseLine       = (Lowest(Low, BasePeriods) + Highest(High, BasePeriods)) / 2;
  154.  
  155. // =========================
  156. // CALCOLI LEADING SPANS
  157. // =========================
  158. LeadLine1 = (ConversionLine + BaseLine) / 2;  
  159. LeadLine2 = (Lowest(Low, LeadLine2LowPeriods) + Highest(High, SpanBPeriods)) / 2;
  160.  
  161. // =========================
  162. // TENKAN & SLOPE
  163. // =========================
  164. Tenkan = (Highest(High,9) + Lowest(Low,9)) / 2;
  165. Slope  = Tenkan - Tenkan[TenkanLen];
  166.  
  167. // =========================
  168. // SPAN A
  169. // =========================
  170. SpanA = (Tenkan + Kijun) / 2;
  171.  
  172. // ============================================================================
  173. // PLOT ICHIMOKU
  174. // ============================================================================
  175.  
  176. Plot4(ConversionLine, "Conversion");    // Linea di conversione (Tenkan)
  177. SetPlotColor(4, Cyan);
  178.  
  179. //Plot5(BaseLine, "Base");                // Linea base (Kijun)
  180. //SetPlotColor(5, Magenta);
  181.  
  182. //Plot6(LeadLine1, "Lead1");              // Leading Span 1
  183. //SetPlotColor(6, Green);
  184.  
  185. Plot7(LeadLine2, "LeadLine2");              // Leading Span 2
  186. SetPlotColor(7, Magenta);
  187.  
  188. // ==============================           ==============================          ==============================          ==============================
  189. // ============================================================================
  190. // SUPERTREND – INDICATOR VERSION
  191. // ============================================================================
  192.  
  193. // =========================
  194. // INPUTS
  195. // =========================
  196. Inputs:
  197.     atrPeriod(10),       // Periodi ATR
  198.     factor(3);           // Moltiplicatore ATR (anche 2.1 va bene)
  199.  
  200. // =========================
  201. // VARS
  202. // =========================
  203. Vars:
  204.     atr(0),              // ATR corrente
  205.     upperBand(0),        // Banda superiore base
  206.     lowerBand(0),        // Banda inferiore base
  207.     finalUpper(0),       // Upper band trailing
  208.     finalLower(0),       // Lower band trailing
  209.     supertrend(0),       // Valore SuperTrend
  210.     direction(0);        // Direzione trend: -1 = uptrend, +1 = downtrend
  211.  
  212. // =========================
  213. // CALCOLO ATR
  214. // =========================
  215. atr = AvgTrueRange(atrPeriod);
  216.  
  217. // =========================
  218. // CALCOLO BANDE BASE
  219. // =========================
  220. upperBand = (High + Low) / 2 + factor * atr;
  221. lowerBand = (High + Low) / 2 - factor * atr;
  222.  
  223. // =========================
  224. // INIZIALIZZAZIONE
  225. // =========================
  226. if CurrentBar = 1 then begin
  227.     finalUpper = upperBand;
  228.     finalLower = lowerBand;
  229.     direction = 1;  // downtrend iniziale
  230. end
  231. else begin
  232.  
  233.     // --- Upper band trailing ---
  234.     if upperBand < finalUpper[1] or Close[1] > finalUpper[1] then
  235.         finalUpper = upperBand
  236.     else
  237.         finalUpper = finalUpper[1];
  238.  
  239.     // --- Lower band trailing ---
  240.     if lowerBand > finalLower[1] or Close[1] < finalLower[1] then
  241.         finalLower = lowerBand
  242.     else
  243.         finalLower = finalLower[1];
  244.  
  245.     // --- Direzione ---
  246.     if supertrend[1] = finalUpper[1] then begin
  247.         if Close > finalUpper then
  248.             direction = -1   // uptrend
  249.         else
  250.             direction = 1;   // downtrend
  251.     end
  252.     else begin
  253.         if Close < finalLower then
  254.             direction = 1   // downtrend
  255.         else
  256.             direction = -1; // uptrend
  257.     end;
  258.  
  259. end;
  260.  
  261. // =========================
  262. // VALORE SUPERTREND
  263. // =========================
  264.  
  265. if direction = -1 then
  266.     supertrend = finalLower
  267. else
  268.     supertrend = finalUpper;
  269.  
  270. // ============================================================================
  271. // PLOT SUPERTREND
  272. // ============================================================================
  273.  
  274. // Plot8 = SuperTrend sul grafico principale (overlay)  
  275. Plot8(supertrend, "SuperTrend");
  276.  
  277. // Colori: verde = uptrend, rosso = downtrend
  278. if direction = -1 then
  279.     SetPlotColor(8, Green)
  280. else
  281.     SetPlotColor(8, Red);
  282.  
  283.  
  284. // ==============================           ==============================          ==============================          ==============================
  285. // ============================================================================
  286. // PTNBASESA LY WEEKLY 23
  287. // ============================================================================
  288.  
  289. var: PtnBaseSA23(false), minimo_uno_weekly(0), minimo_cinque_weekly(0);
  290.  
  291. // --- valori settimanali ---
  292. minimo_uno_weekly    = loww(1);      // low della settimana scorsa
  293. minimo_cinque_weekly = loww(5);      // low delle ultime 5 settimane
  294.  
  295. // --- confronto booleano ---
  296. PtnBaseSA23 = (minimo_uno_weekly < minimo_cinque_weekly);
  297.  
  298. // ============================================================================
  299. // PLOT PTNBASESA LY WEEKLY 23
  300. // ============================================================================
  301.  
  302. // --- plot booleano (1 = true, 0 = false) ---
  303. if PtnBaseSA23 then
  304.     Plot9(1, "Ptn Inclusione")
  305. else
  306.     Plot9(0);
  307.  
  308. SetPlotColor(9, RGB(255,165,0));       // Orange
  309.  
  310. // ==============================           ==============================          ==============================          ==============================
  311. // ============================================================================
  312. // PTNBASESA LN WEEKLY 21
  313. // ============================================================================
  314.  
  315. var: PtnBaseSA21(false), massimo_uno_weekly(0), massimo_cinque_weekly(0);
  316.  
  317. // --- valori settimanali ---
  318. massimo_uno_weekly    = highw(1);     // high della settimana scorsa
  319. massimo_cinque_weekly = highw(5);     // high delle ultime 5 settimane
  320.  
  321. // --- confronto booleano invertito: 1 quando NOT PtnBaseSA21 ---
  322. PtnBaseSA21 = (massimo_uno_weekly > massimo_cinque_weekly);
  323.  
  324. // ============================================================================
  325. // PLOT PTNBASESA LN WEEKLY 21
  326. // ============================================================================
  327.  
  328. // --- plot booleano (1 = true, 0 = false) ---
  329. if not PtnBaseSA21 then
  330.     Plot10(1, "Ptn Esclusione")
  331. else
  332.     Plot10(0);
  333.  
  334. SetPlotColor(10, RGB(255,165,0));      // Orange
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment