aquajets1

Binary Options Strategy Testing Script

This is a script for testing binary options trading strategies. To test a strategy, modify the 'go_down' or 'go_up' booleans. These SHOULD NOT access any current values (for example, 'ohlc4' or 'close'), or the backtesting will not be an accurate representation of the forward values.

Modify the fraction_return input to be the return rate of the option on success. This is assumed to be a true 100 or 0 option- i.e. if the choice is not correct, there is a 100% loss.

The strategy in place is merely an example, and as you can see, has a very negative rate of return when implemented as a strategy.

Please comment in your code if you use this in any future posts. Thanks!
开源脚本

本着真正的TradingView精神,该脚本的作者将其开源发布,以便交易者可以理解和验证它。为作者喝彩!您可以免费使用它,但在出版物中重复使用此代码受网站规则的约束。 您可以收藏它以在图表上使用。

免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。

想在图表上使用此脚本?
//@version=2
study("Binary Options Tester", overlay=false)

sma_12_min = sma(hl2,12)
sma_60_min = sma(hl2,60)

go_down = (open[1] > close[1]) and (open[2] > close[2]) and (sma_12_min[1] < sma_60_min[1])
go_up = (open[1] < close[1]) and (open[2] < close[2]) and (sma_12_min[1] > sma_60_min[1])

//win/lose testing. leave these lines for tester
val_win = go_down ? ((open[0] > close[0]) ? (val_win[1] + 1) : (val_win[1])) : (go_up ? ((open[0] < close[0]) ? (val_win[1] + 1) : (val_win[1])) : (nz(val_win[1]) + 0))
val_lose = go_down ? ((open[0] > close[0]) ? (val_lose[1]) : (val_lose[1] + 1)) : (go_up ? ((open[0] < close[0]) ? (val_lose[1]) : (val_lose[1] + 1)) : (nz(val_lose[1]) + 0))
//

fraction_return = input(.88, title='fraction_return')

return = (val_win * fraction_return)  - val_lose

plot(return)
//plot(val_win,color=green)
//plot(val_lose,color=red)
//plot(sma_12_min, color=blue)
//plot(sma_60_min, color=orange)