Salve a tutti,
ho questo codice per multichart che vorrei codificare in PRT, codice su Gold tf 1h, qualcuno potrebbe aiutarmi?
grazie
PS.
gli orari sono quelli di Chicago
input:valoreSL(1500);
vars: LongTrades(0), ShortTrades(0);
If date<>date[1] then
begin
LongTrades=0;
ShortTrades=0;
end;
var : giornoIndecisione (false);
giornoIndecisione = absvalue(opend(1)-closed(1)) <= 0.50*(Highd(1)-LowD(1)); // Filtro indecisione giorno precedente
If Marketposition = 0 and Time>1000 and Time<2400 and
LongTrades=0 and
giornoIndecisione and
Momentum(close,5)<2*avgtruerange(5) and Highest(High[1],3)<maxlist(HighD(1), HighD(2)) [1]
then buy next bar maxlist(HighD(1), HighD(2))stop;
If Marketposition = 0 and Time>100 and Time<1000 and
ShortTrades=0 and
giornoIndecisione and
Momentum(close,5)<2*avgtruerange(3) and
lowest(Low[1],3)>minlist(LowD(1), LowD(2))[1]
then sellshort next bar minlist(LowD(1), LowD(2)) stop;
If Marketposition = 1 and Time=200 then sell next bar market;
If Marketposition = -1 and Time=1000 then buytocover next bar market;
//casual friday
If dayofweek(date)=5 and T=1600 then
Begin
sell next bar market;
buytocover next bar market;
end;
input: percentualeDaily(80), ATRLength(4);
If MarketPosition <>0 then
begin
sell Next Bar at (EntryPrice -(percentualeDaily/100) * AvgTrueRange(ATRLength) of Data2) stop;
buytocover Next Bar at (EntryPrice + (percentualeDaily/100) * AvgTrueRange(ATRLength) of Data2) stop;
end;
if valoreSL <> 0 then setstoploss(valoreSL );
DANYParticipant
Senior
Ciao,
eccolo !
- Ho assunto che il DATA2 di Multicharts fosse sempre sul GOLD e con Timeframe giornaliero.
- Importante sarebbe sapere se Multichart gira su Ora Locale o su “Exchange Time” perchè in tal caso andrebbero riportati gli orari Exchange o meglio convertiti in Local per PRT. Io al momento li ho tenuti invariati.
- Andrebbe ottimizzato lo STOP Loss che ho tenuto ad 1/10 del contratto Future GOLD.
- Risultato complessivamente non male ma CFD e Future non sono sempre confrontabili. Però è interessante e ci si può lavorare…. Se ne hai altri li traduco senza problemi. Ci metto 10 minuti. Al limite sentiamoci direttamente se preferisci.
Ciao.
valoreSL=150 //x CFD 10 oz, un decimo del Gold standard
If date<>date[1] then
LongTrades=0
ShortTrades=0
endif
giornoIndecisione=0
giornoIndecisione = abs(dopen(1)-dclose(1)) <= 0.50*(dHigh(1)-dLow(1)) // Filtro indecisione giorno precedente
CondL1=Momentum[5](close)<2*averagetruerange[5](close)
CondL2=Highest[3](High[1])<max(dHigh(1), dHigh(2))[1] //??
If not OnMarket and Time>100000 and Time<240000 and LongTrades=0 and giornoIndecisione and CondL1 and CondL2 then
buy 1 contract at max(dHigh(1), dHigh(2)) stop
endif
CondS1=Momentum[5](close)<2*averagetruerange[3](close)
CondS2=Lowest[3](Low[1])>min(dLow(1), dLow(2))[1] //??
If not OnMarket and Time>010000 and Time<100000 and ShortTrades=0 and giornoIndecisione and CondS1 and CondS2 then
sellshort 1 contract at min(dLow(1), dLow(2)) stop
endif
If LongOnMarket = 1 and Time=020000 then
sell at market
endif
If ShortOnMarket and Time=100000 then
exitshort at market
endif
//casual friday
If dayofweek=5 and Time=160000 then
sell at market
exitshort at market
endif
percentualeDaily=80
ATRLength=4
timeframe(daily)
VarATR=AverageTrueRange[ATRLength](close)
timeframe(default)
If OnMarket then
sell at (PositionPrice - (percentualeDaily/100) * VarATR) stop
exitshort at (PositionPrice + (percentualeDaily/100) * VarATR) stop
endif
if valoreSL <> 0 then
set stop ploss valoreSL
endif
DANYParticipant
Senior
Scusa, vedo solo ora che avevi specificato l’exchange time di Chicago…. Ho convertito gli orari. Molto meglio sino al 2017 (vedi immagine allegata) ma poi non guadagna più anche se non perde. Bisogna lavorarci un po’ per vedere se il sistema magari è un po’ vecchio e ha smesso di funzionare oppure se ci sono solo da ottimizzare un po’ le variabili.
valoreSL=150 //x CFD 10 oz, un decimo del Gold standard
If date<>date[1] then
LongTrades=0
ShortTrades=0
endif
giornoIndecisione=0
giornoIndecisione = abs(dopen(1)-dclose(1)) <= 0.50*(dHigh(1)-dLow(1)) // Filtro indecisione giorno precedente
CondL1=Momentum[5](close)<2*averagetruerange[5](close)
CondL2=Highest[3](High[1])<max(dHigh(1), dHigh(2))[1] //??
//100000-> 170000
//240000-> 070000
If not OnMarket and ((Time>170000 and Time<230000) OR (Time>010000 AND time<070000)) and LongTrades=0 and giornoIndecisione and CondL1 and CondL2 then
buy 1 contract at max(dHigh(1), dHigh(2)) stop
endif
CondS1=Momentum[5](close)<2*averagetruerange[3](close)
CondS2=Lowest[3](Low[1])>min(dLow(1), dLow(2))[1] //??
//010000 -> 080000
If not OnMarket and (Time>080000 and Time<170000) and ShortTrades=0 and giornoIndecisione and CondS1 and CondS2 then
sellshort 1 contract at min(dLow(1), dLow(2)) stop
endif
//020000 -> 090000
If LongOnMarket = 1 and Time=090000 then
sell at market
endif
If ShortOnMarket and Time=170000 then
exitshort at market
endif
//casual friday
If dayofweek=5 and Time=230000 then
sell at market
exitshort at market
endif
percentualeDaily=80
ATRLength=4
timeframe(daily)
VarATR=AverageTrueRange[ATRLength](close)
timeframe(default)
If OnMarket then
sell at (PositionPrice - (percentualeDaily/100) * VarATR) stop
exitshort at (PositionPrice + (percentualeDaily/100) * VarATR) stop
endif
if valoreSL <> 0 then
set stop ploss valoreSL
endif
Grazie mille DANY per aver dedicato del tempo ad aiutare gli altri membri con le loro richieste. Apprezzo molto! 😉
GRAZIE 1000 Dany,
quale è la tua mail? ti contatto
grazie
Per favore non includere informazioni personali come indirizzi e-mail o numeri di telefono nei tuoi post.
Grazie 🙂
DANYParticipant
Senior
Giustamente come dice Roberto non è permesso mettere i propri dati in chiaro. Se per te non ci sono problemi posso continuare a darti assistenza sul forum, altrimenti segui pure le indicazioni di Roberto. Ciao.