Ciao a tutti,
ho questo codice preso dal sito e non riesco più a trovare la pagina da cui l’ho preso per cui devo chiedere aiuto a tutti voi.
Questo codice funziona in demo senza errori e l’ho preso e spostato su un altro account che ho aperto ma non posso farlo partire perchè compare l’errore in allegato.
il codice è lo stesso ma sul nuovo account non mi permette di lanciarlo.
Mi potete aiutare a trovare o chi l’ha postato oppure a risolvere l’errore?
Grazie
//-------------------------------------------------------------------------
// Codice principale : The Grinder EUSD 1H
//-------------------------------------------------------------------------
// System parameters
DEFPARAM CumulateOrders = False
DEFPARAM PRELOADBARS = 2000
DEFPARAM FLATBEFORE = 080000
DEFPARAM FLATAFTER = 210000
LimitEntryTime = 200000 //No Entries after this time
// Divergence Indicator RSI
ignored, DRSI = CALL "Divergence RSI v3"[24,8,1,0]
BullishDivergence = DRSI = 1
BearishDivergence = DRSI = -1
// Filter to avoid entries on a trend (Delayed Donchian Canal with a Margin)
NotBearTrend = LOWEST[100](close[10]) < (close+((close*SafetyMargin)/100))
NotBullTrend = HIGHEST[100](close[10]) > (close-((close*SafetyMargin)/100))
SafetyMargin = 0.05
// Conditions for Entry of Long Positions
IF BullishDivergence AND NotBearTrend AND OPENTIME<=LimitEntryTime THEN
BUY 1 CONTRACTS AT MARKET
ELSIF SHORTONMARKET AND ((CLOSE-TRADEPRICE)/TRADEPRICE)*100 > FlipPosition THEN// Change from short to long position when the FlipPosition Stop reached, because a trend is underway
BUY 1 CONTRACTS AT MARKET
ENDIF
// Conditions for Entry of Short Positions
IF BearishDivergence AND NotBullTrend AND OPENTIME<=LimitEntryTime THEN
SELLSHORT 1 CONTRACTS AT MARKET
ELSIF LONGONMARKET AND ((CLOSE-TRADEPRICE)/TRADEPRICE)*100 < -FlipPosition THEN// Change from long to short position when the FlipPosition Stop reached, because a trend is underway
SELLSHORT 1 CONTRACTS AT MARKET
ENDIF
// Loss, Profit and Flip Stops
SET STOP %LOSS 2 // Not used because the Flip Stop is lower, just in case.
SET TARGET %PROFIT 31.1
FlipPosition = 1.0 // It this %Loss is reached the position turns in the opposite direction (Long->Short or Short->Long)
// END
//-------------------------------------------------------------------------
// Funzione : Divergence RSI v3
//-------------------------------------------------------------------------
/// Detector of divergences
/// Version by TempusFugit based on an original idea of jose7674
///The variable "N" is the number of bars backwards that we use to find a divergence
///The variable "a" is the number of bars used to calculate RSI
///The variable "b" is the number of bars checked backwards to detecte swing highs or lows
///The variable "c" is the aditional increase/decrise in price required to get a divergence
DRSI = RSI[a](close)
cero = 0
////Searching for swing highs or lows
IF (BarIndex > 5+N) THEN
IF (DRSI[1]>DRSI AND DRSI[1]>highest[b](DRSI[2])) THEN
RSISwingHigh=DRSI[1]
RSIPreviousSwingHigh=highest[N](DRSI)
PriceSwingHigh=close[1]
PricePreviousSwingHigh=Highest[N](close)
ENDIF
IF (DRSI[1]<DRSI AND DRSI[1]<lowest[b](DRSI[2])) THEN
RSISwingLow=DRSI[1]
RSIPreviousSwingLow=lowest[N](DRSI)
PriceSwingLow=close[1]
PricePreviousSwingLow=lowest[N](close)
ENDIF
////Detecting Divergences between RSI and Price
IF(RSISwingHigh<RSIPreviousSwingHigh AND PriceSwingHigh>(PricePreviousSwingHigh[1]*(1+(c/100)))) THEN
signal = -1
ELSE
signal = 0
ENDIF
IF(RSISwingLow>RSIPreviousSwingLow AND PriceSwingLow<(PricePreviousSwingLow[1]*(1-(c/100)))) THEN
signal = 1
ENDIF
ENDIF
Return cero as "0", signal as "Divergence"
/// If Divergence = 1, there is bullish divergence. if D =-1, bearish divergence
///END
What you have posted is one indicator and one strategy. The strategy calls the indicator. You are getting an error about RETURN if you are trying to write the indicator as a strategy.
Quello che hai postato è un indicatore e una strategia. La strategia chiama l’indicatore. Si sta verificando un errore su RETURN se si sta tentando di scrivere l’indicatore come strategia.
Grazie,
ma perchè funziona su un conto demo prorealtime?
Forse devo avere anche l’indicatore caricato?
Grazie
Forse devo avere anche l’indicatore caricato?
Yes of course. You cannot call an indicator that is not on your platform.
Sì, naturalmente. Non puoi chiamare un indicatore che non sia sulla tua piattaforma.
Ciao,
grazie ma l’indicatore che devo cercare è quello chiamato Divergence, giusto?
Ciao