R05Participant
Veteran
Ok giusto. Ho modificato le voci però non apre nessuna posizione. Nemmeno una.
Ci sono alcune incongruenze:
- alle righe 65 e 66 hai definito alccune variabili già definite precedentemente in modo diverso (basta chiamarle diversamente), quindi devi cambiare anche i nomi nelle righe 70 e 75
- alle righe 60 e 61 hai indicato che devono esserci due candele opposte, ma se poi verifichi che ce ne siano 10 di uno stesso colore non può funziuonare!
questo funziona:
// Definizione dei parametri del codice
DEFPARAM CumulateOrders = False // Posizioni cumulate disattivate
defparam flatbefore = 090000
defparam flatafter = 183000
//PRC_HPT Heikin Ashi Smoothed | indicator
//25.04.2017
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge
//translated from MT4 indicator code
//---settings
MaPeriod=10
//MaPeriod2=10
//---end of settings
once maOpen=Open
once maClose=Close
//once maLow=Low
//once maHigh=High
if barindex>0 then
maOpen=(maOpen[1]*(MAperiod-1)+Open)/MAPeriod
maClose=(maClose[1]*(MAperiod-1)+Close)/MAPeriod
maLow=(maLow[1]*(MAperiod-1)+Low)/MAPeriod
maHigh=(maHigh[1]*(MAperiod-1)+High)/MAPeriod
haOpen=(ExtMapBuffer5[1]+ExtMapBuffer6[1])/2
haClose=(maOpen+maHigh+maLow+maClose)/4
//haHigh=Max(maHigh, Max(haOpen, haClose))
//haLow=Min(maLow, Min(haOpen, haClose))
if (haOpen<haClose) then
//r=0
//g=191
//b=255
//ExtMapBuffer7=haLow
//ExtMapBuffer8=haHigh
else
//r=255
//g=10
//b=0
//ExtMapBuffer7=haHigh
//ExtMapBuffer8=haLow
endif
ExtMapBuffer5=haOpen
ExtMapBuffer6=haClose
//ExtMapBuffer1=weightedaverage[MAperiod2](ExtMapBuffer7)
//ExtMapBuffer2=weightedaverage[MAperiod2](ExtMapBuffer8)
//ExtMapBuffer3=weightedaverage[MAperiod2](ExtMapBuffer5)
//ExtMapBuffer4=weightedaverage[MAperiod2](ExtMapBuffer6)
endif
Bullish = haClose > haOpen
Bearish = haClose < haOpen
//DRAWCANDLE(ExtMapBuffer3,ExtMapBuffer2,ExtMapBuffer1,ExtMapBuffer4) coloured(r,g,b)
//short = ExtMapBuffer7[1]>ExtMapBuffer8[1] and ExtMapBuffer7[2]<ExtMapBuffer8[2] and ExtMapBuffer7[0]>ExtMapBuffer8[0]
//long = ExtMapBuffer7[1]<ExtMapBuffer8[1] and ExtMapBuffer7[2]>ExtMapBuffer8[2] and ExtMapBuffer7[0]<ExtMapBuffer8[0]
Long = 1//Bullish AND Bearish[1]
Short = 1//Bearish AND Bullish[1]
ONCE CandleNum = 10
Bullish2 = summation[CandleNum](Bearish) = CandleNum
Bearish2 = summation[CandleNum](Bullish) = CandleNum
// Condizioni per entrare su posizioni long
IF long and Bullish2 THEN
BUY 1 CONTRACTS AT MARKET
ENDIF
// Condizioni per entrare su posizioni short
IF short and Bearish2 THEN
SELLSHORT 1 CONTRACTS AT MARKET
ENDIF
// Stop e target: Inserisci qui i tuoi stop di protezione e profit target
set target pprofit 20
set stop ploss 20
R05Participant
Veteran
Ciao Roberto, scusa ma solo ora ho potuto vedere e fare le verifiche. Ti ringrazio della disponibilità.
Ho notato che il sistema, se imposto il valore dopo 10 candele, apre direttamente la posizione anche se non c’è il cambio di colore dell’heikin ashi smoothed.
Per capirmi meglio ti faccio l’esempio col grafico. L’esempio è sul Nasdaq di oggi.
Non era previsto il cambio di colore, solo che al raggiungimento di quel numeri di candele doveva entrare in direzionhe opposta, dopo 10 rialziste entra Short e dopo 10 ribassiste entra Long.
Riepilogami cosa vuoi che faccia il TS.
R05Participant
Veteran
Si Roberto giusto, ti riepilogo il tutto.
Gli esempi sono sul nasdaq time frame 30 secondi, oggi. In pratica, ho almeno 10 candele rosse heikin ashi smoothed, da qui in poi posso entrare long se cambia il colore in blu e viceversa. Se ad esempio ho 8 candele rosse e alla nona diventa blu non deve entrare in posizione. L’ho letto in un libro, cerco di filtrare le operazioni in base a quante candele rosse o blu consecutive ho (anche se nel libro si parla di heikin ashi normale, io ho spostato l’idea su quelle smoothed).
Per meglio chiarirmi ti ho fatto direttamente il grafico dove ci ho scritto sopra.
Quindi, oltre alle 10 candele consecutive t’interessa che dopo di esse ci sia un cambio di colore.
Eccolo (non l’ho provato):
// Definizione dei parametri del codice
DEFPARAM CumulateOrders = False // Posizioni cumulate disattivate
defparam flatbefore = 090000
defparam flatafter = 183000
//PRC_HPT Heikin Ashi Smoothed | indicator
//25.04.2017
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge
//translated from MT4 indicator code
//---settings
MaPeriod=10
//MaPeriod2=10
//---end of settings
once maOpen=Open
once maClose=Close
//once maLow=Low
//once maHigh=High
if barindex>0 then
maOpen=(maOpen[1]*(MAperiod-1)+Open)/MAPeriod
maClose=(maClose[1]*(MAperiod-1)+Close)/MAPeriod
maLow=(maLow[1]*(MAperiod-1)+Low)/MAPeriod
maHigh=(maHigh[1]*(MAperiod-1)+High)/MAPeriod
haOpen=(ExtMapBuffer5[1]+ExtMapBuffer6[1])/2
haClose=(maOpen+maHigh+maLow+maClose)/4
//haHigh=Max(maHigh, Max(haOpen, haClose))
//haLow=Min(maLow, Min(haOpen, haClose))
if (haOpen<haClose) then
//r=0
//g=191
//b=255
//ExtMapBuffer7=haLow
//ExtMapBuffer8=haHigh
else
//r=255
//g=10
//b=0
//ExtMapBuffer7=haHigh
//ExtMapBuffer8=haLow
endif
ExtMapBuffer5=haOpen
ExtMapBuffer6=haClose
//ExtMapBuffer1=weightedaverage[MAperiod2](ExtMapBuffer7)
//ExtMapBuffer2=weightedaverage[MAperiod2](ExtMapBuffer8)
//ExtMapBuffer3=weightedaverage[MAperiod2](ExtMapBuffer5)
//ExtMapBuffer4=weightedaverage[MAperiod2](ExtMapBuffer6)
endif
Bullish = haClose > haOpen
Bearish = haClose < haOpen
Cambio = (Bullish AND Bearish[1]) OR (Bearish AND Bullish[1])
//DRAWCANDLE(ExtMapBuffer3,ExtMapBuffer2,ExtMapBuffer1,ExtMapBuffer4) coloured(r,g,b)
//short = ExtMapBuffer7[1]>ExtMapBuffer8[1] and ExtMapBuffer7[2]<ExtMapBuffer8[2] and ExtMapBuffer7[0]>ExtMapBuffer8[0]
//long = ExtMapBuffer7[1]<ExtMapBuffer8[1] and ExtMapBuffer7[2]>ExtMapBuffer8[2] and ExtMapBuffer7[0]<ExtMapBuffer8[0]
Long = 1//Bullish AND Bearish[1]
Short = 1//Bearish AND Bullish[1]
ONCE CandleNum = 10
Bullish2 = summation[CandleNum](Bearish) = CandleNum
Bearish2 = summation[CandleNum](Bullish) = CandleNum
// Condizioni per entrare su posizioni long
IF long and Bullish2[1] AND Cambio THEN
BUY 1 CONTRACTS AT MARKET
ENDIF
// Condizioni per entrare su posizioni short
IF short and Bearish2[1] AND Cambio THEN
SELLSHORT 1 CONTRACTS AT MARKET
ENDIF
// Stop e target: Inserisci qui i tuoi stop di protezione e profit target
set target pprofit 20
set stop ploss 20
R05Participant
Veteran
Si Roberto è così. Perfetto, funziona correttamente. Grazie come sempre. Gentilissimo.
Ciao, hai ottenuto buoni risultati? Funziona meglio nel forex rispetto a qualsiasi indice?
Grazie
R05Participant
Veteran
Ciao io trado solo indici. Attualmente lo sto testando sul nasdaq, sto facendo un pò di backtest ma devo ancora trovare la giusta quadra.