OPEN-SOURCE SCRIPT
TQQQ EMA Strategy

Idea:
Go long on TQQQ when a fast EMA crosses above a slower EMA, only when the market is treated as trending (ADX filter), then manage the trade with a fixed take-profit, a starting stop, and a stepped trailing stop that only moves up.
Entry
Signal: Fast EMA (default 20) crosses over slow EMA (default 50).
Filters: strategy.equity > 0, ADX ≥ 20 (from ta.dmi(14, 14)), and no open trades (strategy.opentrades == 0), so at most one long at a time.
Size: Shares = floor(equity × buying leverage / close), at least 1. Buying leverage is an input (default 1.0), so position size scales with account equity and price, not the strategy’s default “% of equity” field (the script sets qty explicitly on entry).
Exit
Take profit (limit): Exit limit at entry × take-profit multiplier (default 1.3 → +30% from entry).
Stop: Starts at entry × stop-loss multiplier (default 0.95 → −5%).
Trailing / ladder stop: As unrealized gain vs entry grows, the stop is raised and never lowered:
≥ 10% profit → stop moves to breakeven (entry).
≥ 20% profit → stop moves to entry × 1.1 (+10% from entry).
strategy.exit ties the stop and limit to the “Long” entry (from_entry="Long").
Go long on TQQQ when a fast EMA crosses above a slower EMA, only when the market is treated as trending (ADX filter), then manage the trade with a fixed take-profit, a starting stop, and a stepped trailing stop that only moves up.
Entry
Signal: Fast EMA (default 20) crosses over slow EMA (default 50).
Filters: strategy.equity > 0, ADX ≥ 20 (from ta.dmi(14, 14)), and no open trades (strategy.opentrades == 0), so at most one long at a time.
Size: Shares = floor(equity × buying leverage / close), at least 1. Buying leverage is an input (default 1.0), so position size scales with account equity and price, not the strategy’s default “% of equity” field (the script sets qty explicitly on entry).
Exit
Take profit (limit): Exit limit at entry × take-profit multiplier (default 1.3 → +30% from entry).
Stop: Starts at entry × stop-loss multiplier (default 0.95 → −5%).
Trailing / ladder stop: As unrealized gain vs entry grows, the stop is raised and never lowered:
≥ 10% profit → stop moves to breakeven (entry).
≥ 20% profit → stop moves to entry × 1.1 (+10% from entry).
strategy.exit ties the stop and limit to the “Long” entry (from_entry="Long").
סקריפט קוד פתוח
ברוח האמיתית של TradingView, יוצר הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יוכלו לעיין בו ולאמת את פעולתו. כל הכבוד למחבר! אמנם ניתן להשתמש בו בחינם, אך זכור כי פרסום חוזר של הקוד כפוף ל־כללי הבית שלנו.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.
סקריפט קוד פתוח
ברוח האמיתית של TradingView, יוצר הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יוכלו לעיין בו ולאמת את פעולתו. כל הכבוד למחבר! אמנם ניתן להשתמש בו בחינם, אך זכור כי פרסום חוזר של הקוד כפוף ל־כללי הבית שלנו.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.