簡體   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