답변완료
같은 봉에서 매도 신호와 매수신호가 동시에 나갈때 매도우선으로 수정요망 합니다.
제목 에서와 같이 아래의 수식을 사용하여 하락시 분할매수와 상승시 분할매수를 동시에 하여 수식 조건에 맞으면 상승시 매수분 따로 전량 매도하고, 하락시 매수분 전량매도 하도록 되어 있는데, 가끔씩 매도 분봉이나 일봉에서 매수와 매도 신호가 동시에 나가는 경우가 있어서 이것을 동시 신호일때 매도 우선으로 수정하고 싶습니다. 고견을 부탁 드립니다.
input : 금액(10000000);
var : Bcond(False),Scond(False);
var1 = Highest(c,15);
Var2 = Lowest(c,30);
var3 = Highest(c,20);
Var4 = Lowest(c,20);
var5 = Highest(c,20);
Var6 = Lowest(c,20);
var7 = Highest(c,20);
Var8 = Lowest(c,20);
var9 = Highest(c,20);
Var10 = Lowest(c,20);
Bcond = False;
if Bcond == False and CrossUp(c,var1[1]) and Condition1 == False Then
{
Bcond = true;
Buy("a1",OnClose,DEf,((금액*(10/100))/C));
}
if Bcond == False and CrossUp(c,var3[1]) and Condition3 == False Then
{
Bcond = true;
Buy("a3",OnClose,DEf,((금액*(10/100))/C));
}
if Bcond == False and CrossUp(c,var5[1]) and Condition5 == False Then
{
Bcond = true;
Buy("a5",OnClose,DEf,((금액*(10/100))/C));
}
if Bcond == False and CrossUp(c,var7[1]) and Condition7 == False Then
{
Bcond = true;
Buy("a7",OnClose,DEf,((금액*(10/100))/C));
}
if Bcond == False and CrossUp(c,var9[1]) and Condition9 == False Then
{
Bcond = true;
Buy("a9",OnClose,DEf,((금액*(10/100))/C));
}
if MarketPosition == 1 Then
{
if CurrentContracts > CurrentContracts[1] Then
{
if LatestEntryName(0) == "a1" Then
Condition1 = true;
if LatestEntryName(0) == "a3" Then
Condition3 = true;
if LatestEntryName(0) == "a5" Then
Condition5 = true;
if LatestEntryName(0) == "a7" Then
Condition7 = true;
if LatestEntryName(0) == "a9" Then
Condition9 = true;
}
Scond = False;
if Scond == False and CrossDown(c,var2[1]) and Condition1 == true Then
{
Condition1 = False;
ExitLong("ax2",OnClose,DEf,"a1");
}
if Scond == False and CrossDown(c,var2[1]) and Condition3 == true Then
{
Condition3 = False;
ExitLong("ax4",OnClose,DEf,"a3");
}
if Scond == False and CrossDown(c,var2[1]) and Condition5 == true Then
{
Condition5 = False;
ExitLong("ax6",OnClose,DEf,"a5");
}
if Scond == False and CrossDown(c,var2[1]) and Condition7 == true Then
{
Condition7 = False;
ExitLong("ax8",OnClose,DEf,"a7");
}
if Scond == False and CrossDown(c,var2[1]) and Condition9 == true Then
{
Condition9 = False;
ExitLong("ax10",OnClose,DEf,"a9");
}
}
Else
{
Condition1 = False;
Condition3 = False;
Condition5 = False;
Condition7 = False;
Condition9 = False;
}
Var11 = Lowest(c,20);
var12 = Highest(c,200);
Var13 = Lowest(c,40);
var14 = Highest(c,40);
Var15 = Lowest(c,55);
var16 = Highest(c,55);
Var17 = Lowest(c,60);
var18 = Highest(c,60);
Var19 = Lowest(c,80);
var20 = Highest(c,80);
Bcond = False;
if Bcond == False and CrossDown(c,var11[1]) and Condition11 == False Then
{
Bcond = true;
Buy("b1",OnClose,DEf,((금액*(10/100))/C));
}
if Bcond == False and CrossDown(c,var13[1]) and Condition13 == False Then
{
Bcond = true;
Buy("b3",OnClose,DEf,((금액*(10/100))/C));
}
if Bcond == False and CrossDown(c,var15[1]) and Condition15 == False Then
{
Bcond = true;
Buy("b5",OnClose,DEf,((금액*(10/100))/C));
}
if Bcond == False and CrossDown(c,var17[1]) and Condition17 == False Then
{
Bcond = true;
Buy("b7",OnClose,DEf,((금액*(10/100))/C));
}
if Bcond == False and CrossDown(c,var19[1]) and Condition19 == False Then
{
Bcond = true;
Buy("b9",OnClose,DEf,((금액*(10/100))/C));
}
if MarketPosition == 1 Then
{
if CurrentContracts > CurrentContracts[1] Then
{
if LatestEntryName(0) == "b1" Then
Condition11 = true;
if LatestEntryName(0) == "b3" Then
Condition13 = true;
if LatestEntryName(0) == "b5" Then
Condition15 = true;
if LatestEntryName(0) == "b7" Then
Condition17 = true;
if LatestEntryName(0) == "b9" Then
Condition19 = true;
}
Scond = False;
if Scond == False and CrossUp(c,var12[1]) and Condition11 == true Then
{
Condition11 = False;
ExitLong("bx2",OnClose,DEf,"b1");
}
if Scond == False and CrossUp(c,var12[1]) and Condition13 == true Then
{
Condition13 = False;
ExitLong("bx4",OnClose,DEf,"b3");
}
if Scond == False and CrossUp(c,var12[1]) and Condition15 == true Then
{
Condition15 = False;
ExitLong("bx6",OnClose,DEf,"b5");
}
if Scond == False and CrossUp(c,var12[1]) and Condition17 == true Then
{
Condition17 = False;
ExitLong("bx8",OnClose,DEf,"b7");
}
if Scond == False and CrossUp(c,var12[1]) and Condition19 == true Then
{
Condition19 = False;
ExitLong("bx10",OnClose,DEf,"b9");
}
}
Else
{
Condition11 = False;
Condition13 = False;
Condition15 = False;
Condition17 = False;
Condition19 = False;
}
2022-03-31
463
글번호 157610
시스템
답변완료
아래식에서
당일총수익이나 총손실에도달하면 강제청산후에 매수진입이나 매도진입이되지않도록 수정부탁합니다
당일 수이이나 손실이 나도 계속진입이됩니다
input : StartTime(90000),EndTime(110000);
Input : 당일수익틱수(25),당일손실틱수(50);
Input : 전환선기간(9), 기준선기간(26);
Var : 기준선(0), 전환선(0);
var : Tcond(false);
Var : N1(0),dayPl(0),당일수익(0),당일손실(0),Xcond(false);
전환선 = (Highest(High, 전환선기간) + Lowest(Low, 전환선기간)) / 2;
기준선 = (Highest(High, 기준선기간) + Lowest(Low, 기준선기간)) / 2;
당일수익 = PriceScale*당일수익틱수;
당일손실 = PriceScale*당일손실틱수;
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;
Xcond = false;
N1 = NetProfit;
}
daypl = NetProfit-N1;
if TotalTrades > TotalTrades[1] then
{
if daypl >= 당일수익 or daypl <= -당일손실 Then
Xcond = true;
if (IsExitName("dbp",1) == true or IsExitName("dbl",1) == true or
IsExitName("dsp",1) == true or IsExitName("dsl",1) == true) then
Xcond = true;
}
if Tcond == true Then
{
if MarketPosition <= 0 and crossup(전환선,기준선) Then
Buy();
if MarketPosition >= 0 and CrossDown(전환선,기준선) Then
Sell();
}
if MarketPosition == 1 then
{
ExitLong("dbp",atlimit,EntryPrice+((당일수익-daypl)/CurrentContracts));
ExitLong("dbl",AtStop,EntryPrice-((당일손실+daypl)/CurrentContracts));
}
if MarketPosition == -1 then
{
ExitShort("dsp",atlimit,EntryPrice-((당일수익-daypl)/CurrentContracts));
ExitShort("dsl",AtStop,EntryPrice+((당일손실+daypl)/CurrentContracts));
}
SetStopEndofday(Endtime);
2022-03-30
1279
글번호 157604
시스템