fix array

This commit is contained in:
Dobromir Popov 2024-01-12 16:09:56 +02:00
parent fca4c10820
commit 7e4b76fbec

View File

@ -38,9 +38,16 @@ longPoints(pair, isInverse) =>
shortPoints(pair, isInverse) => -longPoints(pair, isInverse) shortPoints(pair, isInverse) => -longPoints(pair, isInverse)
// Hardcode the pairs and their corresponding inverse flags // Hardcoded pairs and their corresponding inverse flags
pairs = ["US30", "GOLD", "DXY", "BTCUSDT.P", syminfo.tickerid] pairs = array.new_string(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")
array.set(pairs, 3, "BTCUSDT.P")
array.set(pairs, 4, syminfo.tickerid)
isInverse = array.new_bool(5, false)
array.set(isInverse, 2, true) // Inverse for DXY
// Initialize variables for storing points // Initialize variables for storing points
var float totalLongPoints = 0 var float totalLongPoints = 0
@ -48,8 +55,8 @@ var float totalShortPoints = 0
// Calculate points for each pair // Calculate points for each pair
for i = 0 to 4 for i = 0 to 4
pair = pairs[i] pair = array.get(pairs, i)
inverseFlag = isInverse[i] inverseFlag = array.get(isInverse, i)
totalLongPoints := totalLongPoints + longPoints(pair, inverseFlag) totalLongPoints := totalLongPoints + longPoints(pair, inverseFlag)
totalShortPoints := totalShortPoints + shortPoints(pair, inverseFlag) totalShortPoints := totalShortPoints + shortPoints(pair, inverseFlag)
@ -57,8 +64,8 @@ for i = 0 to 4
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 = high == low ? 0 : volume * (close - low) / (high - low) buyVolume = high == low ? 0 : volume * (close - low) / (high - low)
sellVolume = 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