답변완료
수식 문의드립니다.
화살표 표시가 안보이는데 어디서 잘 못된걸까요? ^^
진입은 1 이평이 2 이평을 돌파할 때
익절과 손절은 5 이평이 20 이평을 돌파할 때로 잡았습니다
vars:
ma1(0),
ma2(0),
ma5(0),
ma20(0),
longEntry(false),
shortEntry(false);
// 이동평균 계산
ma1 = ma(C, 1);
ma2 = ma(C, 2);
ma5 = ma(C, 5);
ma20 = ma(C, 20);
// === 매수 진입 ===
if (longEntry = false) and (ma1 > ma2) and (ma1[1] <= ma2[1]) and (C > O) then
begin
buy(); // 매수 진입
longEntry = true;
shortEntry = false;
end;
// === 매도 진입 ===
if (shortEntry = false) and (ma1 < ma2) and (ma1[1] >= ma2[1]) and (C < O) then
begin
sell(); // 매도 진입
shortEntry = true;
longEntry = false;
end;
// === 매수 포지션 청산 ===
if longEntry then
begin
// 익절
if (ma5 > ma20) and (ma5[1] <= ma20[1]) then
begin
sell(); // 청산
longEntry = false;
end
// 손절
else if (ma5 < ma20) and (ma5[1] >= ma20[1]) then
begin
sell(); // 청산
longEntry = false;
end;
end;
// === 매도 포지션 청산 ===
if shortEntry then
begin
// 익절
if (ma5 < ma20) and (ma5[1] >= ma20[1]) then
begin
buy(); // 청산
shortEntry = false;
end
// 손절
else if (ma5 > ma20) and (ma5[1] <= ma20[1]) then
begin
buy(); // 청산
shortEntry = false;
end;
end;
2025-05-23
237
글번호 191113
시스템
답변완료
부탁드립니다 항상 감사합니다
Input:
len(10), FC(1), SC(150),
TP_Ratio(0.985), SL_Ratio(1.01), 진입수량(1);
Var:
Price(0), Len1(0), w(0),
H1(0), L1(0), N1(0),
H2(0), L2(0), N2(0),
H3(0), L3(0), N3(0),
dimen1(0), dimen(0), alpha1(0), oldalpha(0),
oldN(0), N(0), alpha_(0), alpha(0), out(0),
진입가(0), TP(0), SL(0), posFlag(0), tx(0);
// FRAMA 계산
Price = (H + L) / 2;
len1 = len / 2;
w = log(2 / (SC + 1));
H1 = highest(H, len1);
L1 = lowest(L, len1);
N1 = (H1 - L1) / len1;
H2 = highest(H, len)[len1];
L2 = lowest(L, len)[len1];
N2 = (H2 - L2) / len1;
H3 = highest(H, len);
L3 = lowest(L, len);
N3 = (H3 - L3) / len;
dimen1 = (log(N1 + N2) - log(N3)) / log(2);
dimen = iff(N1 > 0 and N2 > 0 and N3 > 0, dimen1, iff(isnan(dimen1[1]), 0, dimen1[1]));
alpha1 = exp(w * (dimen - 1));
oldalpha = iff(alpha1 > 1, 1, iff(alpha1 < 0.01, 0.01, alpha1));
oldN = (2 - oldalpha) / oldalpha;
N = (((SC - FC) * (oldN - 1)) / (SC - 1)) + FC;
alpha_ = 2 / (N + 1);
alpha = iff(alpha_ < 2 / (SC + 1), 2 / (SC + 1), iff(alpha_ > 1, 1, alpha_));
out = (1 - alpha) * iff(isnan(out[1]), 0, out[1]) + alpha * Price;
// 진입 조건
If Close < out and Close[1] >= out[1] and posFlag = 0 Then
Begin
SellShort("FRAMA Short") next bar at market;
진입가 = Close;
TP = 진입가 * TP_Ratio;
SL = 진입가 * SL_Ratio;
posFlag = -1;
tx = Text_New(Date, Time, High, "진입조건만족");
Text_SetColor(tx, Red);
End;
// 청산 조건
If posFlag = -1 Then
Begin
If Close <= TP or Close >= SL Then
Begin
BuyToCover("청산") next bar at market;
posFlag = 0;
End;
End;
// 시각화
Plot1(out, "FRAMA", Blue);
지표로 적용할수있게 수정부탁드립니다 감사합니다!!
2025-05-22
250
글번호 191101
지표
답변완료
키움
가=(highest(high,midPeriod)+lowest(low,midPeriod))/2;
나=supertrend(period, multiplier);
M50=ma(C, 50);
M200=ma(C, 200);
M5=ma(C, 5);
M1=ma(C, 1);
CrossUp(나, 가)OR
crossUP(C, 가)OR
CrossUp(M1, M5)OR
CrossUp(M1, M200)OR
CrossUp(M1, M50)OR
C>가 AND C>나 AND C>M5 AND C>M200
period 60
multiplier 2
midPeriod 26
항상감사합니다
2025-05-22
251
글번호 191100
종목검색