英文:
how to loop through a string and see if "1" is an element in the str?
问题
如果orderIds
中存在一个名为"1"的元素,
则将buy1
设置为true
。
orderIds = ""
for idx = 0 to strategy.opentrades - 1
strSuffix = idx == strategy.opentrades - 1 ? "" : ", "
orderIds += strategy.opentrades.entry_id(idx) + strSuffix
英文:
if orderIds has a present element called "1"
then buy1 = true
orderIds = ""
for idx = 0 to strategy.opentrades - 1
strSuffix = idx == strategy.opentrades - 1 ? "" : ", "
orderIds += strategy.opentrades.entry_id(idx) + strSuffix
答案1
得分: 0
orderIds = ""
for idx = 0 to strategy.opentrades - 1
strSuffix = idx == strategy.opentrades - 1 ? "" : ", "
orderIds += strategy.opentrades.entry_id(idx) + strSuffix
// 在图表上显示结果
label.new(bar_index, high, orderIds)
// 如果你的订单ID是"1",那么cakes = 12222
cakes = 10000
if str.contains(orderIds, '1')
cakes := 12222
plot(cakes)
英文:
orderIds = ""
for idx = 0 to strategy.opentrades - 1
strSuffix = idx == strategy.opentrades - 1 ? "" : ", "
orderIds += strategy.opentrades.entry_id(idx) + strSuffix
//Show result on the chart
label.new(bar_index, high, orderIds)
// if your order ID is "1" then cakes = 12222
cakes = 10000
if str.contains(orderIds, '1')
cakes := 12222
plot(cakes)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论