커뮤니티
문의드립니다.
2026-09-03 09:12:03
117
글번호 233476
피라미딩을 하는 수식이고
각각 진입명별로 진입가격을 지정하고
만약에 b9는 1개만 진입하고 b91는 시간 차로 여러개(2개 ~ 5개) 진입할 경 우 각각 진입수량와 평균단가로 진입 청산하고자 합니다.
즉 진입수량와 진입단가 평균값으로 청산하고자 합니다.
수식을 변경하여 주기기 바랍니다.
감사합니다.
var : b9p(0),b91p(0);
if MarketPosition == 0 Then
{
b9p = 0;
b91p = 0;
}
if MarketPosition == 1 Then
{
if LatestEntryName(0) == "b9" Then
b9p = LatestEntryPrice(0);
if LatestEntryName(0) == "b91" Then
b91p = LatestEntryPrice(0);
if b9p > 0 Then
{
ExitLong("bp9",atlimit,b9p+PriceScale*익절틱수b9,"b9");
ExitLong("bl9",AtStop,b9p-PriceScale*손절틱수b9,"b9");
}
if b91p > 0 Then
{
ExitLong("bp91",atlimit,b91p+PriceScale*익절틱수b91,"b91");
ExitLong("bl91",AtStop,b91p-PriceScale*손절틱수b91,"b91");
}
}
답변 1
예스스탁 예스스탁 답변
2026-09-04 10:27:38
안녕하세요
예스스탁입니다.
var : b9p(0),b91p(0);
var : sum91Price(0),sum91vol(0);
if MarketPosition == 0 Then
{
b9p = 0;
b91p = 0;
sum91Price = 0;
sum91vol = 0;
}
if MarketPosition == 1 Then
{
if CurrentContracts > CurrentContracts[1] Then
{
if LatestEntryName(0) == "b9" Then
b9p = LatestEntryPrice(0);
if LatestEntryName(0) == "b91" Then
{
sum91Price = sum91Price + LatestEntryPrice(0);
sum91vol = sum91vol + (CurrentContracts-CurrentContracts[1]);
b91p = sum91Price/sum91vol;
}
}
if b9p > 0 Then
{
ExitLong("bp9",atlimit,b9p+PriceScale*익절틱수b9,"b9");
ExitLong("bl9",AtStop,b9p-PriceScale*손절틱수b9,"b9");
}
if b91p > 0 Then
{
ExitLong("bp91",atlimit,b91p+PriceScale*익절틱수b91,"b91");
ExitLong("bl91",AtStop,b91p-PriceScale*손절틱수b91,"b91");
}
}
즐거운 하루되세요
다음글