找不到有关创建特定交易视图指标的文档

时间:2019-12-22 16:22:50

标签: pine-script

感谢您抽出宝贵的时间阅读本文章。

-我是pine-script的新手,在过去几天中(未成功地)尝试使用一些非常具体的参数为Tradingview创建一个比特币指标。

第1步:在00:00(UTC),[开盘价]是多少?

示例1:在00:00(UTC)[开盘价] = $ 1000

第2步:采用[开盘价]并在[开盘价]下以多于$ 15的多头订单,或在[开盘价]下以$ 15做空的短订单, 先到者

示例2:放置 $ 1015 订单的** Long 。或以 985美元的价格做空,以先到者为准。**

第3步:下订单后,将[止损]设置在多头下方30美元或空头上方30美元。

示例3:做多的[止损]为985美元,做空的[止损]为1015美元。

第4步:更新止损–如果价格比买入价格高出12美元或比卖空价格低12美元,则将新的止损设在多头下方$ .50,或在空头上方$ .50。

示例4:多头价格为1027美元,止损移至1026.5美元,或空头价格为973美元止损移至973.5美元。

第5步:对于比当前多头价格高出10美元的新止损,将新的止损设置为比当前多头价格低5美元,对于价格每高出10美元的价格,则将新的止损设置为比当前多头价格高出5美元。

示例5:多头价格为1027美元,止损为1026.5美元。多头价格为1037,止损为1032。空头价格为973美元,止损为973.5美元。空头价格为963美元,止损为968美元。

此过程一直持续到触发止损为止。然后整个过程将在第二天的世界标准时间00:00再次开始。

-对我来说,我要完成的工作似乎很简单,但是我找不到任何有帮助的文档或示例。我愿意接受所有建议,非常感谢您的指导和知识!谢谢

编辑:

//@version=2

strategy(title = "TEST INDICATOR",overlay = true,calc_on_every_tick=true,default_qty_type=strategy.percent_of_equity,default_qty_value=100,initial_capital=7000)

// Get daily price data
dayOpen  = security(tickerid, "D", open[0])

// Compute values
EntryHighCalc = (dayOpen + 15) / dayOpen
EntryLowCalc = (dayOpen - 15) / dayOpen

EntryHLong = (dayOpen * EntryHighCalc)
EntryLShort = (dayOpen * EntryLowCalc)

// Plot values
plot(series=dayOpen, style=cross, linewidth=2, color=orange)
plot(series=EntryHLong, style=circles, linewidth=3, color=green)
plot(series=EntryLShort, style=circles, linewidth=3, color=red)

// Determine order conditions
priceTouched = (EntryHLong) or (EntryLShort)
timeFilter   = (year > 2019) and (month > 12)

enterLong    = priceTouched and timeFilter
enterShort   = priceTouched and timeFilter

// Everything above this line, works as intended...I think. It creates a range of $15 above and below the Day candle OPEN price. However
// However timeFiler doesnt seem to work, but it doesnt hurt the code currently. Just trying to define a range.

// Below I am trying to set a stop loss at +/-30 after the entry, and then scale +/-.5 in each direction after the price moves another $13.

// Submit orders - Long

//strategy.entry("EntryL", long=true, when=enterLong)
//strategy.exit("LongExit1", "EntryL", loss = (EntryHLong - 30))

// What do I define here to make the stop loss work?
//if  XXXXXX == (EntryHLong + 13)
//strategy.exit("LongExit2", "LongExit1", stop = (EntryHLong + 13 - 0.5)) 

// Submit order - Short

//strategy.entry("EntryS", long=false, when=enterShort)
//strategy.exit("ShortExit1", "EntryS", loss = (EntryLShort + 30))

// What do I define here to make the stop loss work?
//if  YYYYYY == (EntryLShort - 13)
//strategy.exit("ShortExit2", "ShortExit1", stop = (EntryLShort -13 + 0.5)) 

0 个答案:

没有答案