예스스탁
예스스탁 답변
2025-09-29 14:31:39.0
안녕하세요
예스스탁입니다.
1
input : threshold_percent(0.5);
input : additional_long__percent(0.5);
input : additional_short_rise_percent(0.5);
var : threshold(0),addLong(0),addShortRise(0);
var : longCondition(False),shortCondition(False);
var : longAddCondition(False),shortAddCondition(False);
var : hasLongPosition(False),hasShortPosition(False);
threshold = threshold_percent / 100.0;
addLong = additional_long__percent / 100.0;
addShortRise = additional_short_rise_percent / 100.0;
longCondition = avgValue >= low and (CrossUp(low, var1) or CrossUp(low, var2) or CrossUp(low, var5)) and low <= avgValue * (1 - threshold);
shortCondition = avgValue < low and (CrossUp(high, var1) or CrossDown(high, var2) or CrossDown(high, var5)) and low > avgValue * (1 + threshold);
// 추가 롱 조건: 롱 포지션 중 진입가 대비 추가 하락 시 및 롱 신호
longAddCondition = (MarketPosition > 0) and (close <= entryPrice * (1 - addLong)) and longCondition;
// 추가 숏 조건: 숏 포지션 중 진입가 대비 추가 상승 시 및 숏 신호
shortAddCondition = (MarketPosition < 0) and (close >= entryPrice * (1 + addShortRise)) and shortCondition;
hasLongPosition = MarketPosition > 0;
hasShortPosition = MarketPosition < 0;
// 포지션 없을 때만 기존 롱/숏 Condition으로 진입
if (hasLongPosition == False and longCondition) Then
Buy("Long");
if (hasShortPosition == False and shortCondition) Then
Sell("Short");
// 롱 포지션 보유 시 추가 롱 진입 조건만 실행
if (MarketPosition > 0 and MaxEntries == 1) Then
{
if (longAddCondition) then
{
Buy("물Long");
}
}
if (MarketPosition < 0 and MaxEntries == 1) Then
{
if (shortAddCondition) Then
{
Sell("불Short");
}
}
2
input : threshold_percent(0.5);
input : additional_long__percent(0.5);
input : additional_short_rise_percent(0.5);
var : threshold(0),addLong(0),addShortRise(0);
var : longCondition(False),shortCondition(False);
var : longAddCondition(False),shortAddCondition(False);
var : hasLongPosition(False),hasShortPosition(False);
var : pst(0),S(0),tx(0);
threshold = threshold_percent / 100.0;
addLong = additional_long__percent / 100.0;
addShortRise = additional_short_rise_percent / 100.0;
longCondition = avgValue >= low and (CrossUp(low, var1) or CrossUp(low, var2) or CrossUp(low, var5)) and low <= avgValue * (1 - threshold);
shortCondition = avgValue < low and (CrossUp(high, var1) or CrossDown(high, var2) or CrossDown(high, var5)) and low > avgValue * (1 + threshold);
// 추가 롱 조건: 롱 포지션 중 진입가 대비 추가 하락 시 및 롱 신호
longAddCondition = (pst > 0) and (close <= S * (1 - addLong)) and longCondition;
// 추가 숏 조건: 숏 포지션 중 진입가 대비 추가 상승 시 및 숏 신호
shortAddCondition = (pst < 0) and (close >= S * (1 + addShortRise)) and shortCondition;
hasLongPosition = pst > 0;
hasShortPosition = pst < 0;
if pst <= 0 and longCondition == true Then
{
pst = 1;
S = C;
tx = Text_New(sdate,sTime,L,"▲");
Text_SetColor(tx,Red);
Text_SetSize(tx,10);
}
if pst >= 0 and longCondition == true Then
{
pst = -1;
S = C;
tx = Text_New(sdate,sTime,L,"▲");
Text_SetColor(tx,Blue);
Text_SetSize(tx,10);
}
if pst == 1 and longAddCondition == true Then
{
pst = 2;
S = C;
tx = Text_New(sdate,sTime,L,"●");
Text_SetColor(tx,Magenta);
Text_SetSize(tx,20);
}
if pst == -1 and shortAddCondition == true Then
{
pst = -2;
S = C;
tx = Text_New(sdate,sTime,L,"●");
Text_SetColor(tx,Cyan);
Text_SetSize(tx,20);
}
즐거운 하루되세요
> 느와르 님이 쓴 글입니다.
> 제목 : 시스템 및 지표식 문의 드립니다.
> 안녕하세요
항상 빠른 답변 감사 드립니다.
아래 식은 트레이딩뷰에서 파인스크립트로 작성된 식입니다.
예스식으로 시스템식 및 지표식 요청 드립니다.
변경을 요청 드립니다.
ps, 제가 비슷하게 예스식으로 작성하여 적용했을때
피라미딩 전부 허용,진입횟수 2회 설정,
첫 진입 조건 후에 첫 진입 조건에 추가 진입을 했습니다.
제가 원하는건 2번째 진입은 추가 롱,숏 조건에 만족했을때 진입식을 구현 하려고 했지만
어려워 문의 드립니다.
1번.
시스템식 요청
// 전략 진입 조건
// 사용자 입력: 이격 및 추가 롱/숏 진입 가격 차이
threshold_percent = input.float(0.5, title="이격 (%)", step=0.01)
additional_long__percent = input.float(0.5, title="추가 롱 진입 하락 (%)", step=0.01)
additional_short_rise_percent = input.float(0.5, title="추가 숏 진입 상승 (%)", step=0.01)
// 입력된 퍼센트를 소수로 변환
threshold = threshold_percent / 100.0
addLong = additional_long__percent / 100.0
addShortRise = additional_short_rise_percent / 100.0
// 기존 롱/숏 진입 조건
longCondition = avgValue >= low and (ta.crossover(low, var1) or ta.crossover(low, var2) or ta.crossover(low, var5)) and low <= avgValue * (1 - threshold)
shortCondition = avgValue < low and (ta.crossover(high, var1) or ta.crossunder(high, var2) or ta.crossunder(high, var5)) and low > avgValue * (1 + threshold)
// 현재 포지션 진입가
entryPrice = strategy.position_avg_price
// 추가 롱 조건: 롱 포지션 중 진입가 대비 추가 하락 시 및 롱 신호
longAddCondition = (strategy.position_size > 0) and (close <= entryPrice * (1 - addLong)) and longCondition
// 추가 숏 조건: 숏 포지션 중 진입가 대비 추가 상승 시 및 숏 신호
shortAddCondition = (strategy.position_size < 0) and (close >= entryPrice * (1 + addShortRise)) and shortCondition
hasLongPosition = strategy.position_size > 0
hasShortPosition = strategy.position_size < 0
// 포지션 없을 때만 기존 롱/숏 Condition으로 진입
if (not hasLongPosition and longCondition)
strategy.entry('Long', strategy.long)
if (not hasShortPosition and shortCondition)
strategy.entry('Short', strategy.short)
// 롱 포지션 보유 시 추가 롱 진입 조건만 실행
if (strategy.position_size > 0)
if (longAddCondition)
strategy.entry('물Long', strategy.long)
// 숏 포지션 보유 시 추가 숏 진입 조건만 실행
if (strategy.position_size < 0)
if (shortAddCondition)
strategy.entry('불Short', strategy.short)
// longCondition 발생 시 아래에 초록색 삼각형 표시
plotshape(longCondition, title="Long Signal", style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small, text="Long")
// shortCondition 발생 시 위에 빨간색 삼각형 표시
plotshape(shortCondition, title="Short Signal", style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small, text="Short")
// longAddCondition 발생 시 아래에 파란색 원 표시
plotshape(longAddCondition, title="Additional Long", style=shape.circle, location=location.belowbar, color=color.blue, size=size.tiny, text="AddLong")
// shortAddCondition 발생 시 위에 보라색 원 표시
plotshape(shortAddCondition, title="Additional Short", style=shape.circle, location=location.abovebar, color=color.purple, size=size.tiny, text="AddShort")
2번
지표식 요청
파인스크립트는 전략식에 plotshape 식으로 조건에 부합하는 지표를 표시하게 검증 하듯이
지표식을 요청 드립니다.
특히 첫 진입 신호와 이격후 신호는 다른 모양으로 칼라, 1.5배 크기 표기를 희망합니다.
그럼 좋은 하루 되세요