예스스탁
예스스탁 답변
2024-06-12 09:29:04
안녕하세요
예스스탁입니다.
input : length(14);
input : os(20);
input : ob(80);
input : CurrentRes(true); //true면 타주기(CustomRes), False이면 차트주기
input : CustomRes(240);//0이하이면 일봉
var : S1(0),D1(0),TM(0),TF(0),cnt(0);
var : positiveMoneyFlow(0),negativeMoneyFlow(0),moneyFlowIndex(0);
var : oversold(False),overbought(False),col(0),tx(0);
Array : CC[100](0),HH[100](0),LL[100](0),VV[100](0);
if CurrentRes == true Then
{
if CustomRes > 0 Then
{
if Bdate != Bdate[1] Then
{
S1 = TimeToMinutes(stime);
D1 = sdate;
}
if D1 > 0 then
{
if sdate == D1 Then
TM = TimeToMinutes(stime)-S1;
Else
TM = TimeToMinutes(stime)+1440-S1;
TF = TM%CustomRes;
if Bdate != Bdate[1] or
(Bdate == Bdate[1] and CustomRes > 1 and TF < TF[1]) or
(Bdate == Bdate[1] and CustomRes > 1 and TM >= TM[1]+CustomRes) or
(Bdate == Bdate[1] and CustomRes == 1 and TM > TM[1]) Then
{
for cnt = 99 downto 1
{
HH[cnt] = HH[cnt-1];
LL[cnt] = LL[cnt-1];
CC[cnt] = CC[cnt-1];
VV[cnt] = VV[cnt-1];
}
HH[0] = H;
LL[0] = L;
VV[0] = 0;
}
if HH[0] > 0 and H > HH[0] Then
HH[0] = H;
if LL[0] > 0 and H < LL[0] Then
LL[0] = L;
CC[0] = C;
VV[0] = VV[0]+V;
if VV[Length] > 0 Then
{
positiveMoneyFlow = 0;
negativeMoneyFlow = 0;
For cnt = 0 to Length-1
{
if (HH[cnt]+LL[cnt]+CC[cnt])/3 > (HH[cnt+1]+LL[cnt+1]+CC[cnt+1])/3 Then
positiveMoneyFlow = positiveMoneyFlow + (HH[cnt]+LL[cnt]+CC[cnt])/3*VV[cnt];
if (HH[cnt]+LL[cnt]+CC[cnt])/3 < (HH[cnt+1]+LL[cnt+1]+CC[cnt+1])/3 Then
negativeMoneyFlow = negativeMoneyFlow + (HH[cnt]+LL[cnt]+CC[cnt])/3*VV[cnt];
}
moneyFlowIndex = 100 - 100 / (1 + (positiveMoneyFlow/negativeMoneyFlow));
}
}
}
Else
{
if DayVolume(Length) > 0 Then
{
positiveMoneyFlow = 0;
negativeMoneyFlow = 0;
For cnt = 0 to Length-1
{
if (dayhigh(cnt)+daylow(cnt)+dayclose(cnt))/3 > (dayhigh(cnt+1)+daylow(cnt+1)+dayclose(cnt+1))/3 Then
positiveMoneyFlow = positiveMoneyFlow + (dayhigh(cnt)+daylow(cnt)+dayclose(cnt))/3*DayVolume(cnt);
if (dayhigh(cnt)+daylow(cnt)+dayclose(cnt))/3 < (dayhigh(cnt+1)+daylow(cnt+1)+dayclose(cnt+1))/3 Then
negativeMoneyFlow = negativeMoneyFlow + (dayhigh(cnt)+daylow(cnt)+dayclose(cnt))/3*DayVolume(cnt);
}
moneyFlowIndex = 100 - 100 / (1 + (positiveMoneyFlow/negativeMoneyFlow));
}
}
}
Else
{
moneyFlowIndex = MFI(Length);
}
plot1(moneyFlowIndex,"MFI",black);
PlotBaseLine1(80, "Overbought");
PlotBaseLine2(20, "Oversold");
PlotBaseLine3(40, "Bears");
PlotBaseLine4(60, "Bulls");
oversold = moneyFlowIndex[1] > os[1] and moneyFlowIndex < os;
overbought = moneyFlowIndex[1] < ob[1] and moneyFlowIndex > ob;
col = iff(oversold , green , red);
if oversold == true Then
{
tx = Text_New_Self(sDate,sTime,moneyFlowIndex,"●");
Text_SetColor(tx,col);
Text_SetStyle(tx,2,2);
}
if overbought == true Then
{
tx = Text_New_Self(sDate,sTime,moneyFlowIndex,"●");
Text_SetColor(tx,col);
Text_SetStyle(tx,2,2);
}
즐거운 하루되세요
> 부호장자 님이 쓴 글입니다.
> 제목 : 수식변환 요청
> 수고 하십니다.
아래 수식을 예스로 변환해 주시면 좋겠습니다.
study("Money Flow Index MTF + Alerts", overlay = false)
////////////////////////////
// Version control
// ========================
// 1.0
// Initial Release
// 1.1
// Added support for multiple time frames
// Cleaned up code
// 1.1.1
// Minor error fix
////////////////////////////
//Inputs
length = input(title="Length", defval=14)
os = input(20, title="Oversold")
ob = input(80, title="Overbought")
CurrentRes = input(true, title="Use Current Chart Resolution?")
CustomRes = input("240", title="Custom Timeframe? Uncheck Box Above (E.g. 1M, 5D, 240 = 4Hours)")
//MFI Calc
res = CurrentRes ? period : CustomRes
rawMoneyFlow = hlc3 * volume
positiveMoneyFlow() =>
a = 0.0
a := hlc3 > hlc3[1] ? a + rawMoneyFlow : a
negativeMoneyFlow() =>
b = 0.0
b := hlc3 < hlc3[1] ? b + rawMoneyFlow : b
moneyFlowRatio = sma(positiveMoneyFlow(), length) / sma(negativeMoneyFlow(), length)
moneyFlowIndex = security(tickerid, res, 100 - 100 / (1 + moneyFlowRatio))
//OB/OS Identification
oversold = moneyFlowIndex[1] > os[1] and moneyFlowIndex < os
overbought = moneyFlowIndex[1] < ob[1] and moneyFlowIndex > ob
//Plotting
col = oversold ? green : red
plot(moneyFlowIndex, color=black, linewidth=2)
plot(oversold ? moneyFlowIndex : overbought ? moneyFlowIndex : na, title="Oversold/Overbought Cross", color=col, style=circles, linewidth=6)
h1 = hline(80, "Overbought")
h2 = hline(20, "Oversold")
h3 = hline(40, "Bears")
h4 = hline(60, "Bulls")
fill(h4, h1, color=green, title="Uptrend")
fill(h3, h2, color=red, title="Downtrend")
fill (h3, h4, color=gray, title="Transition Zone")
//Alerts
alert = oversold or overbought
alertcondition(oversold, title="MFI Oversold", message="MFI Crossed Oversold" )
alertcondition(overbought, title="MFI Overbought", message="MFI Crossed Overbought" )
alertcondition(alert, title="MFI Alert Both", message="MFI Alert Generated OB/OS" )