Search
📝

SuperTrend Cross 전략

SuperTrend를 상향돌파하면 매수, SuperTrend를 하향이탈하면 매도
Input : period(10),multiplier(3); Var : src(0), alpha(0),ATRV(0),upperBand(0),lowerBand(0),direction(0),SuperTrend(C); var : value(0); src = (H+L)/2; if CurrentBar > 1 Then { alpha = 1 / period ; ATRV = IFf(IsNan(ATRV[1]) == true, ma(TrueRange,period) , alpha * TrueRange + (1 - alpha) * IFf(isnan(ATRV[1])==true,0,ATRV[1])); upperBand = src + multiplier * ATRV; lowerBand = src - multiplier * ATRV; if lowerBand > lowerBand[1] or close[1] < lowerBand[1] Then lowerBand = lowerBand; Else lowerBand = lowerBand[1]; if upperBand < upperBand[1] or close[1] > upperBand[1] Then upperBand = upperBand; Else upperBand = upperBand[1]; if C > UpperBand Then direction = 1; if C < LowerBand Then direction = -1; if direction == 1 Then SuperTrend = lowerband; Else SuperTrend = upperband; if CrossUp(C,supertrend) Then Buy("B"); if CrossDown(C,supertrend) Then Sell("S"); }
JavaScript
복사