답변완료
문의 드립니다
input : StartTime(144000),EndTime(40000);
input : 익절틱수(0),손절틱수(0);
var : Tcond(False),entry(0);
Variables: Mom(0);
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
{
Tcond = true;
IF Endtime <= starttime Then
{
SetStopEndofday(0);
}
}
if (sdate != sdate[1] and stime >= EndTime) or
(sdate == sdate[1] and stime >= EndTime and stime[1] < EndTime) Then
{
Tcond = False;
}
if Tcond == true Then
{
if L ==lowest(L,2) and highest(H,2) >= lowest(L,2)+PriceScale*1 Then
{
Buy("b",AtStop,(highest(H,2)+lowest(L,2))/2);
}
if MarketPosition == 1 and BarsSinceEntry == 2 Then
ExitShort();
}
if H == highest(H,2) and lowest(L,2) <= highest(H,2)+PriceScale*1 Then
{
Sell("s",AtStop,(lowest(L,2)+highest(H,2))/2);
}
if MarketPosition == -1 and BarsSinceEntry == 2 Then
ExitLong();
if L ==lowest(L,1) and highest(H,3) >= lowest(L,2)+PriceScale*10 Then
{
Buy("b1",AtStop,(highest(H,3)+lowest(L,1))/2);
}
if MarketPosition == 1 and BarsSinceEntry == 2 Then
ExitShort();
if H == highest(H,1) and lowest(L,3) <= highest(H,2)+PriceScale*10 Then
{
Sell("s1",AtStop,(lowest(L,3)+highest(H,1))/2);
}
if MarketPosition == -1 and BarsSinceEntry == 2 Then
ExitLong();
if L ==lowest(L,1) and highest(H,3) >= lowest(L,2)+PriceScale*10 Then
{
Buy("b2",AtStop,(highest(H,3)+lowest(L,1))/2);
}
if MarketPosition == 1 and BarsSinceEntry == 2 Then
ExitShort();
if H == highest(H,1) and lowest(L,3) <= highest(H,2)+PriceScale*10 Then
{
Sell("s2",AtStop,(lowest(L,3)+highest(H,1))/2);
}
if MarketPosition == -1 and BarsSinceEntry == 2 Then
ExitLong();
if L ==lowest(L,2) and highest(H,2) >= lowest(L,2)+PriceScale*1 Then
{
Buy("b3",AtStop,(highest(H,2)+lowest(L,2))/2);
}
if MarketPosition == 1 and BarsSinceEntry == 2 Then
ExitShort();
if H == highest(H,2) and lowest(L,2) <= highest(H,2)+PriceScale*1 Then
{
Sell("s3",AtStop,(lowest(L,2)+highest(H,2))/2);
}
if MarketPosition == -1 and BarsSinceEntry == 2 Then
ExitLong();
if L ==lowest(L,1) and highest(H,3) >= lowest(L,2)+PriceScale*10 Then
{
Buy("b4",AtStop,(highest(H,3)+lowest(L,1))/2);
}
if MarketPosition == 1 and BarsSinceEntry == 2 Then
ExitShort();
if H == highest(H,1) and lowest(L,3) <= highest(H,2)+PriceScale*10 Then
{
Sell("s4",AtStop,(lowest(L,3)+highest(H,1))/2);
}
if MarketPosition == -1 and BarsSinceEntry == 2 Then
ExitLong();
if L ==lowest(L,1) and highest(H,3) >= lowest(L,2)+PriceScale*10 Then
{
Buy("b5",AtStop,(highest(H,3)+lowest(L,1))/2);
}
if MarketPosition == 1 and BarsSinceEntry == 2 Then
ExitShort();
if H == highest(H,1) and lowest(L,3) <= highest(H,2)+PriceScale*10 Then
{
Sell("s5",AtStop,(lowest(L,3)+highest(H,1))/2);
}
if MarketPosition == -1 and BarsSinceEntry == 2 Then
ExitLong();
SetStopProfittarget(PriceScale*익절틱수,PointStop);
SetStopLoss(PriceScale*손절틱수,PointStop);
------------------------------
EndTime이 04시00분인데
60분봉은 EndTime이 맞고
400분봉 설정에선 EndTime은 14시 40분에 EndTime이 됩니다.
다른방법이 있는지 문의 드리고
매매시간을 AM 4시부터 AM 7시까지의 변경된 수식어를 부탁드립니다.
2024-02-22
890
글번호 176868
시스템
답변완료
수식요청_(data1과 data2)에서 가격 차이가 클때 손익차이 기준을 0으로
페어트레이딩의 두 개의 데이터 세트(data1과 data2)에서 가격 차이가 클때_예를 들어 gold와 silver선물, 손익차이를계산하고,이를 " 기준 손익"으로 0으로 설정한 이후의 차이가 양수인지 음수인지에 따라 손익을 계산하고자합니다.
예를 들면,
var : Data1(0), Data2(0);
var : data1(PointValue, data2(PointValue);
var: 기준손익(0)
기준손익= data1*data1(PointValue)-data2*data2(PointValue) //이것을 "0" 로 놓고
이것을 기준으로 이전 차이보다 크면 양수t손익로 간주하여상승. 반대는 음수손익이므로 하락으로 plotting.
즉
if 손익차이 > 기준손익(0) , 그 차이만큼 plot(+손익),
if 손익차이< 기준손익(0), 그 차이 만큼 plot(- 손익)
else : 손익없음
요약:
#선언후에 두 종목의 가격 차이를 계산,
# 가격 차이를 이용하여 기준 손익을 계산하고,
#이를 0으로 설정, 기준 손익을 이용하여 각 시점에서의 손익을 계산,
#그래프를 이용하여 손익을 시각적으로 표현.
지표수식부탁드립니다
2024-02-21
943
글번호 176865
지표
답변완료
피보나치 폭 위치
input : Per2(38.2),Per3(50.0),Per4(61.8);
var : HH(0),LL(0),D1(0),T1(0);
var : TL1(0),TL2(0),TL3(0),TL4(0),TL5(0),TL6(0),TL7(0),tx(0);
Plot1 (c);
if sDate >= CurrentDate and sTime >= 103000 Then
{
Condition1 = True;
if hh == 0 or (hh > 0 and h > hh) Then
hh = h;
if ll == 0 or (ll > 0 and L < ll) Then
ll = l;
var2 = 10^(LOG10(HH)-(LOG10(HH)-LOG10(LL))*(Per2/100));
var3 = 10^(LOG10(HH)-(LOG10(HH)-LOG10(LL))*(Per3/100));
var4 = 10^(LOG10(HH)-(LOG10(HH)-LOG10(LL))*(Per4/100));
if Condition1[1] == False Then
{
D1 = sDate;
T1 = sTime;
TL1 = TL_New_Self(D1,T1,HH,NextBarSdate,NextBarStime,HH);
TL3 = TL_New_Self(D1,T1,var2,NextBarSdate,NextBarStime,var2);
TL4 = TL_New_Self(D1,T1,var3,NextBarSdate,NextBarStime,var3);
TL5 = TL_New_Self(D1,T1,var4,NextBarSdate,NextBarStime,var4);
TL7 = TL_New_Self(D1,T1,LL,NextBarSdate,NextBarStime,LL);
TL_SetSize(TL4,2);
TL_SetColor(TL1,Magenta);
TL_SetColor(TL3,Orange);
TL_SetColor(TL4,Gold);
TL_SetColor(TL5,Orange);
TL_SetColor(TL7,Green);
TX = Text_New_Self(sDate,sTime,HH,NumToStr(HH-LL,2));
Text_SetStyle(tx,2,1);
Text_SetSize(tx,25);
Text_SetColor(tx,Magenta);
Text_SetBold(tx,1);
}
Else
{
TL_SetBegin(TL1,D1,T1,HH);
TL_SetBegin(TL3,D1,T1,Var2);
TL_SetBegin(TL4,D1,T1,Var3);
TL_SetBegin(TL5,D1,T1,Var4);
TL_SetBegin(TL7,D1,T1,LL);
TL_SetEnd(TL1,Sdate,Stime,HH);
TL_SetEnd(TL3,Sdate,Stime,Var2);
TL_SetEnd(TL4,Sdate,Stime,Var3);
TL_SetEnd(TL5,Sdate,Stime,Var4);
TL_SetEnd(TL7,Sdate,Stime,LL);
Text_SetString(TX,NumToStr(HH-LL,2));
Text_SetLocation(TX,D1,T1,HH);
}
}
text 표기 위치를, 왼쪽 상단에서 고점을 따라가며 최고점 상단으로 수정. 감사합니다.
2024-02-21
989
글번호 176862
지표