OPEN-SOURCE SCRIPT

TP Calculator (70% & 1.5x)

66
//version=5
indicator("TP Calculator (70% & 1.5x)", overlay=true)

// -------- Inputs --------
entry = input.float(100.0, "Entry Price")
stoploss = input.float(90.0, "Stop Loss")

// -------- Determine Direction --------
// اگر SL پایین‌تر بود = پوزیشن Long
// اگر SL بالاتر بود = پوزیشن Short
isLong = stoploss < entry ? true : false

// -------- Calculations --------
distance = math.abs(entry - stoploss)

// جهت پوزیشن (بالا یا پایین TP می‌رود)
direction = isLong ? 1 : -1

tp1 = entry + direction * (distance * 0.70) // 70%
tp2 = entry + direction * (distance * 1.50) // 1.5x

// -------- Plot Levels --------
plot(entry, "Entry", color=color.blue, linewidth=2)
plot(stoploss, "Stop Loss", color=color.red, linewidth=2)

plot(tp1, "TP1 (70%)", color=color.green, linewidth=2)
plot(tp2, "TP2 (1.5x)", color=color.orange, linewidth=2)

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.