new to v4
This commit is contained in:
parent
897556f8e4
commit
fca4c10820
@ -9,23 +9,25 @@ n2 = input(21, title="WT Average Length")
|
|||||||
|
|
||||||
// Wavetrend Indicator Calculation
|
// Wavetrend Indicator Calculation
|
||||||
ap = hlc3
|
ap = hlc3
|
||||||
esa = ta.ema(ap, n1)
|
esa = ema(ap, n1)
|
||||||
d = ta.ema(math.abs(ap - esa), n1)
|
d = ema(abs(ap - esa), n1)
|
||||||
ci = (ap - esa) / (0.015 * d)
|
ci = (ap - esa) / (0.015 * d)
|
||||||
tci = ta.ema(ci, n2)
|
tci = ema(ci, n2)
|
||||||
wt1 = tci
|
wt1 = tci
|
||||||
wt2 = ta.sma(wt1, 4)
|
wt2 = sma(wt1, 4)
|
||||||
|
|
||||||
// RSI and Stochastic RSI Calculation
|
// RSI and Stochastic RSI Calculation
|
||||||
rsiValue = ta.rsi(close, rsiLength)
|
rsiValue = rsi(close, rsiLength)
|
||||||
stochRsiValue = ta.stoch(rsiValue, rsiValue, rsiValue, stochRsiLength)
|
stochRsiValue = stoch(rsiValue, rsiValue, rsiValue, stochRsiLength)
|
||||||
|
|
||||||
// Function to calculate points for a given indicator and pair
|
// Function to calculate points for a given indicator and pair
|
||||||
calcPoints(currentValue, previousValue, isInverse) =>
|
calcPoints(currentValue, previousValue, isInverse) =>
|
||||||
|
value = 0
|
||||||
if isInverse
|
if isInverse
|
||||||
currentValue < previousValue ? 1 : currentValue > previousValue ? -1 : 0
|
value := currentValue < previousValue ? 1 : currentValue > previousValue ? -1 : 0
|
||||||
else
|
else
|
||||||
currentValue > previousValue ? 1 : currentValue < previousValue ? -1 : 0
|
value := currentValue > previousValue ? 1 : currentValue < previousValue ? -1 : 0
|
||||||
|
value
|
||||||
|
|
||||||
// Calculate points for each currency pair
|
// Calculate points for each currency pair
|
||||||
longPoints(pair, isInverse) =>
|
longPoints(pair, isInverse) =>
|
||||||
@ -36,47 +38,27 @@ longPoints(pair, isInverse) =>
|
|||||||
|
|
||||||
shortPoints(pair, isInverse) => -longPoints(pair, isInverse)
|
shortPoints(pair, isInverse) => -longPoints(pair, isInverse)
|
||||||
|
|
||||||
// Pairs and their corresponding inverse flag
|
// Hardcode the pairs and their corresponding inverse flags
|
||||||
var pairs = array.new_string(5)
|
pairs = ["US30", "GOLD", "DXY", "BTCUSDT.P", syminfo.tickerid]
|
||||||
var isInverse = array.new_bool(5)
|
isInverse = [false, false, true, false, false] // Inverse for DXY
|
||||||
array.set(pairs, 0, "US30")
|
|
||||||
array.set(pairs, 1, "GOLD")
|
|
||||||
array.set(pairs, 2, "DXY") // DXY is inversed
|
|
||||||
array.set(pairs, 3, "BTCUSDT.P")
|
|
||||||
array.set(pairs, 4, syminfo.ticker)
|
|
||||||
array.set(isInverse, 0, false)
|
|
||||||
array.set(isInverse, 1, false)
|
|
||||||
array.set(isInverse, 2, true) // Inverse for DXY
|
|
||||||
array.set(isInverse, 3, false)
|
|
||||||
array.set(isInverse, 4, false)
|
|
||||||
|
|
||||||
// Initialize arrays for storing points
|
// Initialize variables for storing points
|
||||||
var longPointsArray = array.new_float(size = 5, initial_value = 0)
|
var float totalLongPoints = 0
|
||||||
var shortPointsArray = array.new_float(size = 5, initial_value = 0)
|
var float totalShortPoints = 0
|
||||||
|
|
||||||
// Calculate points for each pair
|
// Calculate points for each pair
|
||||||
for i = 0 to array.size(pairs) - 1
|
for i = 0 to 4
|
||||||
pair = array.get(pairs, i)
|
pair = pairs[i]
|
||||||
inverseFlag = array.get(isInverse, i)
|
inverseFlag = isInverse[i]
|
||||||
array.set(longPointsArray, i, longPoints(pair, inverseFlag))
|
totalLongPoints := totalLongPoints + longPoints(pair, inverseFlag)
|
||||||
array.set(shortPointsArray, i, shortPoints(pair, inverseFlag))
|
totalShortPoints := totalShortPoints + shortPoints(pair, inverseFlag)
|
||||||
|
|
||||||
// Calculate total points
|
|
||||||
totalLongPoints = array.sum(longPointsArray)
|
|
||||||
totalShortPoints = array.sum(shortPointsArray)
|
|
||||||
|
|
||||||
// Display the results
|
// Display the results
|
||||||
for i = 0 to array.size(pairs) - 1
|
|
||||||
pair = array.get(pairs, i)
|
|
||||||
plot(array.get(longPointsArray, i), title="Long Points " + pair, color=color.green)
|
|
||||||
plot(array.get(shortPointsArray, i), title="Short Points " + pair, color=color.red)
|
|
||||||
|
|
||||||
plot(totalLongPoints, title="Total Long Points", color=color.blue)
|
plot(totalLongPoints, title="Total Long Points", color=color.blue)
|
||||||
plot(totalShortPoints, title="Total Short Points", color=color.orange)
|
plot(totalShortPoints, title="Total Short Points", color=color.orange)
|
||||||
|
|
||||||
|
|
||||||
// BUYING VOLUME AND SELLING VOLUME //
|
// BUYING VOLUME AND SELLING VOLUME //
|
||||||
buyVolume = iff( (high==low), 0, volume*(close-low)/(high-low))
|
buyVolume = high == low ? 0 : volume * (close - low) / (high - low)
|
||||||
sellVolume = iff( (high==low), 0, volume*(high-close)/(high-low))
|
sellVolume = high == low ? 0 : volume * (high - close) / (high - low)
|
||||||
plot(volume, style=plot.style_columns, color=color.red, title="SELL V") // shows total volume (!)
|
plot(volume, style=plot.style_columns, color=color.red, title="SELL V") // shows total volume (!)
|
||||||
plot(buyVolume, style=plot.style_columns, color=color.teal, title="BUY V") // shows only buy volume
|
plot(buyVolume, style=plot.style_columns, color=color.teal, title="BUY V") // shows only buy volume
|
||||||
|
Loading…
x
Reference in New Issue
Block a user