예스스탁
예스스탁 답변
2021-10-07 14:54:03
안녕하세요
예스스탁입니다.
랭귀지의 if문이 봉완성시기준이라 진입신호가 발생하고
최소 한봉이 완성이 되어야 포지션을 인식하고 진입가함수를 사용할 수 있습니다.
진입신호에서 동시에 걸리는 청산을 추가해 드립니다.
input : StartTime(223000),EndTime(0);
input : Length(20), D1(2);
var : Tcond(false);
if (sdate != sdate[1] and stime >= EndTime) or
(sdate == sdate[1] and stime >= EndTime and stime[1] < EndTime) Then
Tcond = False;
if (sdate != sdate[1] and stime >= StartTime) or
(sdate == sdate[1] and stime >= StartTime and stime[1] < StartTime) Then
Tcond = true;
var1 = BollBandUp(Length,D1);
var2 = BollBandDown(Length,D1);
if Tcond == true Then
{
If CrossUP(H,var1) and c > o then
{
Buy("b",OnClose,DEF,2);
ExitLong("Bp1.",AtLimit,C+PriceScale*50,"",1,1);
ExitLong("Bp2.",AtLimit,C+PriceScale*100,"",1,1);
ExitLong("Bl.",AtStop,C-PriceScale*30,"",1,1);
}
If CrossDown(L,Var2) and C < O then
{
Sell("s",OnClose,DEF,2);
ExitShort("sp1.",AtLimit,C-PriceScale*50,"",1,1);
ExitShort("sp2.",AtLimit,C-PriceScale*100,"",1,1);
ExitShort("sl.",AtStop,C+PriceScale*30,"",1,1);
}
}
if MarketPosition == 1 Then
{
ExitLong("Bp1",AtLimit,EntryPrice+PriceScale*50,"",1,1);
ExitLong("Bp2",AtLimit,EntryPrice+PriceScale*100,"",1,1);
ExitLong("Bl",AtStop,EntryPrice-PriceScale*30,"",1,1);
if CurrentContracts < MaxContracts and Highest(H,BarsSinceEntry) > EntryPrice+PriceScale*50 Then
ExitLong("btr",AtStop,EntryPrice+PriceScale*10);
}
if MarketPosition == -1 Then
{
ExitShort("sp1",AtLimit,EntryPrice-PriceScale*50,"",1,1);
ExitShort("sp2",AtLimit,EntryPrice-PriceScale*100,"",1,1);
ExitShort("sl",AtStop,EntryPrice+PriceScale*30,"",1,1);
if CurrentContracts < MaxContracts and lowest(L,BarsSinceEntry) < EntryPrice-PriceScale*50 Then
ExitShort("str",AtStop,EntryPrice+PriceScale*10);
}
IF Endtime > starttime Then
SetStopEndofday(Endtime);
Else
{
if sDate != sDate[1] Then
SetStopEndofday(Endtime);
}
if (sdate != sdate[1] and stime >= StartTime) or
(sdate == sdate[1] and stime >= StartTime and stime[1] < StartTime) Then
{
IF Endtime <= starttime Then
{
SetStopEndofday(0);
}
}
즐거운 하루되세요
> 에리카 님이 쓴 글입니다.
> 제목 : 문의
> input : StartTime(223000),EndTime(0);
input : Length(20), D1(2);
var : Tcond(false);
if (sdate != sdate[1] and stime >= EndTime) or
(sdate == sdate[1] and stime >= EndTime and stime[1] < EndTime) Then
Tcond = False;
if (sdate != sdate[1] and stime >= StartTime) or
(sdate == sdate[1] and stime >= StartTime and stime[1] < StartTime) Then
Tcond = true;
var1 = BollBandUp(Length,D1);
var2 = BollBandDown(Length,D1);
if Tcond == true Then
{
If CrossUP(H,var1) and c > o then
Buy("b",OnClose,DEF,2);
If CrossDown(L,Var2) and C < O then
Sell("s",OnClose,DEF,2);
}
if MarketPosition == 1 Then
{
ExitLong("Bp1",AtLimit,EntryPrice+PriceScale*50,"",1,1);
ExitLong("Bp2",AtLimit,EntryPrice+PriceScale*100,"",1,1);
ExitLong("Bl",AtStop,EntryPrice-PriceScale*3,"",1,1);
if CurrentContracts < MaxContracts and Highest(H,BarsSinceEntry) > EntryPrice+PriceScale*50 Then
ExitLong("btr",AtStop,EntryPrice+PriceScale*10);
}
if MarketPosition == -1 Then
{
ExitShort("sp1",AtLimit,EntryPrice-PriceScale*50,"",1,1);
ExitShort("sp2",AtLimit,EntryPrice-PriceScale*100,"",1,1);
ExitShort("sl",AtStop,EntryPrice+PriceScale*3,"",1,1);
if CurrentContracts < MaxContracts and lowest(L,BarsSinceEntry) < EntryPrice-PriceScale*50 Then
ExitShort("str",AtStop,EntryPrice+PriceScale*10);
}
IF Endtime > starttime Then
SetStopEndofday(Endtime);
Else
{
if sDate != sDate[1] Then
SetStopEndofday(Endtime);
}
if (sdate != sdate[1] and stime >= StartTime) or
(sdate == sdate[1] and stime >= StartTime and stime[1] < StartTime) Then
{
IF Endtime <= starttime Then
{
SetStopEndofday(0);
}
}
1. 나스닥(22시 30분 ~ 24시) 거래시간 지정
2. 매도신호가 나오는 캔들의 종가에 매도. 음봉일 때만 매도(양봉일 때는 안함)
3. 매수신호가 나오는 캔들의 종가에 매수. 양봉일 때만 매수(음봉일 때는 안함)
4. 매수와 매도, 모두 2계약을 진입합니다.
매수와 매도, 모두 2계약을 진입합니다.
1계약은 익절 50틱 종료.
남은 1계약은 익절 100틱 종료.
만약 남은 1계약이 51틱 이상 상승했다가 100틱 익절 되지 못하고
방향이 바뀌었을 시 10틱 익절로 종료.
5. 2계약의 손절은 30틱.
이 내용으로 문의 드려서 위의 수식을 주셨습니다.
데모를 해보니 2계약이 진입되어 진행되는데, 한번은 목표실현가를 도달했는데도 청산이 안되다가 지정하지 않은 가격에 익절되었고 다음 한번은 2계약 모두 목표실현가를 넘었는데 청산되지 않고 있다가 1계약은 50틱 청산 되었고 남은 1계약은 약손절 되었습니다.
어떤 문제인지,, 수식에 착오가 없는지 답변 부탁드립니다.