답변완료
수식어 검증 오류창
안녕하세요. 항상 감사합니다.
국내선물 수식어가 오류가 발생하여 수정본 수식어 부탁드립니다.
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<L => 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;
답변완료
부탁드립니다
수고하십니다
예스로 수식부탁드립니다
//@version=6
indicator("MA Suite | Lyro RS", overlay= true)
// Library
import LyroRS/LMAs/1 as DynamicMAs
// LyroRS v1.0
// Groups (For Inputs)
ma_g = "𝗠𝗢𝗩𝗜𝗡𝗚 𝗔𝗩𝗘𝗥𝗔𝗚𝗘"
signal_g = '𝗦𝗜𝗚𝗡𝗔𝗟𝗦'
colors_g = '𝗖𝗢𝗟𝗢𝗥𝗦'
// Inputs
// -- MA Inputs
source = input.source(close, "Source", group= ma_g, tooltip= "S E ECT where the data originates (open, high, low, close, etc..).")
ma_type = input.string("EMA", "S E ECT Moving Average", options=["SMA", "EMA", "WMA", "VWMA", "DEMA", "TEMA", "RMA", "HMA", "LSMA", "SMMA", "ALMA", "ZLSMA", "FRAMA", "KAMA", "JMA", "T3"], group=ma_g, tooltip="Choose a moving average to apply to the calculation.")
ma_length = input.int(75, "Moving Average Length", group= ma_g, tooltip= "Defines the length or period of the S E ECTed moving average.")
ma_lengthSmoothing = input.int(25, "MA - Smooth", group=ma_g)
toleranceInputS = input.float(0.0025, "Tolerance - 1", group = ma_g, tooltip = "Tolerance for Support and Resistance", step = 0.0001)
toleranceInputR = input.float(0.0025, "Tolerance - 2", group = ma_g, tooltip = "Tolerance for Rejection Signs", step = 0.0001)
customRise = input.int(25, "Rising MA", group = ma_g, tooltip = "Change Resistance of Rising MA / Long to Short Term")
// -- Display Inputs
trend_type = input.string("Source Above MA", "S E ECT Trend Type", options=["Source Above MA", "Rising MA"], group=signal_g, tooltip="S E ECT a moving average trend following method.")
d_sr_sigs = input.bool (true, "Display Support/Resistance Signs", group= signal_g, display=display.none, tooltip="Enables triangle signs to be displayed.")
d_r_signs = input.bool (true, "Display Rejection Signs", group= signal_g, display=display.none, tooltip="Enables signs for Trend mode.")
smoothingBool = input.bool (false, "Enable / Disable Smoothing", group= signal_g, display=display.none, tooltip="Enables or Disables smoothing.")
// -- Color Inputs
ColMode = input.string("Mystic", "Custom Color Palette", inline="D R OP", options=["Classic", "Mystic", "Accented", "Royal"], group=colors_g, tooltip="Choose a predefined color scheme for indicator visualization.")
cpyn = input.bool(true, "Use Custom Palette", tooltip="Enable manual S E ECTion of custom colors for trend signals.", group=colors_g, display=display.none)
cp_UpC = input.color(#00ff00, "Custom Up", inline="Custom Palette", tooltip="Set a custom color for bullish signals.", group=colors_g, display=display.none)
cp_DnC = input.color(#ff0000, "Custom Down", inline="Custom Palette", tooltip="Set a custom color for bearish signals.", group=colors_g, display=display.none)
// Colors
color UpC = na
color DnC = na
switch ColMode
"Classic" =>
UpC := #00E676
DnC := #880E4F
"Mystic" =>
UpC := #30FDCF
DnC := #E117B7
"Accented" =>
UpC := #9618F7
DnC := #FF0078
"Royal" =>
UpC := #FFC107
DnC := #673AB7
if cpyn
UpC := cp_UpC
DnC := cp_DnC
smoothADD = ma_length + ma_lengthSmoothing
// Moving Average Switch (Standard, No Volume Weighting)
float ma = na
switch ma_type
"SMA" => ma := DynamicMAs.SMA(source, smoothingBool ? smoothADD : ma_length)
"EMA" => ma := DynamicMAs.EMA(source, smoothingBool ? smoothADD : ma_length)
"WMA" => ma := DynamicMAs.WMA(source, smoothingBool ? smoothADD : ma_length)
"VWMA" => ma := DynamicMAs.VWMA(source, volume, smoothingBool ? smoothADD : ma_length)
"DEMA" => ma := DynamicMAs.DEMA(source, smoothingBool ? smoothADD : ma_length)
"TEMA" => ma := DynamicMAs.TEMA(source, smoothingBool ? smoothADD : ma_length)
"RMA" => ma := DynamicMAs.RMA(source, smoothingBool ? smoothADD : ma_length)
"HMA" => ma := DynamicMAs.HMA(source, smoothingBool ? smoothADD : ma_length)
"LSMA" => ma := DynamicMAs.LSMA(source, smoothingBool ? smoothADD : ma_length, 0)
"SMMA" => ma := DynamicMAs.SMMA(source, smoothingBool ? smoothADD : ma_length)
"ALMA" => ma := DynamicMAs.ALMA(source, smoothingBool ? smoothADD : ma_length, 0, 20)
"ZLSMA" => ma := DynamicMAs.ZLSMA(source, smoothingBool ? smoothADD : ma_length)
"FRAMA" => ma := DynamicMAs.FRAMA(source, smoothingBool ? smoothADD : ma_length)
"KAMA" => ma := DynamicMAs.KAMA(source, smoothingBool ? smoothADD : ma_length)
"JMA" => ma := DynamicMAs.JMA(source, smoothingBool ? smoothADD : ma_length, 0)
"T3" => ma := DynamicMAs.T3(source, smoothingBool ? smoothADD : ma_length, 0.5)
toleranceCodeS = ma * toleranceInputS
toleranceCodeR = ma * toleranceInputS
// MA Touch (Support & Resistance)
var float bandtouch_score = na
if close > ma + toleranceCodeS and low < ma
bandtouch_score := 1 // Support
else if close < ma - toleranceCodeS and high > ma
bandtouch_score := -1 // Resistance
else
bandtouch_score := 0
//-- Rejection (Bullish & Bearish Price Behavior)
var float rejection_score = na
bull_c = ta.crossover(close, ma + toleranceCodeR) // Bullish cross
bear_c = ta.crossunder(close, ma - toleranceCodeR) // Bearish cross
if bandtouch_score[1] == -1 and bull_c == true
rejection_score := 1
else if bandtouch_score[1] == 1 and bear_c == true
rejection_score := -1
else
rejection_score := 0
// Plots
pc = trend_type == "Source Above MA" ? (close > ma ? UpC : DnC) : trend_type == "Rising MA" ? (ma > ma[customRise] ? UpC : DnC) : na
plot(ma, color = pc, title= "Moving Average")
plot(ma, color = color.new(pc, 75), linewidth= 5, title= "Moving Average Glow", display = display.pane)
plot(ma, color = color.new(pc, 80), linewidth= 10, title= "Moving Average Glow 2", display = display.pane)
barcolor(pc, title= "Bar Color")
// -- MA Touch Chars
displays_MATC = d_sr_sigs ? display.pane : display.none
plotchar(low, char='▲', color= bandtouch_score == 1 ? UpC : na, location=location.absolute, title= "Support Signals", display= displays_MATC, size= size.tiny)
plotchar(high, char='▼', color= bandtouch_score == -1 ? DnC : na, location=location.absolute, title= "Resistance Signals", display= displays_MATC, size= size.tiny)
// -- Rejection Shapes
displays_rs = d_r_signs ? display.pane : display.none
plotshape(ta.crossover(rejection_score, 0), title="Rejection Signal", location=location.belowbar,
style=shape.labelup, text="𝓑𝓾𝓵𝓵𝓲𝓼𝓱 𝓡𝓮𝓳𝓮𝓬𝓽𝓲𝓸𝓷", textcolor=#000000, size=size.small,
color=UpC, force_overlay=true, display= displays_rs)
plotshape(ta.crossunder(rejection_score, 0), title="Rejection Signal", location=location.abovebar,
style=shape.labeldown, text="𝓑𝓮𝓪𝓻𝓲𝓼𝓱 𝓡𝓮𝓳𝓮𝓬𝓽𝓲𝓸𝓷", textcolor=#000000, size=size.small,
color=DnC, force_overlay=true, display= displays_rs)
답변완료
93959글 다음 사항 좀 추가 요청 드림니다.
ㅇ 항상 많은 도움에 고맙 습니다.
ㅇ 아래 수식에 다음 3가지 사항 좀 추가 요청 드림니다.
1. "hh","hl","LL"등등 신호발생시 강조수식 요청 (하이킨 아시)
##
Var10 = MA(C,20) ; ## 여기에 아래 수식 적용 방식을 모르겠습니다.
if (H+L) / 2 >= Var10 Then
{
PlotPaintBar(O-PriceScale*0 , C-PriceScale*0 ,"강조",Rgb(255,0,0),Def,7);
PlaySound("C:KiwoomGlobalsoundsound8.wav");
}
if (H+L) / 2 < Var10 Then
{
PlotPaintBar(O-PriceScale*0 , C-PriceScale*0 ,"강조",Rgb(0,125,0),Def,7);
PlaySound("C:KiwoomGlobalsoundsound10.wav");
}
2. "hh","hl","LL"등등 신호발생시 수직선 및 소리음 어디에 넣어야 하나요?
3. C[1]까지 연결선( 신호없는 반대편 마지막 부터 C[1] 까지 연결선)
## 아래 수식
input : prd(20);
input : baseAPT(20);
input : useAdapt(false);
input : volBias(10.0);
input : highS(Blue);
input : lowS(red);
input : S(Blue);
input : R(red);
input : xx(2);
var : b(0);
var : ph(Nan),pl(Nan),phl(0),plL(0),prev(Nan),dir(0);
var : atrLen(50);
var : aha(0),atr(0),apa(0),atrAvg(0),ratio(0);
var : aptRaw(0),aptClamped(0),aptSeries(0);
var : hlc3(0),p(0),vol(0);
b = index;
ph = iff(nthhighestbar(1,high, prd) == 0 , high , ph);
pl = iff(nthlowestbar(1,low, prd) == 0 , low , pl);
phL = iff(nthhighestbar(1,high, prd) == 0 , b , phL);
plL = iff(nthlowestbar(1,low, prd) == 0 , b , plL);
dir = iff(phL > plL , 1 , -1);
aha = 1 / atrLen ;
atr = IFf(IsNan(atr[1]) == true, ma(TrueRange,atrLen) , aha * TrueRange + (1 - aha) * IFf(isnan(atr[1])==true,0,atr[1]));
apa = 1/atrLen;
atrAvg = IFf(IsNan(atrAvg[1]) == true , ma(atr, atrLen) , apa * atr + (1 - apa) * iff(IsNan(atrAvg[1]) == true,0,atrAvg[1]));
ratio = iff(atrAvg > 0 , atr / atrAvg , 1.0);
aptRaw = iff(useAdapt , baseAPT / pow(ratio, volBias) , baseAPT);
aptClamped = max(5.0, min(300.0, aptRaw));
aptSeries = round(aptClamped,0);
hlc3 = (h+l+c)/3;
if Index == 0 Then
{
P = hlc3 * volume;
vol = volume;
}
var : x(0),y(0),loc(0),col(0),txt(""),barsback(0),vap(0),i(0);
var : apt_i(0),alpha(0),pxv(0),v_i(0),vappe(0),decay(0),apt_0(0),v0(0);
var : aa(0),tx(0),txx(0);
if dir != dir[1] Then
{
x = iff(dir > 0 , plL , phL);
y = iff(dir > 0 , pl , ph);
loc = iff(dir > 0 , 0,1);
col = iff(dir > 0 , highS , lowS);
if dir > 0 and pl < prev Then
txt = "LL";
Else
{
if dir > 0 and pl > prev Then
txt = "HL";
Else
{
if dir < 0 and ph < prev Then
txt = "LH";
Else
{
if dir < 0 and ph > prev Then
txt = "HH";
Else
txt = "";
}
}
}
tx = Text_New(sDate[Index-x],sTime[Index-x],y,txt);
Text_SetStyle(tx,2,loc);
Text_SetColor(tx,col);
prev = iff(dir > 0 , ph[1] , pl[1]);
barsback = b - x;
p = y * volume[barsback];
vol = volume[barsback];
vap = p / vol;
for i = barsback downto 0
{
apt_i = aptSeries[i];
decay = exp(-log(2.0) /max(1.0, apt_i));
alpha =1.0 - decay;
pxv = hlc3[i] * volume[i];
v_i = volume[i];
p = (1.0 - alpha) * p + alpha * pxv;
vol = (1.0 - alpha) * vol + alpha * v_i;
vappe = iff(vol > 0 , p / vol , Nan);
txx = Text_New(sDate[i],sTime[i],vappe,"·");
Text_SetStyle(txx,2,2);
Text_SetSize(txx,18);
Text_SetColor(txx,iff(dir > 0 , R , S));
}
}
else
{
apt_0 = aptSeries;
decay = exp(-log(2.0) /max(1.0, apt_0));
alpha =1.0 - decay;
pxv = hlc3 * volume;
v0 = volume;
p = (1.0 - alpha) * p + alpha * pxv;
vol = (1.0 - alpha) * vol + alpha * v0;
vap = iff(vol > 0 , p / vol , Nan);
txx = Text_New(sDate,sTime,vap,"·");
Text_SetStyle(txx,2,2);
Text_SetSize(txx,18);
Text_SetColor(txx,iff(dir > 0 , R , S));
}
ㅇ 항상 많은 도움 고맙습니다. 좋은 한주 되십시요.
답변완료
종목검색식 부탁드립니다
1. 다음 화살표 수식을 일봉 (0봉전)종목 검색식으로 부탁드려요
2. 다음 화살표 수식을
0봉전 ~10봉전까지의 모든 종목 검색식 부탁드립니다.
--------------
smoothADD = ma_length + if(smoothingBool, ma_lengthSmoothing, 0);
MS = if(ma_type == 1, ma(C, smoothADD),
if(ma_type == 2, eavg(C, smoothADD),
if(ma_type == 3, ma(C, smoothADD,가중), eavg(C, smoothADD))));
tolerance_R = MS * toleranceInputR;
PREV_BELOW = C(1) <= MS(1) + tolerance_R;
CURR_ABOVE = C > MS + tolerance_R;
PREV_BELOW AND CURR_ABOVE
- 지표조건설정
ma_length : 60
ma_lengthSmoothing : 20
smoothingBool : 0
ma_type : 1
toleranceInputR : 0.0025
----------------------------------------------------------------------------
3. 아래 수식을 참고하여(하단),
일봉기준차트에 주봉 10일 이평선을(단순) 긋고,
일봉차트에서 주봉 10일 이평선이(단순) 아래 (수식1)의 이평선을 돌파할때
종목 검색식 부탁드려요.
4. 아래 수식을 참고하여(하단),
일봉기준차트에 주봉 10일 이평선을(단순) 긋고,
일봉차트에서 주봉 10일 이평선이(단순) 아래 (수식1)의 이평선을 돌파할때
0봉전 ~ 10봉전까지의 모든종목 검색식 부탁드려요.
5. 아래 수식을 참고하여(하단),
일봉기준차트에 주봉 10일 이평선을(단순) 긋고,
일봉차트에서 주봉 10일 이평선(단순)과 아래 (수식1)의 이평선이
(수식1)의 이평선을 기준으로, 상하 1%이내 수렴 했을때
모든종목 검색식 부탁드려요.
6. 아래 수식을 참고하여(하단),
일봉기준차트에 주봉 10일 이평선을(단순) 긋고,
일봉차트에서 양봉 캔들이(꼬리 몸통 모두 포함)
주봉 10일 이평선과(단순), 아래(수식1)의 이평선을 캔들이 양봉(꼬리몸통 모두)
으로 동시돌파할때 종목 검색식 부탁합니다.
7. 아래 수식을 참고하여(하단),
일봉기준차트에 주봉 10일 이평선을(단순) 긋고,
캔들이 종가기준, 주봉 10일 이평선(단순) 위에 있고
아래(수식1)의 이평선 기준 상단 1% 아래에 있는 모든종목 검색식 부탁합니다.
8. 아래수식을 참고하여 (하단),
(수식1) 이 상승추세로 돌아설때 종목검색식 부탁드려요.
---아래---
(수식1) 이평
smoothADD = ma_length + if(smoothingBool, ma_lengthSmoothing, 0);
MS = if(ma_type == 1, ma(C, smoothADD),
if(ma_type == 2, eavg(C, smoothADD),
if(ma_type == 3, ma(C, smoothADD,가중), eavg(C, smoothADD))));
MS
(수식2) 상승
if(MS(1)<MS,MS,0)
(수식3) 하락
if(MS(1)>=MS,MS,0)
- 지표조건설정
ma_length : 80
ma_lengthSmoothing : 20
smoothingBool : 0
ma_type : 2