ProRealCode - Trading & Coding with ProRealTime™
Ciao, io tengo sia il 3min che 30 min,ma non ha fatto niente,pero’ in backtest su 30 m avrebbe dovuto fare trade,nelle opzioni va messo 2 lotti ?Io ho messo
Intendevo dire, che il giorno 3 gennaio mi ha fatto l’ultimo trade (TF 30 minuti). Per come è configurato fa trade di 2 lotti, quindi quando avvii il backtest devi inserire numero lotti 2.
Ciao Roberto, con tutta onesta’ ho provato a modificare le righe ma non ci sono riuscito,ti scrivo come dovrebbero funzionare i pattern se riesci a farlo sarebbe la soluzione di un problema annuale! tutti 3 pattern hanno la condizione : buy solo sopra la media short solo sotto la media pattern 1/ pattern 2 buy : pattern deve essere rialzista (candela verde) la candela precedente deve essere sempre ribassista (rossa) ed avere il minimo superiore a quello del pattern sell : pattern deve essere ribassista ( candela rossa) la candela precedente deve essere sempre rialzista (candela verde) con il minimo inferiore a quello del pattern grazie !!!!
Cerco di darci un’occhiata appena ho un pò di tempo.
Ho dato un’occhiata al pattern2 e rilevo un paio d’incongruenze, verifica se anche per te sono logicamente errate
buypattern2 = close>open and
summation[2](close[1]<open[1])= 2 and
high>high[1] and
low<low[1] and //non dovrebbe essere low>low[1], visto che è una candela rialzista?
highdecrease>=MinimoMassimoDecrescente
sellpattern2 = close<open and
summation[2](close[1]>open[1])=2 and
high>high[1] and //non dovrebbe essere high<high[1], visto che è una candela ribassista?
low<low[1] and
lowincrease>=MinimoMassimoDecrescente
Ciao Roberto,
grazie!
Scusami ma ho sbagliato io l’informazione del dettaglio dei pattern : queste condizioni valgono solo per il pattern 1/3,il pattern 2 sono sicuro che non va bene,ma adesso non volevo mettere troppi problemi insieme,quindi il pattern per il momento non va considerato
Ciao Roberto, con tutta onesta’ ho provato a modificare le righe ma non ci sono riuscito,ti scrivo come dovrebbero funzionare i pattern se riesci a farlo sarebbe la soluzione di un problema annuale! tutti 3 pattern hanno la condizione : buy solo sopra la media short solo sotto la media pattern 1/ pattern 2 buy : pattern deve essere rialzista (candela verde) la candela precedente deve essere sempre ribassista (rossa) ed avere il minimo superiore a quello del pattern sell : pattern deve essere ribassista ( candela rossa) la candela precedente deve essere sempre rialzista (candela verde) con il minimo inferiore a quello del pattern grazie !!!!
La condizione del pattern 2 deve essere :
buy = pattern rialzista (candela verde),sempre minimo 2 candele precedenti rosse(ribassiste)
il pattern deve avere rispetto solo alla candela precedente rossa (ribassista ) il minimo superiore ed il massimo superiore
Scusami spero che adesso puoi vedere meglio anche il pattern 2
Grazie per tutta la disponibilita’!!
Per evitare confusione, indicami solamente le condizioni del PATTERN1, cioè come deve essere la formazione delle candele.
Ripeti ancora, separatamente, per i PATTERN2 e 3, ma sempre indicandoli inteamente e singolarmente.
In pratica, dopo avermi detto come deve essere esattamente il pattern1, per il pattern2 non dimi “uguale al pattern1, ma con il minimo…” altrimenti si aumenta la confusione. Ripeti, magari le stesse cose, anche per gli altri pattern variando le cose che sono diverse e tienimeli ben distinti su paragrafi diversi, esempio:
Pattern1: chiusura > apertura, range superiore a quello della camdela precedente, ecc…
Pattern2: chiusura > apertura, apertura < massimo precedente, ecc…
Pattern3: …..
Grazie, così avrò più chiare le idee.
Grazie a te e scusa la mia poca esperienza nel fornire le indicazioni :
—————————————————————————————————————————–
pattern1
buy
chiusura : deve avere il minimo < al minimo della candela precedente
pattern in chiusura sempre rialzista,candela precedente sempre ribassista
sell
chiusura: deve avere sempre il massimo > del massimo della candela precedente
pattern in chiusura sempre ribassista,candela precedente sempre rialzista
pattern 2
buy
chiusura : sempre il minimo > del minimo della candela precedente,sempre il massimo > al massimo della candela precedente
pattern in chiusura sempre rialzista,candela precedente sempre ribassista,le candele precedenti ribassiste sempre maggiore di 1
sell
chiusura : sempre il massimo < del massimo della candela precedente,sempre il minimo < al minimo della candela precedente
pattern in chiususra sempre ribassista,candela precedente sempre rialzista,le candele precedenti rialziste sempre maggiore di 1
pattern 3
buy
chiusura : deve avere il minimo < al minimo della candela precedente
pattern in chiusura sempre rialzista,candela precedente sempre ribassista
sell
chiusura: deve avere sempre il massimo > del massimo della candela precedente
pattern in chiusura sempre ribassista,candela precedente sempre rialzista
grazie!!
pattern 2
buy chiusura : sempre il minimo > del minimo della candela precedente,sempre il massimo > al massimo della candela precedente pattern in chiusura sempre rialzista,candela precedente sempre ribassista,le candele precedenti ribassiste sempre maggiore di 1
sell chiusura : sempre il massimo < del massimo della candela precedente,sempre il minimo < al minimo della candela precedente pattern in chiususra sempre ribassista,candela precedente sempre rialzista,le candele precedenti rialziste sempre maggiore di 1
Cosa intendi per SEMPRE MAGGIORE DI 1, che deve esserci più di una candela dello stesso segno?
si,
maggiore di 1 dello stesso segno
grazie!
Quindi nel PATTAERN 2, per i BUY (opposto per i SELL):
riepilogando il Pattern2, la candela rialzista deve SEMPRE essere preceduta da almeno 3 candele ribassiste, va bene?
Quindi nel PATTAERN 2, per i BUY (opposto per i SELL):
riepilogando il Pattern2, la candela rialzista deve SEMPRE essere preceduta da almeno 3 candele ribassiste, va bene?
de sempre essere preceduta da almeno 2 candele ribassiste – UNICA MODIFICA RISPETTO A QUELLO CHE HAI SCRITTO
Ho modificato i 3 pattern della versione 2.0 pubblicata da Gianluca Albino e lìho chiamata 3.0.
La posto per il copia e incolla ed allego anche il file per l’importazione.
defparam cumulateorders = false
ActivatePattern1 = 1//activate or not the 1st pattern (0=false) -> PINBAR PATTERN
ActivatePattern2 = 1//activate or not the 2nd pattern (0=false) -> SECOND PATTERN
ActivatePattern3 = 1 //activate or not the 3rd pattern (0=false) -> THIRD PATTERN
MAtype = 1 //0=SMA ; 1=EMA
MAperiod = 21 //Moving average period
MAprice = close //MA price (close,high,low,open)
MAdifference = 0 //points difference from moving average and the pinbar (0=disable)
CandleCount = 3//5//candles count above/below Moving Average
MinimoMassimoDecrescente = 0 //minimum candles to increase or decrease before pattern 1,2 or 3
MaxStop = 50//30//maximum stoploss value in points15
MinStop = 8//minimum stoploss value in points
TimeStart = 080000 //time to start the strategy
TimeEnd = 150000 //time to end the strategy
MaxTradesPerDay = 5 //max quantity of trades each day
BarsExpiration = 2 //how much bars to wait to expire pending orders
cc = CCI[20]
targetplong = (cc < 20)
targetpshort = (cc > -20)
///filtro operazioni in perdita//
stoch = Stochastic[8,3](close)
short1 = stoch > 21
short2 = stoch < 40
/////////////////
// Position size module, 2 is the default. Can be adapted to scale with the profits
/////////////////////////////////////////////////////////////////////////
positionsize=2//+2*round((strategyprofit*2)/10000)
maybe= positionperf(1)<0
losses = positionperf(1)<0 and positionperf(2)<0
if losses then
PositionSize = 3//+3*round((strategyprofit*2)/10000)
elsif not losses then
PositionSize = 2//+2*round((strategyprofit*2)/10000)
Endif
if maybe and not losses then
positionsize=3//+3*round((strategyprofit*2)/10000)
endif
if positionperf(1)<0 and positionperf(2)<0 and positionperf(3)<0 then
positionSize=2//+2*round((strategyprofit*2)/10000)
endif
if positionperf(1)>0 and positionperf(2)>0 then
positionsize=1//+1*round((strategyprofit*2)/10000)
endif
if positionperf(1)<0 and positionperf(2)<0 and positionperf(3)<0 and positionperf(4)<0 and positionperf(5)<0 and positionperf(6)<0 then
positionsize=5
endif
if positionperf(1)>0 and positionperf(2)>0 and positionperf(3)>0 and positionperf(4)>0 and positionperf(5)>0 and positionperf(6)>0 then
positionsize=1
endif
// ---
once buylevel=0
once selllevel=0
if longonmarket or barindex-tradeindex(1)<BarsExpiration then
// set buy level @ 0 to avoid new pending order
buylevel = 0
endif
if shortonmarket or barindex-tradeindex(1)<BarsExpiration then
// set sell level @ 0 to avoid new pending order
selllevel = 0
endif
if intradaybarindex = 0 then
tradecount = 0
endif
tcondition = time>=TimeStart and time<TimeEnd
if MAtype=1 then
ma = exponentialaverage[MAperiod](MAprice)
else
ma = average[MAperiod](MAprice)
endif
//Trade count
if onmarket and tradeprice<>savedprice then
tradecount = tradecount+1
savedprice = tradeprice
endif
//Candles count
if close>ma then
above = above+1
below = 0
endif
if close<ma then
above = 0
below = below+1
endif
//Increase/Decrease count
if MinimoMassimoDecrescente>0 then
//lowincrease = summation[MinimoMassimoDecrescente+1](low>low[1])
//highdecrease = summation[MinimoMassimoDecrescente+1](high<high[1])
else
//lowincrease = 1
//highdecrease = 1
endif
//Pin Bar
//body = abs(open-close)>=1*pointsize
if close>open then
//bullishtail = (open-low>=0.33*range)
//bullishnose = (high-close<0.18*range)
//bearishtail = (high-close>=0.33*range)
//bearishnose = (open-low<0.18*range)
else
//bullishtail = (close-low>=0.33*range)
//bullishnose = (high-open<0.18*range)
//bearishtail = (high-open>=0.33*range)
//bearishnose = (close-low<0.18*range)
endif
if ActivatePattern1 then
//buypattern1 = body and bullishtail and bullishnose and highdecrease>=MinimoMassimoDecrescente and low<low[1] and close>open//and low>ma and low[1]>(high+low)/2 //+50%
buypattern1 = low < low[1] AND close > open AND close[1] < open[1]
//sellpattern1 = body and bearishtail and bearishnose and lowincrease>=MinimoMassimoDecrescente and high>high[1] and close<open//and high<ma and high[1]<(high+low)/2 //+50%
sellpattern1 = high > high[1] AND close < open AND close[1] > open[1]
else
buypattern1 = 0
sellpattern1 = 0
endif
//Max Above / Below patterns
if ActivatePattern2 then
//buypattern2 = close>open and summation[2](close[1]<open[1])=2 and high>high[1] and low<low[1] and highdecrease>=MinimoMassimoDecrescente
buypattern2 = low > low[1] AND high > high[1] AND close > open AND (summation[2](close[1] < open[1]) = 2)
//sellpattern2 = close<open and summation[2](close[1]>open[1])=2 and high>high[1] and low<low[1] and lowincrease>=MinimoMassimoDecrescente
sellpattern2 = low < low[1] AND high < high[1] AND close < open AND (summation[2](close[1] > open[1]) = 2)
else
buypattern2 = 0
sellpattern2 = 0
endif
//Pattern 3
if ActivatePattern3 then
//buypattern3 = close>open and summation[2](close[1]<open[1])=2 and high>high[1] and low<low[1] and highdecrease>=MinimoMassimoDecrescente
buypattern3 = low < low[1] AND close > open AND close[1] < open[1]
//sellpattern3 = close<open and summation[2](close[1]>open[1])>=1 and high>high[1] and low>low[1] and lowincrease>=MinimoMassimoDecrescente
sellpattern3 = high > high[1] AND close < open AND close[1] > open[1]
else
buypattern3 = 0
sellpattern3 = 0
endif
//MA difference activate or not
if MAdifference=0 then
buydiff = 1
selldiff = 1
else
buydiff = low-ma>=MAdifference*pointsize
selldiff = ma-high>=MAdifference*pointsize
endif
//long conditions tested
if not longonmarket and (buypattern1 or buypattern2 or buypattern3) and tcondition and tradecount<MaxTradesPerDay and above>=candlecount and buydiff then
savedbarindex = barindex
buylevel = high
stoplossvalue = range
//buySL = low
endif
while not longonmarket and buylevel>0 and barindex<=savedbarindex+BarsExpiration and stoplossvalue<MaxStop*pointsize and stoplossvalue>MinStop*pointsize and not onmarket[1] and barindex>tradeindex(1)+BarsExpiration and tcondition do
buy positionsize share at buylevel stop
wend
//short conditions tested
if not shortonmarket and (sellpattern1 or sellpattern2 or sellpattern3) and tcondition and tradecount<MaxTradesPerDay and below>=candlecount and selldiff then
savedbarindex = barindex
selllevel = low
stoplossvalue = range
//sellSL = high
endif
while not shortonmarket and selllevel>0 and barindex<=savedbarindex+BarsExpiration and stoplossvalue<MaxStop*pointsize and stoplossvalue>MinStop*pointsize and not onmarket[1] and barindex>tradeindex(1)+BarsExpiration and tcondition and short1 and short2 do
sellshort positionsize share at selllevel stop
wend
if longonmarket and targetplong then
sell at market
endif
if shortonmarket and targetpshort then
exitshort at market
endif
////*********************************************************************
//trailing stop function
trailingstart = 50//58 //25 // trailing will start @trailinstart points profit
trailingstep = 10//60 //27// trailing step to move the "stoploss"
//reset the stoploss value
IF NOT ONMARKET THEN
newSL=0
ENDIF
//manage long positions
IF LONGONMARKET THEN
//first move (breakeven)
IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
newSL = tradeprice(1)+trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
newSL = newSL+trailingstep*pipsize
ENDIF
ENDIF
//manage short positions
IF SHORTONMARKET THEN
//first move (breakeven)
IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
newSL = tradeprice(1)-trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
newSL = newSL-trailingstep*pipsize
ENDIF
ENDIF
//stop order to exit the positions
IF newSL>0 THEN
SELL AT newSL STOP
EXITSHORT AT newSL STOP
ENDIF
//************************************************************************
Ho modificato solo i pattern 1,2 e 3. Fammi sapere come va.
Ciao Roberto,
Ti ringrazio e’ devo fare i complimenti a tutti,questo forum è veramente funzionale
Ti terrò aggiornato su tutto
Grazie
Edoardo
Ciao Edo, ciao Roberto, ecco l’andamento in demo della strategia su cui abbiamo lavorato ad inizio anno.
Ormai sono 6 mesi di demo pieno.
[attachment file=”74445″]
Mi fa piacere che stia andando piuttosto bene.
Vedo che fa molte operazioni negative (anche se di poco), cerca di vedere, sul grafico, quando le fa e se hanno qualcosa in comune, in modo da cercare di ridurre le operazioni in perdita.
Modifica TS da condividere
This topic contains 43 replies,
has 3 voices, and was last updated by
robertogozzi
7 years, 10 months ago.
| Forum: | ProOrder: Trading Automatico & Backtesting |
| Language: | Italian |
| Started: | 12/27/2017 |
| Status: | Active |
| Attachments: | 5 files |
The information collected on this form is stored in a computer file by ProRealCode to create and access your ProRealCode profile. This data is kept in a secure database for the duration of the member's membership. They will be kept as long as you use our services and will be automatically deleted after 3 years of inactivity. Your personal data is used to create your private profile on ProRealCode. This data is maintained by SAS ProRealCode, 407 rue Freycinet, 59151 Arleux, France. If you subscribe to our newsletters, your email address is provided to our service provider "MailChimp" located in the United States, with whom we have signed a confidentiality agreement. This company is also compliant with the EU/Swiss Privacy Shield, and the GDPR. For any request for correction or deletion concerning your data, you can directly contact the ProRealCode team by email at privacy@prorealcode.com If you would like to lodge a complaint regarding the use of your personal data, you can contact your data protection supervisory authority.