예스스탁
예스스탁 답변
2019-12-23 10:29:34
안녕하세요
예스스탁입니다.
수식에 일정손익이 발생하면 Xcond가 true가 됩니다.
진입식에 Xcond == false라는 조건이 들어가야 합니다.
input : n(30);
Input : 당일누적수익틱수(600),당일누적손실틱수(200);
input : starttime(101500),endtime(180000);
vars : Tcond(false),N1(0),dayPl(0),당일누적수익(0),당일누적손실(0),Xcond(false);
Var : Pivot(0),R1(0),R2(0),S1(0),S2(0),T(0);
if (sdate != sdate[1] and stime >= endtime) or
(sdate == sdate[1] and stime >= endtime and stime[1] < endtime) then
{
Tcond = false;
if MarketPosition == 1 Then
ExitLong("매수청산");
if MarketPosition == -1 Then
ExitShort("매도청산");
}
if (sdate != sdate[1] and stime >= starttime) or
(sdate == sdate[1] and stime >= starttime and stime[1] < starttime) then
{
Xcond = false;
N1 = NetProfit;
Tcond = true;
}
당일누적수익 = PriceScale*당일누적수익틱수;
당일누적손실 = PriceScale*당일누적손실틱수;
daypl = NetProfit-N1;
if TotalTrades > TotalTrades[1] and
(daypl >= 당일누적수익 or daypl <= -당일누적손실) then
Xcond = true;
if MarketPosition == 1 then{
ExitLong("매수수익",atlimit,EntryPrice+((당일누적수익-daypl)/CurrentContracts));
ExitLong("매수손실",AtStop,EntryPrice-((당일누적손실+daypl)/CurrentContracts));
}
if MarketPosition == -1 then{
ExitShort("매도수익",atlimit,EntryPrice-((당일누적수익-daypl)/CurrentContracts));
ExitShort("매도손실",AtStop,EntryPrice+((당일누적손실+daypl)/CurrentContracts));
}
Pivot = (DayHigh(1)+DayLow(1)+DayClose(1))/3;
R1 = 2*Pivot-DayLow(1);
R2 = Pivot+DayHigh(1)-DayLow(1);
S1 = 2*Pivot-DayHigh(1);
S2 = Pivot-DayHigh(1)+DayLow(1);
if crossup(C,R2+PriceScale*n) Then
T = 5;
if crossup(C,R1+PriceScale*n) Then
T = 4;
if crossup(C,Pivot+PriceScale*n) Then
T = 3;
if crossup(C,S1+PriceScale*n) Then
T = 2;
if crossup(C,S2+PriceScale*n) Then
T = 1;
if CrossDown(C,R2-PriceScale*n) Then
T = -5;
if CrossDown(C,R1-PriceScale*n) Then
T = -4;
if CrossDown(C,Pivot-PriceScale*n) Then
T = -3;
if CrossDown(C,S1-PriceScale*n) Then
T = -2;
if CrossDown(C,S2-PriceScale*n) Then
T = -1;
if Tcond == true and Xcond == false then
{
if T != T[1] and
T >= 0 and T[1] <= 0 Then
Buy("매수");
if T != T[1] and
T <= 0 and T[1] >= 0 Then
Sell("매도");
}
즐거운 하루되세요
> 승부사1 님이 쓴 글입니다.
> 제목 : 피봇수식 수정부탁드립니다.
> 아래의 수식을 적용하였습니다.
하루 손실제한 틱수를 넘었는데도 시그널이 계속 발생을 합니다.
하루 손실제한 틱수에 도달하면 더 이상 시그널 발생이 안되도록 수정 부탁드립니다.
- 아 래 -
input : n(30);
Input : 당일누적수익틱수(600),당일누적손실틱수(200);
input : starttime(101500),endtime(180000);
vars : Tcond(false),N1(0),dayPl(0),당일누적수익(0),당일누적손실(0),Xcond(false);
Var : Pivot(0),R1(0),R2(0),S1(0),S2(0),T(0);
if (sdate != sdate[1] and stime >= endtime) or
(sdate == sdate[1] and stime >= endtime and stime[1] < endtime) then
{
Tcond = false;
if MarketPosition == 1 Then
ExitLong("매수청산");
if MarketPosition == -1 Then
ExitShort("매도청산");
}
if (sdate != sdate[1] and stime >= starttime) or
(sdate == sdate[1] and stime >= starttime and stime[1] < starttime) then
{
Xcond = false;
N1 = NetProfit;
Tcond = true;
}
당일누적수익 = PriceScale*당일누적수익틱수;
당일누적손실 = PriceScale*당일누적손실틱수;
daypl = NetProfit-N1;
if TotalTrades > TotalTrades[1] and
(daypl >= 당일누적수익 or daypl <= -당일누적손실) then
Xcond = true;
if MarketPosition == 1 then{
ExitLong("매수수익",atlimit,EntryPrice+((당일누적수익-daypl)/CurrentContracts));
ExitLong("매수손실",AtStop,EntryPrice-((당일누적손실+daypl)/CurrentContracts));
}
if MarketPosition == -1 then{
ExitShort("매도수익",atlimit,EntryPrice-((당일누적수익-daypl)/CurrentContracts));
ExitShort("매도손실",AtStop,EntryPrice+((당일누적손실+daypl)/CurrentContracts));
}
Pivot = (DayHigh(1)+DayLow(1)+DayClose(1))/3;
R1 = 2*Pivot-DayLow(1);
R2 = Pivot+DayHigh(1)-DayLow(1);
S1 = 2*Pivot-DayHigh(1);
S2 = Pivot-DayHigh(1)+DayLow(1);
if crossup(C,R2+PriceScale*n) Then
T = 5;
if crossup(C,R1+PriceScale*n) Then
T = 4;
if crossup(C,Pivot+PriceScale*n) Then
T = 3;
if crossup(C,S1+PriceScale*n) Then
T = 2;
if crossup(C,S2+PriceScale*n) Then
T = 1;
if CrossDown(C,R2-PriceScale*n) Then
T = -5;
if CrossDown(C,R1-PriceScale*n) Then
T = -4;
if CrossDown(C,Pivot-PriceScale*n) Then
T = -3;
if CrossDown(C,S1-PriceScale*n) Then
T = -2;
if CrossDown(C,S2-PriceScale*n) Then
T = -1;
if Tcond == true then
{
if T != T[1] and
T >= 0 and T[1] <= 0 Then
Buy("매수");
if T != T[1] and
T <= 0 and T[1] >= 0 Then
Sell("매도");
}