Buongiorno e’ possibile avere questo indicatore già presente su altre piattaforme anche in PRT?
@nicolas @robertogozzi Grazie in anticipo.
Allego qualche link che spiega il funzionamento:
https://library.tradingtechnologies.com/trade/chrt-ti-intraday-momentum-index.html
http://www.traderpedia.it/wiki/index.php/Formula_Intraday_Momentum_Indicator
qui il codice preso da tradingview:
//@version=2
study("Intraday Momentum Indicator")
// Get traditional OHLC values
tOpen = security(tickerid, 'D', open)
tClose = security(tickerid, 'D', close)
// Inputs
imiPeriod = input(defval = 14, title = "IMI Period Length", type = integer, minval = 1)
//Calculate IMI
imiGain = tClose > tOpen ? nz(imiGain[1]) + (tClose - tOpen) : 0 // Open Higher than Close, Gain day
imiLoss = tClose < tOpen ? nz(imiLoss[1]) + (tOpen - tClose) : 0 // Close Higher than Open, Loss day
imiGainSum = sum(imiGain,imiPeriod) // Sum total of all Gains in specified period
imiLossSum = sum(imiLoss, imiPeriod) // Sum total of all Loses in specified period
imiTotal = 100 * (imiGainSum / (imiGainSum + imiLossSum))
plot (70, title = "Overbought", style = circles, color = green, transp = 10, join = true)
plot(30, title = "Oversold", style = circles, color = red, transp = 30, join = true)
plot(imiTotal, title = "Intraday Momentum Indicator", style = line, color = yellow, transp = 0) // Plot the indicator
ho anche provato un poco a farlo ma senza riuscirci:
//@version=2
//study("Intraday Momentum Indicator")
// Get traditional OHLC values
tOpen = Open
tClose = close
// Inputs
imiPeriod = periodi
//Calculate IMI
if tClose > tOpen then
imigain=(imiGain[1]) + (tClose - tOpen)
endif
// Open Higher than Close, Gain day
if tClose < tOpen then
imiloss=(imiLoss[1]) + (tOpen - tClose)
endif // Close Higher than Open, Loss day
imiGainSum = summation[imiPeriod](imiGain) =imiPeriod// Sum total of all Gains in specified period
imiLossSum = summation[imiPeriod](imiloss)=imiPeriod // Sum total of all Loses in specified period
imiTotal = 100 * (imiGainSum / (imiGainSum + imiLossSum))
return imitotal
Penso che dovrebbe essere codificato in questo modo:
//@version=2
//study("Intraday Momentum Indicator")
// Get traditional OHLC values
tOpen = dOpen(0)
tClose = dclose(0)
// Inputs
imiPeriod = 14
if barindex>imiPeriod then
//Calculate IMI
if tClose > tOpen then
imigain=(imiGain[1]) + (tClose - tOpen)
else
imigain=0
endif
// Open Higher than Close, Gain day
if tClose < tOpen then
imiloss=(imiLoss[1]) + (tOpen - tClose)
else
imiLoss=0
endif // Close Higher than Open, Loss day
imiGainSum = summation[imiPeriod](imiGain)// Sum total of all Gains in specified period
imiLossSum = summation[imiPeriod](imiloss)// Sum total of all Loses in specified period
imiTotal = 100 * (imiGainSum / (imiGainSum + imiLossSum))
endif
return imitotal,70,30
L’indicatore che hai pubblicato usa il quotidiano Apri e Chiudi. Ma la formula originale usa invece il tempo corrente Apri e Chiudi, quindi in base a questo puoi cambiare le variabili con:
tOpen = open//dOpen(0)
tClose = close//dclose(0)
praticamente simile a una RSI, ma invece di usare Close / Close [1], utilizza Open / Close