매수 손절과 매도 손절을 다른가격으로 설정하고 싶은데
제대로 작성 수식 작성한건지 알고 싶어서 문의 드립니다.
매수 진입 및 청산은 진입조건 만족시 다음봉 기준 진입이구여
매수 손절은 진입 가격 기준 SL_Long틱 이하로 빠질 경우 즉시 청산
매도 손절은 진입 가격 기준 SL_Short틱 이하로 빠질 경우 즉시 청산을 구현하고 싶습니다.
주석처리한 부분을 살려서 쓸 수 있는지 아니면 밑에 if else문으로 작성 하는게 맞는지
아니면 다른 방법이 있는지 꼭 알려주세요.
Input : SL_Long(50), SL_Short(70);
TickPoint = PriceScale;
# 매수 진입
If MarketPosition == 0 and CrossUP(value1, value2) and Condition1 == True and condition3 == True Then
Buy("매수");
# 매수 청산 및 손절
if MarketPosition == 1 Then
{
if CrossUp(value,Exit_Long) Then
ExitLong("매수청산");
// if IsEntryName("매수") == True and c <= EntryPrice - PriceScale*SL_Long Then
// SetStopLoss(PriceScale * SL_Long,PointStop);
}
# 매도 진입
if MarketPosition == 0 and CrossDown(value3, value4)and Condition2 == True and condition4 == True Then
Sell("매도");
# 매도 청산 및 손절
if MarketPosition == -1 Then
{
if CrossDown(value,Exit_Short) Then
ExitShort("매도청산");
// if IsEntryName("매도") == True and c >= EntryPrice + PriceScale*SL_Short Then
// SetStopLoss(PriceScale * SL_Short,PointStop);
}
# 손절
if MarketPosition == 1 and IsEntryName("매수") == True and c <= EntryPrice - (PriceScale * SL_Long) Then {
SetStopLoss(PriceScale * SL_Long,PointStop);
}
Else if MarketPosition == -1 and IsEntryName("매도") == True and c >= EntryPrice + (PriceScale * SL_Short) Then {
SetStopLoss(PriceScale * SL_Short,PointStop);
}
Else {
SetStopLoss(0);
}
답변 1
예스스탁
예스스탁 답변
2021-03-16 10:14:38
안녕하세요
예스스탁입니다.
1
SetStopLoss가 손절매함수입니다.
진입후 지정한 값의 손실이 발생하면 즉시 청산이므로
c <= EntryPrice - (PriceScale * SL_Long)
c >= EntryPrice + (PriceScale * SL_Short)
와 같은 로직은 불필요합니다.
해당 내용이 있으면 if문은 봉완성시에 체크하게 되어 해당 조건이
진입이후 종가가 위 조건을 만족하면 그때 강제청산 함수가 셋팅되게 됩니다.
즉 위 내용이 if문에 있으면 종가로 지정한 손익이 도달되면 강제청산이 셋팅되고
다음봉에서 계속 지정한 손실을 유지되면 청산이 발생하게 됩니다.
2
각 진입이 하나이므로 이름지정도 의미가 없습니다.
동일방향 진입이 다수이고 이름별로 청산을 지정하는 경우가 아니라면
이름도 지정할 필요가 없습니다.
3
아래와 같이 작성하시면 됩니다.
# 손절
if MarketPosition == 1 Then
{
SetStopLoss(PriceScale * SL_Long,PointStop);
}
Else if MarketPosition == -1 Then
{
SetStopLoss(PriceScale * SL_Short,PointStop);
}
Else
{
SetStopLoss(0);
}
즐거운 하루되세요
> 7out 님이 쓴 글입니다.
> 제목 : 시스템 수식 관련 문의 드립니다.
> 매수 손절과 매도 손절을 다른가격으로 설정하고 싶은데
제대로 작성 수식 작성한건지 알고 싶어서 문의 드립니다.
매수 진입 및 청산은 진입조건 만족시 다음봉 기준 진입이구여
매수 손절은 진입 가격 기준 SL_Long틱 이하로 빠질 경우 즉시 청산
매도 손절은 진입 가격 기준 SL_Short틱 이하로 빠질 경우 즉시 청산을 구현하고 싶습니다.
주석처리한 부분을 살려서 쓸 수 있는지 아니면 밑에 if else문으로 작성 하는게 맞는지
아니면 다른 방법이 있는지 꼭 알려주세요.
Input : SL_Long(50), SL_Short(70);
TickPoint = PriceScale;
# 매수 진입
If MarketPosition == 0 and CrossUP(value1, value2) and Condition1 == True and condition3 == True Then
Buy("매수");
# 매수 청산 및 손절
if MarketPosition == 1 Then
{
if CrossUp(value,Exit_Long) Then
ExitLong("매수청산");
// if IsEntryName("매수") == True and c <= EntryPrice - PriceScale*SL_Long Then
// SetStopLoss(PriceScale * SL_Long,PointStop);
}
# 매도 진입
if MarketPosition == 0 and CrossDown(value3, value4)and Condition2 == True and condition4 == True Then
Sell("매도");
# 매도 청산 및 손절
if MarketPosition == -1 Then
{
if CrossDown(value,Exit_Short) Then
ExitShort("매도청산");
// if IsEntryName("매도") == True and c >= EntryPrice + PriceScale*SL_Short Then
// SetStopLoss(PriceScale * SL_Short,PointStop);
}
# 손절
if MarketPosition == 1 and IsEntryName("매수") == True and c <= EntryPrice - (PriceScale * SL_Long) Then {
SetStopLoss(PriceScale * SL_Long,PointStop);
}
Else if MarketPosition == -1 and IsEntryName("매도") == True and c >= EntryPrice + (PriceScale * SL_Short) Then {
SetStopLoss(PriceScale * SL_Short,PointStop);
}
Else {
SetStopLoss(0);
}