Hello,
after recive a json page, I put a value inside a list.
Then, i need to do an operation ((a/b)-1) from the before value and current value.
From the list, I have create a map, but the order inside it, is not correct an different from the list
Let's write code:
Then I generate the MAP from the previus List
--------------------------------------------------------------------------------------------------------------
I have use this rude mode:
Result data:
Now, I need to count how many max times the value is > 0 and < 0
In this example, there are 3 negative and 4 positive.
Thank you
after recive a json page, I put a value inside a list.
Then, i need to do an operation ((a/b)-1) from the before value and current value.
From the list, I have create a map, but the order inside it, is not correct an different from the list
Let's write code:
B4X:
listacandele.Clear ' as list
kandleCalc.Clear ' as map
Dim j As HttpJob
j.Initialize("", Me) 'name is empty as it is no longer needed
j.Download("https://api.binance.com/api/v3/klines?symbol=BTCUSDT&interval=1d&limit=10") '&orderby=my_totbalance 'limit=10 limit the number of results
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Log(j.GetString)
' 'The result is a json string. We parse it and log the fields.
Dim parser As JSONParser
parser.Initialize(j.getstring)
Dim root As List = parser.NextArray
For Each colroot As List In root
Dim cndclose As String = colroot.Get(4)
Log(cndclose)
listacandele.Add(cndclose)
Next
' 'listacandele.Add(
File.WriteList(folder,"candele.txt",listacandele)
Then I generate the MAP from the previus List
B4X:
For i = 1 To listacandele.Size-1
Log(i)
kandleCalc.Put(listacandele.Get(i-1),listacandele.Get(i))
Log(kandleCalc.Get(i))
Log(listacandele.Get(i-1))
i = i+1
Log(i)
Next
File.WriteMap(folder,"candele.txt",kandleCalc)
37311.61000000
41574.25000000
41382.59000000
42380.87000000
43839.99000000
44042.99000000
44372.72000000
43495.44000000
42373.73000000
41846.69000000
41574.25000000
41382.59000000
42380.87000000
43839.99000000
44042.99000000
44372.72000000
43495.44000000
42373.73000000
41846.69000000
42373.73000000=41846.69000000
37311.61000000=41574.25000000
41382.59000000=42380.87000000
44372.72000000=43495.44000000
43839.99000000=44042.99000000
37311.61000000=41574.25000000
41382.59000000=42380.87000000
44372.72000000=43495.44000000
43839.99000000=44042.99000000
I have use this rude mode:
B4X:
If j.Success Then
Log(j.GetString)
' 'The result is a json string. We parse it and log the fields.
Dim parser As JSONParser
parser.Initialize(j.getstring)
Dim root As List = parser.NextArray
For Each colroot As List In root
Dim cndclose As String = colroot.Get(4)
Log(cndclose)
listacandele.Add(cndclose)
Next
' 'listacandele.Add(
File.WriteList(folder,"candele.txt",listacandele)
Dim n As Double
For i = 1 To listacandele.Size-1
Log(i)
Log(listacandele.Get(i-1))
Log(listacandele.Get(i))
n = listacandele.Get(i) / listacandele.Get(i-1) - 1
Log(n)
kandleCalc.Add(n)
Log(i)
Next
Result data:
B4X:
-0.004610065124446061
0.02412318803632174
0.03442874108058658
0.004630475508776266
0.007486548937753801
-0.01977070596528674
-0.025789140194926174
-0.003678222332563097
0.0014081714686220437
Now, I need to count how many max times the value is > 0 and < 0
In this example, there are 3 negative and 4 positive.
Thank you
Last edited: