예스스탁
예스스탁 답변
2025-09-08 14:12:41
안녕하세요
예스스탁입니다.
국내 프로그램의 스팟은 ECMA version으로 3~4사이입니다.
변수는 모두 var로 처리하셔야 하고 Arrow Function, Map은 지원되지 않습니다.
즐거운 하루되세요
> 치치야 님이 쓴 글입니다.
> 제목 : 수식어 검증 오류창
> 안녕하세요. 항상 감사합니다.
국내선물 수식어가 오류가 발생하여 수정본 수식어 부탁드립니다.
1.예스트레이드 #6132 편집기
2.예스랭귀지 #6109 편집기-시스템 클릭후 해서 입력해도 수식어가 오류가 발생합니다.
// --- INPUT SERIES ---
// close[], upperBand[], lowerBand[], chTop1[], chBot1[], dayIndex[], entryStage[]
function generateSignals(data) {
const n = data.close.length;
const orders = [];
let position = 0; // +: long qty, -: short qty
let longQty = 0, shortQty = 0;
const longEnterCount = new Map();
const shortEnterCount = new Map();
const hitTopCount = new Map();
const hitBotCount = new Map();
const getCnt = (m, d) => m.get(d) || 0;
const inc = (m, d) => m.set(d, (m.get(d) || 0) + 1);
const EPS = 1e-8;
const eq = (a, b) => Math.abs(a - b) <= EPS;
for (let i = 0; i < n; i++) {
const C = data.close[i];
const U = data.upperBand[i];
const L = data.lowerBand[i];
const CT1 = data.chTop1[i];
const CB1 = data.chBot1[i];
const D = data.dayIndex[i];
const STG = (data.entryStage?.[i] ?? 0);
const cntLong = getCnt(longEnterCount, D);
const cntShort = getCnt(shortEnterCount, D);
const cntTop = getCnt(hitTopCount, D);
const cntBot = getCnt(hitBotCount, D);
// ---- ENTRY ----
// If CountIF(MarketPosition > 0, DayIndex) < 1 && DayIndex>2 && DayIndex<80 && STG==0 && C>U => Buy 2
if (cntLong < 1 && D > 2 && D < 80 && STG === 0 && C > U) {
const qty = 2;
orders.push({ i, side: "BUY", qty, price: C, tag: "ENTRY_LONG" });
position += qty; longQty += qty;
inc(longEnterCount, D);
}
// If CountIF(MarketPosition < 0, DayIndex) < 1 && ... && C Sell 2
if (cntShort < 1 && D > 2 && D < 80 && STG === 0 && C < L) {
const qty = 2;
orders.push({ i, side: "SELL", qty, price: C, tag: "ENTRY_SHORT" });
position -= qty; shortQty += qty;
inc(shortEnterCount, D);
}
// ---- TOUCH COUNTS (for partial exits) ----
if (eq(C, CT1)) inc(hitTopCount, D);
if (C <= CB1 + EPS) inc(hitBotCount, D);
// ---- PARTIAL EXITS ----
// if CountIF(C = chTop1, DayIndex) < 2 && C = chTop1 => ExitLong 1 of 2
if (position > 0 && cntTop < 2 && eq(C, CT1) && longQty > 0) {
const q = Math.min(1, longQty);
orders.push({ i, side: "SELL", qty: q, price: C, tag: "TP1_LONG" });
position -= q; longQty -= q;
}
// if CountIF(C = chBot1, DayIndex) < 2 && C <= chBot1 => ExitShort 1 of 2
if (position < 0 && cntBot < 2 && C <= CB1 + EPS && shortQty > 0) {
const q = Math.min(1, shortQty);
orders.push({ i, side: "BUY", qty: q, price: C, tag: "TP1_SHORT" });
position += q; shortQty -= q;
}
}
return orders;