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 : 기준선(0), 전환선(0),선행스팬1(0), 선행스팬2(0); 전환선 = (Highest(High, 9) + Lowest(Low, 9)) / 2; 기준선 = (Highest(High, 26) + Lowest(Low, 26)) / 2; 선행스팬1 = (전환선[25] + 기준선[25]) / 2 ; 선행스팬2 = (Highest(High, 52)[25] + Lowest(Low, 52)[25]) / 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; Condition1 = C > SuperTrend and C > max(선행스팬1,선행스팬2); Condition2 = C < SuperTrend and C < min(선행스팬1,선행스팬2); if Condition1 == true and Condition1[1] == False Then Buy("b"); if Condition2 == true and Condition2[1] == False Then Sell(""); }
JavaScript
복사