Search
📝

Triple SuperTrend 전략

기간과 승수가 다른 3개의 Supertrend가 동일방향일때 진입하는 전략
input : period1(10),multiplier1(1); input : period2(11),multiplier2(2); input : period3(12),multiplier3(3); var : src(0); var : alpha1(0),ATRV1(0),upperBand1(0),lowerBand1(0),direction1(0),SuperTrend1(C); var : alpha2(0),ATRV2(0),upperBand2(0),lowerBand2(0),direction2(0),SuperTrend2(C); var : alpha3(0),ATRV3(0),upperBand3(0),lowerBand3(0),direction3(0),SuperTrend3(C); src = (H+L)/2; if CurrentBar > 1 Then { alpha1 = 1 / period1 ; ATRV1 = IFf(IsNan(ATRV1[1]) == true, ma(TrueRange,period1) , alpha1 * TrueRange + (1 - alpha1) * IFf(isnan(ATRV1[1])==true,0,ATRV1[1])); upperBand1 = src + multiplier1 * ATRV1; lowerBand1 = src - multiplier1 * ATRV1; if lowerBand1 > lowerBand1[1] or close[1] < lowerBand1[1] Then lowerBand1 = lowerBand1; Else lowerBand1 = lowerBand1[1]; if upperBand1 < upperBand1[1] or close[1] > upperBand1[1] Then upperBand1 = upperBand1; Else upperBand1 = upperBand1[1]; if C > UpperBand1 Then direction1 = 1; if C < LowerBand1 Then direction1 = -1; if direction1 == 1 Then SuperTrend1 = lowerband1; Else SuperTrend1 = upperband1; alpha2 = 1 / period2 ; ATRV2 = IFf(IsNan(ATRV2[1]) == true, ma(TrueRange,period2) , alpha2 * TrueRange + (1 - alpha2) * IFf(isnan(ATRV2[1])==true,0,ATRV2[1])); upperBand2 = src + multiplier2 * ATRV2; lowerBand2 = src - multiplier2 * ATRV2; if lowerBand2 > lowerBand2[1] or close[1] < lowerBand2[1] Then lowerBand2 = lowerBand2; Else lowerBand2 = lowerBand2[1]; if upperBand2 < upperBand2[1] or close[1] > upperBand2[1] Then upperBand2 = upperBand2; Else upperBand2 = upperBand2[1]; if C > UpperBand2 Then direction2 = 1; if C < LowerBand2 Then direction2 = -1; if direction2 == 1 Then SuperTrend2 = lowerband2; Else SuperTrend2 = upperband2; alpha3 = 1 / period3 ; ATRV3 = IFf(IsNan(ATRV3[1]) == true, ma(TrueRange,period3) , alpha3 * TrueRange + (1 - alpha3) * IFf(isnan(ATRV3[1])==true,0,ATRV3[1])); upperBand3 = src + multiplier3 * ATRV3; lowerBand3 = src - multiplier3 * ATRV3; if lowerBand3 > lowerBand3[1] or close[1] < lowerBand3[1] Then lowerBand3 = lowerBand3; Else lowerBand3 = lowerBand3[1]; if upperBand3 < upperBand3[1] or close[1] > upperBand3[1] Then upperBand3 = upperBand3; Else upperBand3 = upperBand3[1]; if C > UpperBand3 Then direction3 = 1; if C < LowerBand3 Then direction3 = -1; if direction3 == 1 Then SuperTrend3 = lowerband3; Else SuperTrend3 = upperband3; Condition1 = C > SuperTrend1 and C > SuperTrend2 and C > SuperTrend3); Condition2 = C < SuperTrend1 and C < SuperTrend2 and C < SuperTrend3); if Condition1 == true and Condition1[1] == False Then Buy("b"); if Condition2 == true and Condition2[1] == False Then Sell(""); }
JavaScript
복사