Interruzione script e attesa reverse nel caso di intervento del exitLong o exitShort
Collapse
X
-
Sì, in effetti così come l\'avevo scritto, oltre che dopo l\'uscita in Exit Long / Short, il sistema si ferma anche dopo l\'uscita in Trailing Stop.
Se magari volevi che questo non si verificasse, lo si potrebbe eventualmente riscrivere in un altro modo .....
E richiamami tranquillamente, senza problemi!
Smash, se puoi riscriverlo ....... risolveresti al meglio l\'uscita dai trend di questa strategia (da aggiungere a quanto ho detto ad Apo stamane)
Grazie x l\'assiduo aiuto.
ArmandoLast edited by armando; 29-09-14, 21:02.Comment
-
OK, allora proviamolo in questo altro modo:
Buy Script
Codice:INPUTS: @Gap(30) INPUTS: @periods(14) , @price(CLOSE), @matype(EXPONENTIAL), INPUTS: @trailAmount(100),@trailPercent(10), @stopLoss(400) SET TRAILING_STOP = @trailAmount SET TRAILING_PERCENT = @trailPercent SET STOP_LOSS = @stopLoss SET Gap = @Gap SET a = MovingAverage(@price, 6, @matype) SET b = MovingAverage(@price, 10, @matype) SET c = MovingAverage(@price, 14, @matype) SET d = MovingAverage(@price, 20, @matype) SET e = MovingAverage(@price, 28, @matype) SET f = LinearRegressionForecast(@price, 8) SET g = LinearRegressionForecast(@price, 5) SET BuyCondition = f - Gap > ( a + b + c + d + e / 5) SET SellCondition = f + Gap < ( a + b + c + d + e / 5) SET EntryCondition = BuyCondition - SellCondition SET LastEntry = CHANGEIF(EntryCondition <> 0, EntryCondition) SET LastEntryLong = IF(LastEntry = 1, 1, 0) SET ExitLongCondition = CROSSOVER(a, g) * LastEntryLong SET LongExited = CHANGEIF(LastEntryLong = ExitLongCondition, LastEntryLong) BuyCondition AND NOT LongExited
Sell Script
Codice:SET Gap = @Gap SET a = MovingAverage(@price, 6, @matype) SET b = MovingAverage(@price, 10, @matype) SET c = MovingAverage(@price, 14, @matype) SET d = MovingAverage(@price, 20, @matype) SET e = MovingAverage(@price, 28, @matype) SET f = LinearRegressionForecast(@price, 8) SET g = LinearRegressionForecast(@price, 5) SET BuyCondition = f - Gap > ( a + b + c + d + e / 5) SET SellCondition = f + Gap < ( a + b + c + d + e / 5) SET EntryCondition = BuyCondition - SellCondition SET LastEntry = CHANGEIF(EntryCondition <> 0, EntryCondition) SET LastEntryShort = IF(LastEntry = -1, 1, 0) SET ExitShortCondition = CROSSOVER(g, a) * LastEntryShort SET ShortExited = CHANGEIF(LastEntryShort = ExitShortCondition, LastEntryShort) SellCondition AND NOT ShortExited
ExitLong Script
Codice:SET a = MovingAverage(@price, 6, @matype) SET g = LinearRegressionForecast(@price, 5) CROSSOVER(a, g)
ExitShort Script
Due precisazioni:Codice:SET a = MovingAverage(@price, 6, @matype) SET g = LinearRegressionForecast(@price, 5) CROSSOVER(g, a)
- ho trasformato quel valore di 30 in un parametro di Input, così se ne hai voglia lo potresti anche ottimizzare
- il sistema scritto in questo modo dovrebbe fermarsi in attesa di Reverse quando si verifica la condizione di ExitLong o di ExitShort, ma non necessariamente quando la posizione è stata chiusa realmente per l\'ultima volta in ExitLong o ExitShort, in quanto al verificarsi dell\'ExitLong o dell\'ExitShort poteva essere già stata chiusa prima in TrailingStop senza poi essere stata mai riaperta.
Io comunque non lo complicherei più di così.
Provalo e poi fammi sapere!Comment



Sei forte. Fà esattamente quanto volevo!!! Grazie mille Smash
Comment