pipCharlie

Chandelier Stop

A modified verion of the Chande & Kroll's Stop indicator.
开源脚本

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

免责声明

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

想在图表上使用此脚本?
//+------------------------------------------------------------------+
//| Edited original VStop Script from LazyBear using info from       |
//|                                           ChandelierStops_v1.mq4 |
//|                                  Copyright © 2006, Forex-TSD.com |
//|                         Written by IgorAD,igorad2003@yahoo.co.uk |   
//|            http://finance.groups.yahoo.com/group/TrendLaboratory |                                      
//+------------------------------------------------------------------+

study("Chandelier Stop", overlay=true)

//input variables
Length=input(title="Look Back Period", type=integer, defval=22)
ATRPeriod=input(title="ATR Period", type=integer, defval=22)
Mult=input(title="ATR Multiplier", type=integer, defval=3)

//calculate stop value
short_stop = lowest(Length)+Mult*atr(ATRPeriod)
long_stop  = highest(Length)-Mult*atr(ATRPeriod)

shortvs=na(shortvs[1]) ? short_stop : iff(close>shortvs[1], short_stop , min(short_stop,shortvs[1]))
longvs=na(longvs[1]) ? long_stop : iff(close<longvs[1], long_stop, max(long_stop,longvs[1]))

longswitch=iff (close>=shortvs[1] and close[1]<shortvs[1] , 1 ,  0)
shortswitch=iff (close<=longvs[1] and close[1]>longvs[1] ,  1 ,  0)

direction= iff(na(direction[1]), 0, 
			iff (direction[1]<=0 and longswitch, 1, 
			iff (direction[1]>=0 and shortswitch, -1, direction[1])))
			
pc=direction>0?longvs:shortvs

plot(pc, color=direction>0?aqua:fuchsia, style=circles, linewidth=2)
plot(pc, color=direction>0?aqua:fuchsia, style=line, linewidth=2)