OPEN-SOURCE SCRIPT

Price_Deviation Oleg

420
📘 Description
This script is an extended and customized version of the original work by the respected author fullmax.
I adapted the logic for my own trading needs and added several improvements, including lot‑precision rounding to prevent exchange errors when using webhook automation, as well as additional visualization elements for clarity.

🔧 Key Enhancements
Lot precision control (prevents invalid quantity errors on exchanges when using webhooks)

Base order labels for easier visual tracking

Mini‑table with live position metrics

Configurable date‑range window for backtesting

Dynamic safety‑order price calculation

Trailing take‑profit option

Improved visualization of thresholds, MA, and TP levels

🎯 How the Strategy Works
The script calculates a moving average and compares the current price deviation against user‑defined thresholds.
When the deviation condition is met, the strategy opens a base position and then manages it using safety orders that scale in both volume and distance.

After entering a position, the script manages exits using:

a fixed take‑profit target

or an optional trailing take‑profit

plus a breakeven reference line

and an auto‑close mechanism when the averaging cycle resets

All order quantities are rounded according to the selected lot precision to ensure compatibility with exchange requirements when sending webhook‑based orders.

⚙️ Features Overview
Deviation‑based entry logic

Safety orders with volume and step scaling

Configurable date window for testing

Trailing TP with adjustable distance

Breakeven visualization

Mini‑table showing quantity, USD value, open trades, PnL, and equity

Clean and intuitive chart visualization

📝 Disclaimer
This script is provided for educational purposes only.
It does not constitute financial advice and does not guarantee profits.
Always test strategies on historical data before using them in live trading.

כתב ויתור

המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.