tarzan

Momentuminator 1.0

Here we have a general purpose momentum based long and short flip flop with optional profit target and maximum loss.

Program development: Boffin Hollow Lab

Author: Tarzan at tradingview.com

Release: Version 1.0 May 2016

Please Note: Past Performance is not necessarily indicative of future results
開源腳本

本著真正的TradingView精神,該腳本的作者將其開源發布,以便交易者可以理解和驗證它。為作者喝彩吧!您可以免費使用它,但在出版物中重複使用此代碼受網站規則的約束。 您可以收藏它以在圖表上使用。

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。

想在圖表上使用此腳本?
//@version=2
strategy("Momentuminator 1.0", title = "Momentuminator", overlay=true)

//©2016 Boffin Hollow Lab
//Author: Craig Harris

//color the background by days of the week

c = navy


bgColor = (dayofweek == monday)    ? color(c, 94) :
          (dayofweek == tuesday)   ? color(c, 90) :
          (dayofweek == wednesday) ? color(c, 86) :
          (dayofweek == thursday)  ? color(c, 84) :
          (dayofweek == friday)    ? color(c, 82) : na
          
          
bgcolor(color = bgColor)

//input parms and variables

length = input(12)
tgtt = input(title = "profit target", defval=600, step = 5)
mloss = input (title = "Maximum Loss",defval=-600, step=5)
price = close

//momentuminator function

momentum(seria, length) =>
    mom = seria - seria[length]
    mom
    
// give it to a mom    

momz = momentum(price, length)
mom1 = momentum( momz, 1)

if (momz > 0 and mom1 > 0)
    strategy.entry("MomLE", strategy.long, stop=high+syminfo.mintick, comment="MomLE")
else
    strategy.cancel("MomLE")
    
strategy.close("MomLE", when = strategy.openprofit > (tgtt))    
strategy.close("MomSE", when = strategy.openprofit > (tgtt))     

if (momz < 0 and mom1 < 0)
    strategy.entry("MomSE", strategy.short, stop=low-syminfo.mintick, comment="MomSE")
else
    strategy.cancel("MomSE")
    
strategy.close("MomLE", when = strategy.openprofit > (tgtt))    
strategy.close("MomSE", when = strategy.openprofit > (tgtt)) 

strategy.close("MomLE", when = strategy.openprofit < (mloss))    
strategy.close("MomSE", when = strategy.openprofit < (mloss))    

//plot(strategy.equity, title="equity", color=red, linewidth=2, style=areabr)