답변완료
문의드립니다.
안녕하세요, 수식 작성에 도움을 주셔서 감사드립니다.
분할 매도 수식 문의드립니다.
일봉시스템이고 가격조건만족시 즉시 신호가 발생하게 해서 거래중입니다.
1. 시스템 성능을 개량하고자 분할매도를 백테스팅하려고 하는데,
가격이 B1으로 진입했을 때 매도가격에서 40%, 매도가격*1.05%에서 30%, 매도가격*1.1에서 나머지를 매도하려고 하고,
매도가격*1.1까지 가지 못하고 하락하는 경우 매도가격*1.05에서 전량 익절하려고 합니다.
(당일청산)
단 매도가격이 상한가 근처여서 매도가격*1.05가 상한가를 넘어서는 경우는 익일에 수식을 적용하고 싶습니다.
수식 검토 부탁드립니다.
즐거운 주말 보내세요.
if LatestEntryName(0) == "b1" Then
{
ExitLong("bx1",AtLimit,매도가격,"",MaxContracts*0.4,2);
ExitLong("bx1-1%",AtLimit,매도가격*(1.05),"",MaxContracts*0.3,2);
if H > 매도가격 * 1.05 and H<매도가격 * 1.1 then
{
ExitLong("bx1-1-1",AtStop,매도가격*1.05);
}
ExitLong("bx1-2",AtLimit,매도가격*(1.1));
}
2021-04-30
1351
글번호 148554
시스템
답변완료
수식어 부탁드립니다
input : StartTime(213000),EndTime(055000),진입횟수(5),익절틱수(120),손절틱수(25);
var : Tcond(false),entry(0);
if StartTime < EndTime Then
{
SetStopEndofday(EndTime);
}
Else
{
if sDate != sDate[1] Then
SetStopEndofday(EndTime);
}
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
{
if StartTime > EndTime Then
SetStopEndofday(0);
Tcond = true;
entry = 0;
}
if (MarketPosition != 0 and MarketPosition != MarketPosition[1]) or
(MarketPosition == MarketPosition[1] and TotalTrades > TotalTrades[1]) Then
entry = entry+1;
if Tcond == true Then
{
if MarketPosition == 0 and C > O and entry < 진입횟수 Then
{
Buy("b");
}
if MarketPosition == 0 and C < O and entry < 진입횟수 Then
{
Sell("s");
}
}
SetStopProfittarget(PriceScale*익절틱수,PointStop);
SetStopLoss(PriceScale*손절틱수,PointStop);
--------------------------------------
input : StartTime(180000),EndTime(055000),xtime(055500);
Input : Period(20);
Input : 당일수익틱수(600);
Var : N1(0),dayPl(0),당일수익(0),Xcond(false);
Var : value(0),Tcond(false);
if sDate != sDate[1] then
SetStopEndofday(xtime);
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;
SetStopEndofday(0);
Xcond = false;
N1 = NetProfit;
}
당일수익 = PriceScale*당일수익틱수;
daypl = NetProfit-N1;
if TotalTrades > TotalTrades[1] then
{
if daypl >= 당일수익 Then
Xcond = true;
if (IsExitName("dbp",1) == true or IsExitName("dsp",1) == true ) then
Xcond = true;
}
value = VR(Period);
var1 = ma(C,5);
var2 = ma(C,200);
If CrossUP(value, 100) and Xcond == False Then
{
Buy("b");
}
If CrossDown(value, 1500) and Xcond == False Then
{
ExitLong();
}
if marketposition == 1 then
{
if isentryname("b") == true and crossdown(var1,var2) then
sell("bs");
if crossdown(var2,var3) Then
Exitlong("sbx",onclose,def,"sb");
ExitLong("dbp",atlimit,EntryPrice+((당일수익-daypl)/CurrentContracts));
if EntryTime >= 213000 or EntryTime < Endtime Then
ExitLong("bpx",AtLimit,EntryPrice+PriceScale*20);
}
if marketposition == -1 then
{
if isentryname("s") == true and crossup(var1,var2) then
buy("sb");
if crossup(var2,var3) Then
ExitShort("bsx",onclose,def,"bs");
ExitShort("dsp",atlimit,EntryPrice-((당일수익-daypl)/CurrentContracts));
if EntryTime >= 213000 or EntryTime < Endtime Then
ExitShort("spx",AtLimit,EntryPrice-PriceScale*20);
}
-------------------------
input : StartTime(70000),EndTime(55000),Xtime(55500);
var : Tcond(false),B1(0),B2(0),X1(0),X2(0),entry(0);
if sdate != sDate[1] Then
SetStopEndofday(Xtime);
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;
SetStopEndofday(0);
entry = 0;
}
if (MarketPosition != 0 and MarketPosition != MarketPosition[1]) or
(MarketPosition == MarketPosition[1] and TotalTrades > TotalTrades[1]) Then
entry = entry+1;
B1 = DayLow(1)+(DayHigh(1)-DayLow(1))*0.382;
B2 = DayLow(1)+(DayHigh(1)-DayLow(1))*0.236;
X1 = DayLow(1)+(DayHigh(1)-DayLow(1))*0.800;
X2 = DayHigh(1);
if Tcond == true Then
{
if (MarketPosition == 0 or (MarketPosition == 1 and MaxEntries == 1)) Then
{
if entry < 5 and L > B1 Then
Buy("b1",AtLimit,B1);
if entry < 5 and L > B2 Then
Buy("b2",AtLimit,B2);
}
if MarketPosition == 1 Then
{
ExitLong("bx1",AtLimit,X1,"B1");
ExitLong("bx2",AtLimit,X2,"B2");
}
}
SetStopProfittarget(PriceScale*150,PointStop);
SetStopLoss(PriceScale*30,PointStop);
--------------------
매매시간 및 진입횟수 ,익절, 손절은 아래 내용으로 통일해주시고 다른 진입허용으로
상기 수식어 3개의 합체를 부탁드립니다.
StartTime(213000),EndTime(055000),진입횟수(10),익절틱수(120),손절틱수(25)
2021-04-30
1302
글번호 148552
시스템
답변완료
부탁드립니다
*,아래식에서 최근4일(당일포함)동안 고저진폭P값을 출력하려는데 당일(P)과,전일(P1)은
구했는데 2일전(P2),3일전(P3),4일전(P4)값을 추가로 출력 부탁드립니다.
Input : 위치(0),크기(0),위치2(0);
var : tx(0),text(""),text1(""),tx1(0),tx2(0);
if Bdate != Bdate[1] Then
{
tx1 = tx[1];
tx2 = tx1[1];
Text_Delete(tx2);
text = NumToStr(DayOpen(0)-DayOpen(1),2)+NewLine+
NumToStr(DayLow(0)-DayOpen(0),2)+NewLine+
NumToStr(DayHigh(0)-DayOpen(0),2);
tx = Text_New(sDate,sTime,H+PriceScale*10,text);
Text_SetStyle(tx,0,1);
}
Else
{
text = "O:"+NumToStr(DayOpen(0)-DayOpen(1),2)+NewLine+
"p:"+NumToStr((DayHigh(0)-DayLow(0))*1,2);
text1 = "p1:"+NumToStr((DayHigh(1)-DayLow(1))*1,2);
Text_SetString(tx,text);
#당일값위치
Text_SetLocation(tx,NextBarSdate,NextBarStime,H+PriceScale*10);
Text_SetString(tx1,text1);
#전일값위치
Text_SetLocation(tx1,NextBarSdate,NextBarStime,DayLow(1)+PriceScale*위치2);
Text_SetLocation(tx,sDate,sTime,H+PriceScale*위치);
Text_SetColor(tx,IFf(DayOpen(1) < DayOpen(0) ,RED,BLUE));
Text_SetSize(tx,크기);
}
#전일색
Text_SetColor(Tx1,BLACK);
2021-04-30
992
글번호 148548
지표