답변완료
문의 드립니다
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
830
글번호 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
906
글번호 176865
지표