커뮤니티
수식 수정 부탁드립니다.
2018-06-27 18:18:24
168
글번호 120102
안녕하세요? 수식 수정하고 싶어서 다시 글 남깁니다.
아래식중 맨 아래쪽에
if H >= LatestEntryPrice(0)*1.05 Then
Condition4 = true;
if Condition4 == true Then
ExitLong("bx2",AtStop,LatestEntryPrice(0)*1.02);
이부분을 보면 익절이 같은조건으로 마지막 진입에서 5% 올랐다가 2%까지 내려오면 익절이 나가게 되어있는데..
1차 2차 3차 매수후 올랐다가 내리는 폭을 조절해서 익절을 하고 싶습니다.
예를 들어
1차매수 시점 진입후 5% 올랐다가 2% 까지 내려오면 익절
2차매수 시점 진입후 7% 올랐다가 4% 까지 내려오면 익절
3차매수 시점 진입후 6% 올랐다가 3% 까지 내려오면 익절
이런식으로 추가하고 싶습니다.
감사합니다.
input : 투자금액(1000000),투자비율1(45),투자비율2(30),투자비율3(25);
input : P1(9),P2(14);
var : count(0),sumV1(0),sumV2(0);
var : mav1(0),mav2(0);
var : m1(0),m2(0),m3(0),dd(0),entry(false);
sumV1 = 0;
sumV2 = 0;
for count = 0 to P2{
if count < P1 Then
sumV1 = sumV1+DayClose(count);
if count < P2 Then
sumV2 = sumV2+DayClose(count);
}
maV1 = sumV1 / P1;
maV2 = sumV2 / P2;
m1 = 투자금액*(투자비율1/100);
m2 = 투자금액*(투자비율2/100);
m3 = 투자금액*(투자비율3/100);
if bdate != bdate[1] Then
{
dd = dd+1;
entry = true;
}
if TotalTrades > TotalTrades[1] and MarketPosition == 0 Then
entry = false;
if MarketPosition == 0 and Condition1 == false and L < mav1 and entry == true Then
{
buy("b1",AtLimit,mav1,Floor(m1/mav1));
}
if MarketPosition == 1 Then
{
if CurrentContracts > CurrentContracts[1] Then
{
Condition1 = false;
Condition2 = false;
Condition4 = false;
if MaxEntries == 1 Then
var1 = dd;
}
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "bl1" Then
Condition3 = true;
if MaxEntries == 1 and L > mav2 Then
buy("b2",AtLimit,mav2,Floor(m2/mav2));
if MaxEntries == 2 Then
{
buy("b3",AtLimit,LatestEntryPrice(0)*0.95,Floor(m3/LatestEntryPrice(0)*0.95));
}
if MaxEntries == 3 then
{
if Condition3 == false then
ExitLong("bl1",AtStop,LatestEntryPrice(0)*0.95,"",Floor(MaxContracts*0.5),1);
ExitLong("bl2",AtStop,LatestEntryPrice(0)*0.90);
}
if Condition1 == false then
{
ExitLong("bp1",atlimit,AvgEntryPrice*1.05,"",Floor(MaxContracts*0.5),1);
}
if Condition2 == false then
{
ExitLong("bp2",atlimit,AvgEntryPrice*1.10,"",Floor(MaxContracts*0.3),1);
}
ExitLong("bp3",atlimit,AvgEntryPrice*1.15);
if NextBarSdate > sdate and dd >= var1+4 Then
exitlong("bx1",AtMarket);
if H >= LatestEntryPrice(0)*1.05 Then
Condition4 = true;
if Condition4 == true Then
ExitLong("bx2",AtStop,LatestEntryPrice(0)*1.02);
}
Else
{
Condition3 = false;
}
답변 1
예스스탁 예스스탁 답변
2018-06-28 09:18:46
안녕하세요
예스스탁입니다.
input : 투자금액(1000000),투자비율1(45),투자비율2(30),투자비율3(25);
input : P1(9),P2(14);
var : count(0),sumV1(0),sumV2(0);
var : mav1(0),mav2(0);
var : m1(0),m2(0),m3(0),dd(0),entry(false);
sumV1 = 0;
sumV2 = 0;
for count = 0 to P2{
if count < P1 Then
sumV1 = sumV1+DayClose(count);
if count < P2 Then
sumV2 = sumV2+DayClose(count);
}
maV1 = sumV1 / P1;
maV2 = sumV2 / P2;
m1 = 투자금액*(투자비율1/100);
m2 = 투자금액*(투자비율2/100);
m3 = 투자금액*(투자비율3/100);
if bdate != bdate[1] Then
{
dd = dd+1;
entry = true;
}
if TotalTrades > TotalTrades[1] and MarketPosition == 0 Then
entry = false;
if MarketPosition == 0 and Condition1 == false and L < mav1 and entry == true Then
{
buy("b1",AtLimit,mav1,Floor(m1/mav1));
}
if MarketPosition == 1 Then
{
if CurrentContracts > CurrentContracts[1] Then
{
Condition1 = false;
Condition2 = false;
Condition4 = false;
if MaxEntries == 1 Then
var1 = dd;
}
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "bl1" Then
Condition3 = true;
if MaxEntries == 1 and L > mav2 Then
buy("b2",AtLimit,mav2,Floor(m2/mav2));
if MaxEntries == 2 Then
{
buy("b3",AtLimit,LatestEntryPrice(0)*0.95,Floor(m3/LatestEntryPrice(0)*0.95));
}
if MaxEntries == 3 then
{
if Condition3 == false then
ExitLong("bl1",AtStop,LatestEntryPrice(0)*0.95,"",Floor(MaxContracts*0.5),1);
ExitLong("bl2",AtStop,LatestEntryPrice(0)*0.90);
}
if Condition1 == false then
{
ExitLong("bp1",atlimit,AvgEntryPrice*1.05,"",Floor(MaxContracts*0.5),1);
}
if Condition2 == false then
{
ExitLong("bp2",atlimit,AvgEntryPrice*1.10,"",Floor(MaxContracts*0.3),1);
}
ExitLong("bp3",atlimit,AvgEntryPrice*1.15);
if NextBarSdate > sdate and dd >= var1+4 Then
exitlong("bx1",AtMarket);
if MaxEntries == 1 then
{
if H >= LatestEntryPrice(0)*1.05 Then
Condition4 = true;
if Condition4 == true Then
ExitLong("bx21",AtStop,LatestEntryPrice(0)*1.02);
}
if MaxEntries == 2 then
{
if H >= LatestEntryPrice(0)*1.07 Then
Condition4 = true;
if Condition4 == true Then
ExitLong("bx22",AtStop,LatestEntryPrice(0)*1.04);
}
if MaxEntries == 3 then
{
if H >= LatestEntryPrice(0)*1.06 Then
Condition4 = true;
if Condition4 == true Then
ExitLong("bx23",AtStop,LatestEntryPrice(0)*1.03);
}
}
Else
{
Condition3 = false;
}
즐거운 하루되세요
> 부자청년28 님이 쓴 글입니다.
> 제목 : 수식 수정 부탁드립니다.
> 안녕하세요? 수식 수정하고 싶어서 다시 글 남깁니다.
아래식중 맨 아래쪽에
if H >= LatestEntryPrice(0)*1.05 Then
Condition4 = true;
if Condition4 == true Then
ExitLong("bx2",AtStop,LatestEntryPrice(0)*1.02);
이부분을 보면 익절이 같은조건으로 마지막 진입에서 5% 올랐다가 2%까지 내려오면 익절이 나가게 되어있는데..
1차 2차 3차 매수후 올랐다가 내리는 폭을 조절해서 익절을 하고 싶습니다.
예를 들어
1차매수 시점 진입후 5% 올랐다가 2% 까지 내려오면 익절
2차매수 시점 진입후 7% 올랐다가 4% 까지 내려오면 익절
3차매수 시점 진입후 6% 올랐다가 3% 까지 내려오면 익절
이런식으로 추가하고 싶습니다.
감사합니다.
input : 투자금액(1000000),투자비율1(45),투자비율2(30),투자비율3(25);
input : P1(9),P2(14);
var : count(0),sumV1(0),sumV2(0);
var : mav1(0),mav2(0);
var : m1(0),m2(0),m3(0),dd(0),entry(false);
sumV1 = 0;
sumV2 = 0;
for count = 0 to P2{
if count < P1 Then
sumV1 = sumV1+DayClose(count);
if count < P2 Then
sumV2 = sumV2+DayClose(count);
}
maV1 = sumV1 / P1;
maV2 = sumV2 / P2;
m1 = 투자금액*(투자비율1/100);
m2 = 투자금액*(투자비율2/100);
m3 = 투자금액*(투자비율3/100);
if bdate != bdate[1] Then
{
dd = dd+1;
entry = true;
}
if TotalTrades > TotalTrades[1] and MarketPosition == 0 Then
entry = false;
if MarketPosition == 0 and Condition1 == false and L < mav1 and entry == true Then
{
buy("b1",AtLimit,mav1,Floor(m1/mav1));
}
if MarketPosition == 1 Then
{
if CurrentContracts > CurrentContracts[1] Then
{
Condition1 = false;
Condition2 = false;
Condition4 = false;
if MaxEntries == 1 Then
var1 = dd;
}
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "bl1" Then
Condition3 = true;
if MaxEntries == 1 and L > mav2 Then
buy("b2",AtLimit,mav2,Floor(m2/mav2));
if MaxEntries == 2 Then
{
buy("b3",AtLimit,LatestEntryPrice(0)*0.95,Floor(m3/LatestEntryPrice(0)*0.95));
}
if MaxEntries == 3 then
{
if Condition3 == false then
ExitLong("bl1",AtStop,LatestEntryPrice(0)*0.95,"",Floor(MaxContracts*0.5),1);
ExitLong("bl2",AtStop,LatestEntryPrice(0)*0.90);
}
if Condition1 == false then
{
ExitLong("bp1",atlimit,AvgEntryPrice*1.05,"",Floor(MaxContracts*0.5),1);
}
if Condition2 == false then
{
ExitLong("bp2",atlimit,AvgEntryPrice*1.10,"",Floor(MaxContracts*0.3),1);
}
ExitLong("bp3",atlimit,AvgEntryPrice*1.15);
if NextBarSdate > sdate and dd >= var1+4 Then
exitlong("bx1",AtMarket);
if H >= LatestEntryPrice(0)*1.05 Then
Condition4 = true;
if Condition4 == true Then
ExitLong("bx2",AtStop,LatestEntryPrice(0)*1.02);
}
Else
{
Condition3 = false;
}
다음글
이전글