답변완료
수식 변경 요청드립니다.
안녕하세요.
아래 수식은 진입 시 3 계약이 동시에 진입하여 3차례에 걸쳐서 나누어 분할 익절되고 손절 시 15틱 일괄 청산 되도록 되어 있습니다. 이것을 역으로, 진입 시 3계약 동시 진입하여 N 틱수 이익 시 3계약 모두 일괄 청산되고, 손실 시 손절틱수1(10), 손절틱수2(15), 손절틱수3(20) 이 되도록 변경하여 주시면 감사 하겠습니다.
input : 거래시간 (1), 시작시간 (220000), 끝시간 (045000),익절틱수1(10),익절틱수2(15),익절틱수3(20),손절틱수 (15);
Input : 전환선기간 (5), 기준선기간1(26), 기준선기간2(1), 선행스팬2기간(52), short(12), long(26), sig(9),BBP(120), 당일누적손실틱수 (100);
Var : MACDv(0), MACDsig(0),macdosc(0), Condition3(false);
var : 전환선 (0), 기준선1(0), 기준선2(0), 후행스팬(0), 선행스팬1(0), 선행스팬2(0), Xcond(false),N1(0),daypl(0),당일누적손실 (0);
var1 = MACD(short, long);
var2 = ema(MACDv,sig);
var3 = ma(C,BBP);
전환선 = (Highest(High, 전환선기간 ) + Lowest(Low, 전환선기간 )) / 2;
기준선1 = (Highest(High, 기준선기간1 ) + Lowest(Low, 기준선기간1 )) / 2;
기준선2 = (Highest(High, 기준선기간2 ) + Lowest(Low, 기준선기간2 )) / 2;
선행스팬1 = (전환선 [25] + 기준선2 [25]) / 2 ;
선행스팬2 = (Highest(High, 선행스팬2기간 )[25] + Lowest(Low, 선행스팬2기간 )[25]) / 2;
if 거래시간 == 1 then
condition3 = (stime>=시작시간 or stime<=끝시간);
Else if 거래시간 == 2 then
condition3 = (stime>=시작시간 and stime<=끝시간);
Else
condition3 = true;
if 거래시간 == 1 or 거래시간 == 2 then
{
if (sdate != sdate[1] and stime >= 시작시간) or
(sdate == sdate[1] and stime >= 시작시간 and stime[1] < 시작시간) Then
{
Xcond = false;
N1 = NetProfit;
}
}
else
{
if Bdate != Bdate[1] Then
{
Xcond = false;
N1 = NetProfit;
}
}
당일누적손실 = PriceScale*당일누적손실틱수;
daypl = NetProfit-N1;
if TotalTrades > TotalTrades[1] and
(IsExitName("dbl",1) == true or IsExitName("dsl",1) == true) then
Xcond = true;
# 매수/매도청산
if MarketPosition == 0 and
TotalTrades == TotalTrades[3] and
Xcond == false and
Condition3 == true and var3 > var3[1] and var1 > var2 and 전환선 > 기준선1 and crossup(C,전환선 ) and C > O Then
{
Buy("b",OnClose,def,3);
ExitLong("bp1.",atlimit,C+PriceScale*익절틱수1,"",1,1);
ExitLong("bp2.",atlimit,C+PriceScale*익절틱수2,"",1,1);
ExitLong("bp3.",atlimit,C+PriceScale*익절틱수3);
}
# 매도/매수청산
if MarketPosition == 0 and TotalTrades == TotalTrades[3] and
Xcond == false and
Condition3 == true and var3 < var3[1] and var1 < var2 and 전환선 < 기준선1 and CrossDown(C,전환선 ) and C < O Then
{
Sell("s",OnClose,def,3);
ExitShort("sp1.",atlimit,C-PriceScale*익절틱수1,"",1,1);
ExitShort("sp2.",atlimit,C-PriceScale*익절틱수2,"",1,1);
ExitShort("sp3.",atlimit,C-PriceScale*익절틱수3);
}
if MarketPosition == 1 Then{
if highest(H,BarsSinceEntry) < EntryPrice+PriceScale*익절틱수1 then
ExitLong("bp1",atlimit,EntryPrice+PriceScale*익절틱수1,"",1,1);
if highest(H,BarsSinceEntry) < EntryPrice+PriceScale*익절틱수2 then
ExitLong("bp2",atlimit,EntryPrice+PriceScale*익절틱수2,"",1,1);
if highest(H,BarsSinceEntry) < EntryPrice+PriceScale*익절틱수3 then
ExitLong("bp3",atlimit,EntryPrice+PriceScale*익절틱수3);
}
if MarketPosition == -1 Then{
if lowest(L,BarsSinceEntry) > EntryPrice-PriceScale*익절틱수1 Then
ExitShort("sp1",atlimit,EntryPrice-PriceScale*익절틱수1,"",1,1);
if lowest(L,BarsSinceEntry) > EntryPrice-PriceScale*익절틱수2 Then
ExitShort("sp2",atlimit,EntryPrice-PriceScale*익절틱수2,"",1,1);
if lowest(L,BarsSinceEntry) > EntryPrice-PriceScale*익절틱수3 Then
ExitShort("sp3",atlimit,EntryPrice-PriceScale*익절틱수3);
}
SetStopLoss(PriceScale*손절틱수,PointStop);
if stime == 끝시간 or (stime > 끝시간 and stime[1] < 끝시간 ) Then{
if MarketPosition == 1 Then
ExitLong("bx");
if MarketPosition == -1 Then
ExitShort("sx");
}
if MarketPosition == 1 then
{
ExitLong("dbl",AtStop,EntryPrice-((당일누적손실+daypl)/CurrentContracts));
}
if MarketPosition == -1 then
{
ExitShort("dsl",AtStop,EntryPrice+((당일누적손실+daypl)/CurrentContracts));
}
2020-04-05
679
글번호 137560
시스템
답변완료
문의드립니다
안녕하세요
아래 수식에서 상한가 다음날에만 매수진입
1차 or 2차 or 3차까지 매수가 되어서 청산이 되면 더이상 진입되지않게 수식 변경 부탁드립니다
예를들면 상한가 다음날에 1차 매수후 청산이 되면 더이상 진입금지
input : 금액(10000000);
var : vol(0);
if MarketPosition == 0 and L > DayHigh*0.82 Then
{
vol = Floor((금액*0.3)/min(NextBarOpen,DayHigh*0.82));
buy("b1",atlimit,DayHigh*0.82,vol);
}
if MarketPosition == 1 then
{
if MaxEntries == 1 and L > DayHigh*0.78 Then
{
vol = Floor((금액*0.3)/min(NextBarOpen,DayHigh*0.78));
buy("b2",atlimit,DayHigh*0.78,vol);
}
if MaxEntries == 2 and L > DayHigh*0.75 Then
{
vol = Floor((금액*0.3)/min(NextBarOpen,DayHigh*0.75));
buy("b3",atlimit,DayHigh*0.75,vol);
}
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "bp1" Then
Condition1 = true;
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "bp2" Then
Condition2= true;
if Condition1 == false Then
ExitLong("bp1",atlimit,AvgEntryPrice*1.025,"",floor(MaxContracts*0.8),1);
if Condition2 == false Then
ExitLong("bp2",atlimit,AvgEntryPrice*1.035);
if MaxEntries == 3 then
ExitLong("bl",AtStop,AvgEntryPrice*0.92);
}
SetStopEndofday(151000);
2020-04-05
718
글번호 137558
시스템