Search
📝

SuperTrend+지수이동평균 전략

SuperTrend가 상승추세이고 종가가 지수이평보다 클때 매수 SuperTrend가 하락추세이고 종가가 지수이평보다 작을때 매도
Input : period(10),multiplier(3),EmaPeriod(200); Var : src(0), alpha(0),ATRV(0),upperBand(0),lowerBand(0),direction(0),SuperTrend(C); var : Emav(0); src = (H+L)/2; Emav = Ema(c,EmaPeriod); 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; Condition1 = C > SuperTrend and C > emav; Condition2 = C < SuperTrend and C < emav; if Condition1 == true and Condition1[1] == False Then Buy("b"); if Condition2 == true and Condition2[1] == False Then Sell(""); }
JavaScript
복사