资源加载中... loading...

SuperTrend

Author: 发明者量化, Date: 2022-04-27 18:21:50
Tags: supertrend

At the request of our platform users, FMZ is compatible with the Pine language function library of TradingView now, and has entered a stable version.

  • the grammer is fully compatible with v5 version
  • all indicators of ta library are fully implemented
  • full implementation of math library
  • full implementation of string library
  • full implementation of array library
  • input parameters are recognized in the interface automatically
  • request.security support for heikinashi
  • strategy library implementation (full support for stop loss/profit target/trailing stop/conditional orders, etc.)
  • compatible with plot/plotchar/plotshape/plotcandle/alert/alertcondition etc.

It is a continuous process that provide full support for language functions, and this public version is made available in advance for user testing.

Later, FMZ will continue to increase and improve the function library support for Pine language of TradingView, if necessary, please leave a comment on this strategy.

Remark: If you encounter undefined variables, it is proved that this attribute is not supported. You can delete the relevant call, or send a work order to contact the technician to solve the problem.

img


/*backtest
start: 2020-04-27 00:00:00
end: 2022-04-26 23:59:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Bitfinex","currency":"BTC_USD"}]
*/
strategy("supertrend", overlay=true)

[supertrend, direction] = ta.supertrend(input(5, "factor"), input.int(10, "atrPeriod"))

plot(direction < 0 ? supertrend : na, "Up direction", color = color.green, style=plot.style_linebr)
plot(direction > 0 ? supertrend : na, "Down direction", color = color.red, style=plot.style_linebr)

if direction < 0
    if supertrend > supertrend[2]
        strategy.entry("entry long", strategy.long)
    else if strategy.position_size < 0
        strategy.close_all()
else if direction > 0
    if supertrend < supertrend[3]
        strategy.entry("entry short", strategy.short)
    else if strategy.position_size > 0
        strategy.close_all()

template: strategy.tpl:40:21: executing "strategy.tpl" at <.api.GetStrategyListByName>: wrong number of args for GetStrategyListByName: want 7 got 6