답변완료
질문 부탁드립니다
답변 감사드립니다
질문 1)
아래식에서
for문을 수행했는데 해당 값이 없을 경우, 그 다음에
if aa[0]*1.05 < aa[cnt] 를 for cnt=1 to 5 로 수행하려고 한다면
어떻게 작성을 해야 할까요?
value1=0;
for cnt=1 to 5
{
if aa[0]*1.2 < aa[cnt] then
{
value1=aa[cnt];
}
}
위의 질문과 별개로
아래와 같이 나눠서 작성한다면 for 문을 순차적으로 수행하게 되는건가요??
첫번째 for 문에서 저장된 value1 값이
두번째 for문으로 의해서 두번째 value1 값으로 변경되는건가요? (기존 value1에 덮어씌움?)
value1=0;
for cnt=1 to 5
{
if aa[0]*1.2 < aa[cnt] then
{
value1=aa[cnt];
}
}
for cnt=1 to 5
{
if aa[0]*1.05 < aa[cnt] then
{
value1=aa[cnt];
}
}
질문2))
if h>l*1.08 then
{
sum1=0; sumi1=0;
For cnt = 49 DownTo 1
{
id[cnt]=id[cnt-1];
}
id[0]= index;
For cnt = 1 to (id[0]-id[1])
{
sum1=sum1+l[cnt];
sumi1=sumi1+1;
}
value1=sum1/sumi1;
For cnt = 49 DownTo 1
{
aa[cnt] = aa[cnt-1];
}
aa[0] = value1;
For cnt = 1 to (id[0]-id[1])
{
if h[cnt]>aa[0] then value2=cnt;
}
}
위에 식에서 aa[0] 보다 큰 고가의 갯수를 value2 에 저장을 했는데요
만약에 cnt = 1 to (id[0]-id[2] )
cnt= 1 to (id[0]-id[3])
,,,
이런식으로 cnt= 1 to (id[0]-id[4]) 까지 고가의 갯수를 각각 구했을때,
value2 보다 처음으로 2배 이상의 값을 가지게 됐을때 id[] 의 번호와 고가값의 갯수를 저장하고자 하는데 통합된 식으로 작성을 도와주셨으면 합니다
예를들어서 기준이 되는 value2 가 5일때, 만약 id[3] 까지 구했을때는 8, id[4] 까지는 12개가 나왔다면 id[4]의 번호 (4번) 과 고가값의 갯수를 저장하고자 합니다
질문3)
질문2와 같이 갯수 비교하는 수식을 만들려고 하는데요
For cnt = 1 to (id[0]-id[1])
{
if h[cnt]>aa[0] and l[cnt]<aa[0] then value2=cnt;
}
위와 같은 식이 있을때,
같은 for 범위 ( cnt = 1 to (id[0]-id[1]) 인데 aa[] 값을 다르게 해서 비교하려고 합니다
if h[cnt]>aa[0] and l[cnt]<aa[0]
h[cnt]>aa[1] and l[cnt]<aa[1]
...
h[cnt]>aa[3] and l[cnt]<aa[3]
이렇게 각각의 cnt 값들을 구했을때 이들중에서 cnt 가 가장 클때 그 값과, 그때의 aa 배열의 의 순번을 저장하고 싶습니다
예를들어 aa[3] 일때 봉갯수가 가장 많다면 봉갯수와 aa[3] 을 저장을 하고 싶습니다
감사합니다
2025-05-23
215
글번호 191099
지표
답변완료
시작시간 문의
늘 감사합니다.
아래 수식이 안되네요 . 검토좀 해주세요.
input : 시작시간(090000),ntime(30);
var : S1(0),D1(0),TM(0),TF(0),TL(0);
if data1((sDate != sDate[1] and sTime >= 시작시간) or
(sDate == sDate and sTime >= 시작시간 and sTime[1] < 시작시간)) Then
{
S1 = data1(TimeToMinutes(시작시간));
D1 = data1(sdate);
}
if D1 > 0 then
{
if data1(sdate) == D1 Then
TM = data1(TimeToMinutes(stime))-S1;
Else
TM = data1(TimeToMinutes(stime))+1440-S1;
TF = TM%ntime;
if Bdate != Bdate[1] or
(Bdate == Bdate[1] and ntime > 1 and TF < TF[1]) or
(Bdate == Bdate[1] and ntime > 1 and TM >= TM[1]+ntime) or
(Bdate == Bdate[1] and ntime == 1 and TM > TM[1]) Then
{
TL = TL_New_Self(sDate,sTime,-999999999,sDate,sTime,999999999);
TL_SetColor(TL,Black);
TL_SetSize(TL,0);
}
}
Plot1(data1(HighD(0)), "고가",Red);
Plot2(data1(lowD(0)), "저가",Blue);
Plot3(data1(OpenD(0)), "시가");
Plot4(data1(CloseD(0)), "현재");
감사합니다.
2025-05-22
196
글번호 191097
지표
답변완료
지표 변환 부탁드립니다.
//@version=6
indicator(title="Price Oscillator", shorttitle="PPO", format=format.price, precision=2, timeframe="", timeframe_gaps=true)
shortlen = input.int(12, "Short Length", minval=1)
longlen = input.int(26, "Long Length", minval=1)
signallen = input.int(9, "Signal Length", minval=1)
src = input.source(close, title="Source")
exp = input.bool(true, "Use exponential MA")
esma(source, length)=>
s = ta.sma(source, length)
e = ta.ema(source, length)
exp ? e : s
short = esma(src, shortlen)
long = esma(src, longlen)
po = (short - long) / long * 100
sl = esma(po, signallen)
hist = po - sl
plot(hist, title = "Histogram", style = plot.style_columns, color = (hist >= 0 ? (hist[1] < hist ? #26A69A : #B2DFDB) : (hist[1] < hist ? #FFCDD2 : #FF5252)))
plot(po, color=color.teal, title="PPO")
plot(sl, color=color.orange, title="Signal Line")
hline(0, "Zero Line", color=#787B86)
2025-05-22
219
글번호 191093
지표
답변완료
다시 문의드립니다.
문의드린 이전 수식변환에서 아래와 같이 답을 주셨습니다.
1분봉 차트에, 같은 기간(50)과 승수(5)를 적용해서 트레이딩뷰와 비교했더니
첨부된 그림처럼 다르게 나옵니다.
heikinashi supertrend 라기보다 그냥 supertrend 처럼 구현됩니다.
왜 다르게 나오는지
번거로우시겠지만 다시한번 검토부탁드립니다.
그리고 녹색선과 빨강선의 바뀌는 부분을 연결부탁드립니다.
감사합니다.
=========================
안녕하세요
예스스탁입니다.
input : upertrendAtrPeriod(10);
input : supertrendAtrMultiplier(2.7);
var : haClose(0),haOpen(0),haHigh(0),haLow(0),haTR(0),alpha(0),haTrueRange(0);
var : haSupertrendUp(0),haSupertrendDown(0),trendingUp(Nan),trendingDown(Nan);
var : direction(0),supertrend(0),supertrendUp(False),supertrendDown(False);
if index == 0 then
{
haClose = (O+H+L+C)/4;
haOpen = open;
haHigh = MaxList( high, haOpen, haClose);
haLow = MinList( low, haOpen,haClose);
}
else
{
haClose = (O+H+L+C)/4;
haOpen = (haOpen [1] + haClose [1])/2 ;
haHigh = MaxList(High, haOpen, haClose) ;
haLow = MinList(Low, haOpen, haClose) ;
}
haTR = iff(IsNan(haOpen[1]) == true, haOpen-haLow, max(max(haOpen - haLow, abs(haOpen - haClose[1])), abs(haLow - haClose[1])));
alpha = 1 / upertrendAtrPeriod ;
haTrueRange = IFf(IsNan(haTrueRange[1]) == true, ma(haTR,upertrendAtrPeriod) , alpha * haTR + (1 - alpha) * IFf(isnan(haTrueRange[1])==true,0,haTrueRange[1]));
haSupertrendUp =((haHigh +haLow )/2 )-(supertrendAtrMultiplier *haTrueRange );
haSupertrendDown =((haHigh +haLow )/2 )+(supertrendAtrMultiplier *haTrueRange );
direction = 0;
trendingUp = iff(haClose[1]>trendingUp[1] , max (haSupertrendUp ,trendingUp[1]) , haSupertrendUp);
trendingDown = iff(haClose[1]<trendingDown[1] , min (haSupertrendDown ,trendingDown[1]) , haSupertrendDown);
direction = iff(haClose > trendingDown[1] , 1 , iff(haClose < trendingUp[1], -1 , IFf(IsNan(direction[1]) == true,1,direction[1])));
supertrend = iff(direction == 1 , trendingUp , trendingDown);
if direction == 1 Then
{
plot1(supertrend,"supertrendUp", Green);
NoPlot(2);
}
Else
{
plot2(supertrend,"supertrendDow", Red);
NoPlot(1);
}
=========================
2025-05-22
269
글번호 191084
지표
답변완료
문의드립니다,
수고많으십니다.
아래수식중 증액을할때 진입할때마다라고 했는데 시스템에서 정한기준안에서
예를들면 시스템진입식에 10번진입 실제진입5번일때 실제진입한것만
증액으로 진입식부탁드립니다.
1.
inputs : P1(5),P2(20),RSILength(10), OverSold(30),OverBought(70);
input : 첫진입금액(1000000),A(10);
var : m1(0,Data2),m2(0,Data2), R(0,Data1);
var : TT(0,Data1),T1(0,Data1),entry(0,Data1),mm(0,data1),vol(0,Data1);
m1 = Data2(ma(C,P1));
m2 = Data2(ma(C,P2));
R = data1(RSI(RSILength));
If Data2(m1 > m2) and Crossup(R, OverSold) Then
{
if TotalTrades == 0 Then
mm = 첫진입금액;
Else
mm = mm*(1+A/100);
Buy("B",OnClose,Def,Floor(Floor(mm/C)/10)*10);
}
if Data2(CrossDown(m1,m2)) or Crossup(R, OverBought) Then
Sell("S");
2
inputs : P1(5),P2(20),RSILength(10), OverSold(30),OverBought(70);
input : 첫진입금액(1000000),A(10),B(20);
var : m1(0,Data2),m2(0,Data2), R(0,Data1),LP(0,Data1);
var : TT(0,Data1),T1(0,Data1),entry(0,Data1),mm(0,data1),vol(0,Data1);
m1 = Data2(ma(C,P1));
m2 = Data2(ma(C,P2));
R = data1(RSI(RSILength));
if MarketPosition == 1 Then
LP = LatestEntryPrice(0);
Else
LP = LatestEntryPrice(1);
If Data2(m1 > m2) and Crossup(R, OverSold) Then
{
if TotalTrades == 0 Then
mm = 첫진입금액;
Else
{
if LP > C Then
mm = mm*(1+B/100);
Else
mm = mm*(1+A/100);
}
Buy("B",OnClose,Def,Floor(Floor(mm/C)/10)*10);
}
if Data2(CrossDown(m1,m2)) or Crossup(R, OverBought) Then
Sell("S");
2025-05-22
178
글번호 191081
시스템
답변완료
문의 드립니다.
안녕하세요 항상 감사드립니다.
아래의 서식에서 추가적인 서식을 부탁드립니다.
*추가사항
1.연결선물 기준 5분봉에서 이평선 50일선 아래 위치시 매도만 진입, 50일선 위에 위치시 매수 만 진입
(50일선은 최적화를 할 수 있게 input으로 넣어주시기 바랍니다.)
# KOSPI 선물 5분봉
input: tt(150000),당일진입횟수(3);
var: chkP(10), reChkP(20), stopChk(25);
var: HH(0), LL(0), BS(0), SS(0);
var: dayChk(0);
var : TotalCount(0),PreDay(0),DayEntry(0);
TotalCount = TotalTrades;
if Bdate != Bdate[1] Then
PreDay = TotalCount[1];
DayEntry = (TotalCount-PreDay)+IFF(MarketPosition != 0,1,0);
if BarIndex == 0 then ClearDebug();
if dayindex == chkP then
{
HH = Highest(Max(C,O), chkP+1);
LL = Lowest(Min(C,O), chkP+1);
#if date == 20240612 then messageLog("--HH %.2f, LL: %.2f", HH, LL);
}
#if High >= HH and MarketPosition == 0 and ExitDate(1) < Date and time > 93000 then messageLog("HH %.2f, High: %.2f", HH, High);
if DayIndex >= chkP
# and Time < 95000
and sDate == NextBarSdate
and EntryDate(0) < Date
and EntryDate(1) < Date
and DayEntry < 당일진입횟수
Then {
Buy("B1", AtStop, HH);
Sell("S1", AtStop, LL);
}
//if dayChk == 0 and High >= HH and MarketPosition == 0 and ExitDate(1) < Date and time > 93000 then {
// messageLog("HH %.2f, High: %.2f", HH, High);
// dayChk = 1;
//}
if ExitDate(1) == Date
and Time < 150000
// and LatestEntryName(1) != "B2"
// and LatestEntryName(1) != "S2"
// and LatestEntryName(0) != "B2"
// and LatestEntryName(0) != "S2"
Then
{
if DayIndex < reChkP Then
{
HH = Highest(Max(C,O), DayIndex+1);
LL = Lowest(Min(C,O), DayIndex+1);
}
Else
{
HH = Highest(Max(C,O), reChkP);
LL = Lowest(Min(C,O), reChkP);
}
if DayEntry < 당일진입횟수 Then
{
Buy("B2", AtStop, HH);
Sell("S2", AtStop, LL);
}
}
if (MarketPosition == 1) Then {
if DayIndex < stopChk Then {
BS = Lowest(Min(C,O), DayIndex+1);
}
Else {
BS = Lowest(Min(C,O), stopChk);
}
ExitLong("EL", AtStop, BS);
}
if (MarketPosition == -1) Then {
if DayIndex < stopChk Then {
SS = Highest(Max(C,O), DayIndex+1);
}
Else {
SS = Highest(Max(C,O), stopChk);
}
#messageLog(" SS %.2f", SS);
ExitShort("ES", AtStop, SS);
}
var : month(0),nday(0),week(0),X(False);
month = int(date/100)-int(date/10000)*100;
nday = date - int(date/100)*100;
Week = DayOfWeek(date);
#만기일
if (month%3 == 0 and nday >= 8 and nday <= 14 and week == 4) then
{
X = true;
SetStopEndofday(151500);
}
Else#만기일아닐때
{
X = False;
SetStopEndofday(152000);
}
2025-05-22
223
글번호 191074
지표