답변완료
함수요청
안녕하세요?
아래 함수의 고점과 저점을 적용하여 글번호 77957번의 전략을 작성하고 싶습니다.
스크립트 수정 부탁드립니다.
#HHLL
Input : short(12), long(26), signal(9),P(20);
Var : MACDv(0), MACDs(0),macdo(0),T(0),HH(0),LL(0);
var : d1(0),t1(0),tl1(0),tl2(0),mav(0),entry(0);
MACDv = MACD(short, long);
MACDs = ema(MACDv,signal);
macdo = MACDv-MACDs;
mav = ma(C,P);
if Bdate != Bdate[1] Then
{
d1 = sDate;
t1 = sTime;
HH = macdo;
LL = macdo;
Condition1 = False;
entry = 0;
T = 1;
}
if (MarketPosition != 0 and MarketPosition != MarketPosition[1]) or
(MarketPosition == MarketPosition[1] and TotalTrades > TotalTrades[1]) Then
entry = entry+1;
if d1 > 0 Then
{
if macdo > hh Then
hh = macdo;
if macdo < ll Then
ll = macdo;
if Condition1 == False and hh >= ll+0.5 Then
{
Condition1 = true;
var1 = DayHigh;
Var2 = DayLow;
TL1 = TL_New(d1,t1,var1,NextBarSdate,NextBarStime,var1);
TL2 = TL_New(d1,t1,var2,NextBarSdate,NextBarStime,var2);
}
if Condition1 == true Then
{
TL_SetEnd(TL1,sDate,sTime,var1);
TL_SetEnd(TL2,sDate,sTime,var2);
# 77957번 전략
input : HH(360),LL(350);
var : entry(0),T(0);
if Bdate != Bdate[1] then
{
entry = 0;
T = 1;
}
if (MarketPosition != 0 and MarketPosition != MarketPosition[1]) Or
(MarketPosition == MarketPosition[1] and TotalTrades > TotalTrades[1]) Then
entry = entry+1;
if CrossUp(C,HH) Then
T = 1;
if CrossDown(C,LL) Then
T = -1;
if Bdate == Bdate[3] Then
{
if T == 1 and CountIf(C > HH and C > O and C > C[1],3) == 3 Then
{
if entry < 1 Then
Buy("b1");
Else
ExitShort();
}
if T == -1 and CountIf(C < LL and C > O and C > C[1],3) == 3 Then
{
if entry < 1 Then
Buy("b2");
Else
ExitShort();
}
if T == 1 and CountIf(C > HH and C < O and C < C[1],3) == 3 Then
{
if entry < 1 Then
Sell("s1");
Else
ExitLong();
}
if T == -1 and CountIf(C < LL and C < O and C < C[1],3) == 3 Then
{
if entry < 1 Then
Sell("s2");
Else
ExitLong();
}
}
###스크립트 -> 이렇게 작성하면 원하는 신호가 아닙니다
Input : short(12), long(26), signal(9),P(20);
Var : MACDv(0), MACDs(0),macdo(0),T(0),HH(0),LL(0);
var : d1(0),t1(0),tl1(0),tl2(0),mav(0),entry(0);
MACDv = MACD(short, long);
MACDs = ema(MACDv,signal);
macdo = MACDv-MACDs;
mav = ma(C,P);
if Bdate != Bdate[1] Then
{
d1 = sDate;
t1 = sTime;
HH = macdo;
LL = macdo;
Condition1 = False;
entry = 0;
T = 1;
}
if (MarketPosition != 0 and MarketPosition != MarketPosition[1]) or
(MarketPosition == MarketPosition[1] and TotalTrades > TotalTrades[1]) Then
entry = entry+1;
if d1 > 0 Then
{
if macdo > hh Then
hh = macdo;
if macdo < ll Then
ll = macdo;
if Condition1 == False and hh >= ll+0.5 Then
{
Condition1 = true;
var1 = DayHigh;
Var2 = DayLow;
TL1 = TL_New(d1,t1,var1,NextBarSdate,NextBarStime,var1);
TL2 = TL_New(d1,t1,var2,NextBarSdate,NextBarStime,var2);
}
if Condition1 == true Then
{
TL_SetEnd(TL1,sDate,sTime,var1);
TL_SetEnd(TL2,sDate,sTime,var2);
if Bdate != Bdate[1] then
{
entry = 0;
T = 1;
}
if (MarketPosition != 0 and MarketPosition != MarketPosition[1]) Or
(MarketPosition == MarketPosition[1] and TotalTrades > TotalTrades[1]) Then
entry = entry+1;
if CrossUp(C,HH) Then
T = 1;
if CrossDown(C,LL) Then
T = -1;
if Bdate == Bdate[3] Then
{
if T == 1 and CountIf(C > HH and C > O and C > C[1],3) == 3 Then
{
if entry < 1 Then
Buy("b1");
Else
ExitShort();
}
if T == -1 and CountIf(C < LL and C > O and C > C[1],3) == 3 Then
{
if entry < 1 Then
Buy("b2");
Else
ExitShort();
}
if T == 1 and CountIf(C > HH and C < O and C < C[1],3) == 3 Then
{
if entry < 1 Then
Sell("s1");
Else
ExitLong();
}
if T == -1 and CountIf(C < LL and C < O and C < C[1],3) == 3 Then
{
if entry < 1 Then
Sell("s2");
Else
ExitLong();
}
}
}
}
SetStopEndofday(151500);
2022-07-06
1378
글번호 160500
시스템
답변완료
수식 문의
아래는 일전에 도움을 주신,
RSI의 과매도,과매수권을 캔들위에 표현하는 수식입니다.
이를 수정하여,
RSI signal 의 과매도 과매수권을 캔들위에 표현하고 싶습니다.
RSI signal = ma((RSI(RSI_Period)),시그널);
아래 수식의 rsi를 RSI signal로 수정하면 되지 않을까 싶은데
실력이 천박하여 이렇게 문의드립니다.
부탁 드립니다. 감사합니다.
Input : Length(9);
Var : Counter(0), DownAmt(0), UpAmt(0), UpSum(0), DownSum(0), UpAvg(0), DownAvg(0),RSIV(0),Current(0);
var : cnt1(0),current1(0),UpAmt1(0),DownAmt1(0),UpAvg1(0),DownAvg1(0),RSIv1(0);
var : cnt2(0),current2(0),UpAmt2(0),DownAmt2(0),UpAvg2(0),DownAvg2(0),RSIv2(0);
var : upPrice(0),dnPrice(0);
If CurrentBar == 1 AND Length > 0 Then
Begin
UpSum = 0;
DownSum = 0;
For Counter = 0 To Length - 1
Begin
UpAmt = C[Counter] - C[Counter+1];
If UpAmt >= 0 Then
DownAmt = 0;
Else Begin
DownAmt = -UpAmt;
UpAmt = 0;
End;
UpSum = UpSum + UpAmt;
DownSum = DownSum + DownAmt;
End;
UpAvg = UpSum / Length;
DownAvg = DownSum / Length;
End
Else If CurrentBar > 1 AND Length > 0 Then Begin
UpAmt = C[0] - C[1];
If UpAmt >= 0 Then
DownAmt = 0;
Else Begin
DownAmt = -UpAmt;
UpAmt = 0;
End;
UpAvg = (UpAvg[1] * (Length - 1) + UpAmt) / Length;
DownAvg = (DownAvg[1] * (Length - 1) + DownAmt) / Length;
End;
If UpAvg + DownAvg <> 0 Then
RSIv = 100 * UpAvg / (UpAvg + DownAvg);
Else
RSIv = 0;
IF rsiv[1] >= 30 AND rsiv[1] <= 70 Then
{
for cnt1 = 0 to 100
{
Current1 = C+PriceScale*cnt1;
UpAmt1 = current1 - C[1];
If UpAmt1 >= 0 Then
DownAmt1 = 0;
Else
Begin
DownAmt1 = -UpAmt1;
UpAmt1 = 0;
End;
UpAvg1 = (UpAvg[1] * (Length - 1) + UpAmt1) / Length;
DownAvg1 = (DownAvg[1] * (Length - 1) + DownAmt1) / Length;
If UpAvg1 + DownAvg1 <> 0 Then
RSIv1 = 100 * UpAvg1 / (UpAvg1 + DownAvg1);
Else
RSIv1 = 0;
IF rsiv1 >= 70 Then
{
upPrice = CURRENT1;
cnt1 = 101;
}
}
for cnt2 = 0 to 100
{
Current2 = C-PriceScale*cnt2;
UpAmt2 = current2 - C[1];
If UpAmt2 >= 0 Then
DownAmt2 = 0;
Else
Begin
DownAmt2 = -UpAmt2;
UpAmt2 = 0;
End;
UpAvg2 = (UpAvg[1] * (Length - 1) + UpAmt2) / Length;
DownAvg2 = (DownAvg[1] * (Length - 1) + DownAmt2) / Length;
If UpAvg2 + DownAvg2 <> 0 Then
RSIv2 = 100 * UpAvg2 / (UpAvg2 + DownAvg2);
Else
RSIv2 = 0;
IF rsiv2 <= 30 Then
{
dnPrice = CURRENT2;
cnt2 = 101;
}
}
plot1(upPrice);
plot2(dnPrice);
}
2022-07-06
1076
글번호 160495
지표