답변완료
당일 첫봉에서 진입이 안됩니다, 그리고 계좌예수금에 따라 베팅사이즈를 조절
안녕하세요 ^^
1) 아래와 같은 수식을 사용할 경우 당일 첫봉에서 매수/매도 진입이 전혀 되지 않습니다. 어떻게 해야될까요?
2) 계좌 예수금에 따라 베팅사이즈를 조절하려면 아래와 같이 수식을 적으면 될까요? (모의투자)
input : n(3),risk(1.5%),rt(0.17),MUL(50000);
var : noise(0),sum(0),cnt(0),
RANGE(0),LTR(0),STR(0),
L1(0),L2(0),L3(0),S1(0), S2(0),S3(0),
NL1(0), NL2(0),NL3(0), NS1(0), NS2(0), NS3(0),
VL(0),Lunit(0),LUNIT1(0),LUNIT2(0),SUNIT(0), SUNIT1(0), SUNIT2(0),
Accoundnum(""),value(0);
accoundnum = GetAccount(0);
value = GetUnclearedDeposits(accoundnum);
VL = value / (dayclose(1) * MUL * rt);
LUNIT = INT((value * RISK) / (LTR * MUL));
SUNIT = INT((value * RISK) / (STR * MUL));
# ENTRY
L1 = DAYOPEN + LTR ;
L2 = L1 + (LTR * 0.5);
L3 = L1 + LTR;
S1 = DAYOPEN - STR;
S2 = S1 - (STR * 0.5);
S3 = S1 - STR;
NL1 = LatestExitPrice(1)+LTR;
NL2 = NL1 + LTR * 0.5;
NL3 = NL1 + LTR;
NS1 = LatestExitPrice(1)-STR;
NS2 = NS1 - STR * 0.5;
NS3 = NS1 - Str;
IF MarketPosition == 0 AND BDATE != EXITDATE(1) Then {
IF H <= L1 AND NEXTBARSDATE == SDATE Then BUY("L1",ATSTOP,L1,LUNIT1);
IF L >= S1 AND NextBarSdate == SDATE THEN SELL("S1",ATSTOP,S1,SUNIT1);
}
# 매수 피라미딩
IF MarketPosition == 1 AND STIME <153000 and IsEntryName("L1")==True THEN {
if highest(h,BarsSinceEntry) <= L2 Then
buy("L2",ATSTOP,L2,LUNIT2);
if highest(h,BarsSinceEntry) <= L1 + LTR Then
buy("L3",ATSTOP, L3,LUNIT2);
}
# 매수청산
IF MarketPosition == 1 then {
if NextBarSdate == SDATE Then
ExitLong("LS",AtStop,LatestEntryPrice - LTR);
IF NextBarSdate != SDATE Then
ExitLong("EL",ATMARKET);
}
# 매도 피라미딩
IF MarketPosition == -1 AND STIME < 153000 AND IsEntryName("S1") == True THEN {
IF Lowest(L,BarsSinceEntry) >= S2 Then
SELL("S2",AtStop,S2,SUNIT2);
IF Lowest(L,BarsSinceEntry) >= S1 - STR Then
SELL("S3",AtStop,S3,SUNIT2);
}
# 매도청산
IF MarketPosition == -1 then {
IF NextBarSdate == SDATE Then EXITSHORT("SS",AtStop,LatestEntryPrice + STR);
SetStopEndofday(1545);
}
ELSE SetStopEndofday(0); #해제
# 재진입
IF MarketPosition == 0 AND BDATE == EXITDATE(1) Then {
IF MarketPosition(1) == 1 AND H <= NL1 AND NextBarSdate == sDate AND IsExitName("LS",1) == TRUE THEN BUY("NL1",ATSTOP,NL1,LUNIT1);
IF MarketPosition(1) == -1 AND L >= NS1 AND NextBarSdate == SDATE THEN SELL("NS1",ATSTOP,NS1,SUNIT1);
}
IF BDATE == EXITDATE(1) AND MarketPosition == 1 AND IsEntryName("NL1") == TRUE THEN {
IF LatestEntryName == "NL1" AND Highest(H,BarsSinceEntry) <= NL2 THEN BUY("NL2",ATSTOP,NL2,LUNIT2);
IF LatestEntryName == "NL2" AND HIGHEST(H,BarsSinceEntry) <= NL3 THEN BUY("NL3",ATSTOP,NL3,LUNIT2);
}
IF BDATE == ExitDate(1) AND MarketPosition == -1 AND IsEntryName("NS1") == TRUE Then {
IF LatestEntryName == "NS1" AND Lowest(L,BarsSinceEntry) >= NS2 THEN SELL("NS2",ATSTOP,NS2,SUNIT2);
IF LatestEntryName == "NS2" AND Lowest(L,BarsSinceEntry) >= NS3 THEN SELL("NS3",ATSTOP,NS2,SUNIT2);
}
2020-06-07
1787
글번호 139595
시스템
답변완료
문의드립니다.
예스수식으로 부탁드립니다.
rsiSource = input(title="RSI Source", type=input.source, defval=close)
rsiLength = input(title="RSI Length", type=input.integer, defval=12)
rsiOverbought = input(title="RSI Overbought", type=input.integer, defval=70, minval=50, maxval=100)
rsiOvesold = input(title="RSI Oversold", type=input.integer, defval=30, minval=1, maxval=50)
// RSI value based on inbuilt RSI
rsiValue = rsi(rsiSource, rsiLength)
// Get the current state
isOverbought = rsiValue >= rsiOverbought
isOversold = rsiValue <= rsiOvesold
// State of the last extreme 0 for initialization, 1 = overbought, 2 = oversold
var laststate = 0
// Highest and Lowest prices since the last state change
var hh = low
var ll = high
// Labels
var label labelll = na
var label labelhh = na
// Swing lines
var line line_up = na
var line line_down = na
// We go from overbought straight to oversold NEW DRAWINGS CREATED HERE
if(laststate == 1 and isOversold)
ll := low
labelll := label.new(bar_index, low, style=label.style_label_up, color=color.green, size=size.tiny)
labelhh_low = label.get_x(labelhh)
labelhh_pos = label.get_y(labelhh)
line_down := line.new(bar_index, high, labelhh_low, labelhh_pos, width=2)
// We go from oversold straight to overbought NEW DRAWINGS CREATED HERE
if(laststate == 2 and isOverbought)
hh := high
labelhh := label.new(bar_index, high, style=label.style_label_down, color=color.red, size=size.tiny)
labelll_low = label.get_x(labelll)
labelll_pos = label.get_y(labelll)
line_up := line.new(bar_index, high, labelll_low, labelll_pos, width=2)
// If we are overbought
if(isOverbought)
if(high >= hh)
hh := high
label.set_x(labelhh, bar_index)
label.set_y(labelhh, high)
line.set_x1(line_up, bar_index)
line.set_y1(line_up, high)
laststate := 1
// If we are oversold
if(isOversold)
if(low <= ll)
ll := low
label.set_x(labelll, bar_index)
label.set_y(labelll, low)
line.set_x1(line_down, bar_index)
line.set_y1(line_down, low)
laststate := 2
// If last state was overbought and we are overbought
if(laststate == 1 and isOverbought)
if(hh <= high)
hh := high
label.set_x(labelhh, bar_index)
label.set_y(labelhh, high)
line.set_x1(line_up, bar_index)
line.set_y1(line_up, high)
//If we are oversold and the last state was oversold, move the drawings to the lowest price
if(laststate == 2 and isOversold)
if(low <= ll)
ll := low
label.set_x(labelll, bar_index)
label.set_y(labelll, low)
line.set_x1(line_down, bar_index)
line.set_y1(line_down, low)
// If last state was overbought
if(laststate == 1)
if(hh <= high)
hh := high
label.set_x(labelhh, bar_index)
label.set_y(labelhh, high)
line.set_x1(line_up, bar_index)
line.set_y1(line_up, high)
// If last stare was oversold
if(laststate == 2)
if(ll >= low)
ll := low
label.set_x(labelll, bar_index)
label.set_y(labelll, low)
line.set_x1(line_down, bar_index)
line.set_y1(line_down, low)
2020-06-06
2027
글번호 139590
지표
답변완료
부탁 드립니다.
도움주심에 항상 감사 드립니다.
1) 아래 수식1,2)를 타주기 일봉용으로 작성해주신 수식3)입니다.
이것을
질문1) 타주기(주봉용),
질문2) 타주기(월봉용),으로
스스로 작성된것이 정상작동이 되지 않는것으로 보입니다.
검토 부탁 드립니다.
특히 변수 P값을 변경하여도 변화가 없습니다.
미리 감사 드립니다.
수식1)
Input : P(20),sig(5);
var1=(highest(c,p)-L)/(highest(c,p))*100;
var2=ma(var1,sig);
수식2)
Input : P(20),sig(5);
var1=(lowest(c,p)-H)/(lowest(c,p))*100;
var2=ma(var1,sig);
수식3) 타주기(일봉용)_정상 작동됨
input : P(20),sig(5);
var : sum1(0),sum2(0),hc(0),lc(0),i1(0),i2(0);
if DayHigh(P+sig-1) > 0 and DayLow(P+sig-1) > 0 then
{
sum1 = 0;
sum2 = 0;
for i1 = 0 to sig-1
{
hc = 0;
lc = 0;
for i2 = i1+0 to i1+P-1
{
if hc == 0 or (hc > 0 and DayClose(i2) > hc) Then
hc = DayClose(i2);
if lc == 0 or (lc > 0 and DayClose(i2) < lc) Then
lc = DayClose(i2);
}
sum1 = sum1 + (hc-DayLow(i1))/hc*100;
sum2 = sum2 + (lc-dayhigh(i1))/lc*100;
if i1 == 0 Then
{
var1 = (hc-daylow(i1))/hc*100;
value1 = (lc-DayHigh(i1))/lc*100;
}
}
var2 = sum1/sig;
value2 = sum2/sig;
plot1(var1);
plot2(var2);
plot3(value1);
plot4(value2);
}
질문1) 타주기(주봉용)_검토 필요
input : P(20),sig(5);
var : sum1(0),sum2(0),hc(0),lc(0),i1(0),i2(0);
if weekHigh(P+sig-1) > 0 and weekLow(P+sig-1) > 0 then
{
sum1 = 0;
sum2 = 0;
for i1 = 0 to sig-1
{
hc = 0;
lc = 0;
for i2 = i1+0 to i1+P-1
{
if hc == 0 or (hc > 0 and weekClose(i2) > hc) Then
hc = weekClose(i2);
if lc == 0 or (lc > 0 and weekClose(i2) < lc) Then
lc = weekClose(i2);
}
sum1 = sum1 + (hc-weekLow(i1))/hc*100;
sum2 = sum2 + (lc-weekhigh(i1))/lc*100;
if i1 == 0 Then
{
var1 = (hc-weeklow(i1))/hc*100;
value1 = (lc-weekHigh(i1))/lc*100;
}
}
var2 = sum1/sig;
value2 = sum2/sig;
plot1(var1);
plot2(var2);
plot3(value1);
plot4(value2);
}
질문2) 타주기(월봉용)_검토 필요
input : P(20),sig(5);
var : sum1(0),sum2(0),hc(0),lc(0),i1(0),i2(0);
if MONTHHigh(P+sig-1) > 0 and MONTHLow(P+sig-1) > 0 then
{
sum1 = 0;
sum2 = 0;
for i1 = 0 to sig-1
{
hc = 0;
lc = 0;
for i2 = i1+0 to i1+P-1
{
if hc == 0 or (hc > 0 and MONTHClose(i2) > hc) Then
hc = MONTHClose(i2);
if lc == 0 or (lc > 0 and MONTHClose(i2) < lc) Then
lc = MONTHClose(i2);
}
sum1 = sum1 + (hc-MONTHLow(i1))/hc*100;
sum2 = sum2 + (lc-MONTHhigh(i1))/lc*100;
if i1 == 0 Then
{
var1 = (hc-MONTHlow(i1))/hc*100;
value1 = (lc-MONTHHigh(i1))/lc*100;
}
}
var2 = sum1/sig;
value2 = sum2/sig;
plot1(var1);
plot2(var2);
plot3(value1);
plot4(value2);
}
2020-06-08
2088
글번호 139589
지표