繁体   English   中英

当我在“strategy.entry()”中使用与“strategy()”中的默认值不同的值时,订单单位不一致

[英]When I use a different value in "strategy.entry()" from the default value in "strategy()", the order unit is inconsistent

请教一个关于“strategy.cash”的问题,非常感谢。 我在strategy()中设置了“default_qty_type=strategy.cash,default_qty_value=30,currency=currency.USD”,当我使用“strategy.entry("buy8",strategy.long)”时,订单是Buying 共30美元价值的比特币以美元计,但是当我使用“strategy.entry("buy8",strategy.long,qty=10)”时,订单是购买十个比特币。 为什么第二种购买方式不是美元?

代码在这里:

//@version=4
strategy("My Strategy", overlay=true,pyramiding=1000,default_qty_type=strategy.cash,default_qty_value=30,currency=currency.USD)

//******************************************定义界限曲线
jema1400=sma(close,1400)//定义1400日均线-等效200周均线
jema1008=sma(close,1008)//定义1008日均线-等效144周均线
jema623=sma(close,623)//定义623日均线-等效89周均线
jema200=ema(close,200)//定义200日均线
// jema111=sma(close,111)//定义111日均线
// jema3502=2*sma(close,350)//定义200日均线
// plot(jema1400,color=color.red)
// plot(jema1008,color=color.purple)
// plot(jema623,color=color.blue)
plot(jema200,color=color.green)
days = (time- timestamp(2009, 01, 09, 00, 00)) / (24 * 60 * 60 * 1000)//定义从当前开始和比特币开始挖矿时的间隔天数
// plot(days)
pvolution=exp(log(10)*(5.755*log10(days)-16.751))//估值曲线
// plot(pvolution,color=color.orange,style=plot.style_circles)
pvolution12=sqrt(1.2*jema200*pvolution) //根据九神的估值曲线和九神指数计算指数为1.2时的价格曲线
plot(pvolution12,color=bar_index % 2 == 0 ? color.orange : #00000000)//用虚线显示1.2定投曲线
pvolution45=sqrt(0.45*jema200*pvolution)//根据九神的估值曲线和九神指数计算指数为1.2时的价格曲线  
// plot(pvolution45,color=#AAAAAA)

//*************************************定义定投指数
x = if close < jema1400
    5
else if close > jema1400 and close < jema1008
    3
else if close > jema1400 and close > jema1008 and close < jema623 
    1
else
    0
// plot(x,style=plot.style_columns,color= x==5 ? color.red : x==3 ? color.orange : x==1 ? color.orange : color.white)

y = if close < pvolution12 and close < jema200
    5
else if close < pvolution12 and close > jema200
    3
else
    0
// plot(y,style=plot.style_columns,color= y==5 ? color.red : y==3 ? color.orange : color.blue)

z = x+y
// plot(z,style=plot.style_columns,color= z==10 ? color.green : z==8 ? color.orange : z==6 ? color.blue : z==5 ? color.purple : z==4 ? color.gray : z==3 ? color.orange : color.red)

//******************************定义定投策略
longCondition10 = z==10
longCondition8 = z==8
longCondition6 = z==6
longCondition5 = z==5
longCondition4 = z==4
longCondition3 = z==3
longCondition1 = z==1
if (longCondition10)
    strategy.entry("buy10",strategy.long,qty=10)//but the order here is based on the number of bitcoins???
if (longCondition8)
    strategy.entry("buy8",strategy.long,qty=8)//but the order here is based on the number of bitcoins
if (longCondition6)
    strategy.entry("buy6",strategy.long,qty=6)//but the order here is based on the number of bitcoins
if (longCondition5)
    strategy.entry("buy5",strategy.long)//The order here is based on USD, the same as the default
if (longCondition4)
    strategy.entry("buy4",strategy.long)
if (longCondition3)
    strategy.entry("buy3",strategy.long)
if (longCondition1)
    strategy.entry("buy1",strategy.long)
shortCondition = crossover(sma(close, 111), 2*sma(close, 350))
if(shortCondition)
    strategy.exit("exit",stop = (high+low)/2)
//****************************

我的目的是用不同的资金在不同的地方购买比特币

strategy.entry(...qty) 只接受合同,不接受现金或股权的百分比。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM