-
28-09-14, 09:05 #11
- Data Registrazione
- Apr 2012
- Messaggi
- 43
Ciao Smash, funziona. Ma parzialmente
L'avevo provato ma interpretato male, e ti spiego:
Il test appare come un Crossover che, appunto come dici, si rovescia sempre.
Il fatto é che non sfrutta i trend. Perché mi taglia tutto anche l'essenza stessa dello script, che sarebbe il [ f+30<(a+b+c+d+e/5)] od anche il fatto che dopo il Trailing Percent e Trailing Stop (sinonimo di trend) s'interrompano.
Devo investigare ancora ma ti ringrazio. Se mi permetti ti richiamo x ulteriori sviluppi.
Saluti.
ArmandoUltima modifica di armando; 28-09-14 alle 10:45
-
28-09-14, 10:35 #12
- Data Registrazione
- Jan 2008
- Messaggi
- 1,010
-
28-09-14, 12:30 #13
Scusa Armando, su quale sottostante lo stai provando ?
La variabile costante 30 presente nella condizione buy/sell:
che cosa rappresenta ?1f-
30
>(a+b+c+d+e/
5
)
vorrei studiarlo ma dovrei adattare quella costante al sottostante che intendo caricare altrimenti non ho segnali.
grazie
ApoUltima modifica di Apocalips; 28-09-14 alle 12:35
....non si desidera ciò che è facile ottenere (Ovidio)....
-
28-09-14, 17:07 #14
- Data Registrazione
- Feb 2012
- Località
- Pisa
- Messaggi
- 351
-
28-09-14, 17:13 #15
- Data Registrazione
- Feb 2012
- Località
- Pisa
- Messaggi
- 351
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!
-
29-09-14, 08:53 #16
- Data Registrazione
- Apr 2012
- Messaggi
- 43
-
29-09-14, 09:00 #17
- Data Registrazione
- Apr 2012
- Messaggi
- 43
-
30-09-14, 22:07 #18
- Data Registrazione
- Feb 2012
- Località
- Pisa
- Messaggi
- 351
OK, allora proviamolo in questo altro modo:
Buy Script
12345678910111213141516171819202122232425262728293031323334INPUTS
:
@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
123456789101112131415161718192021222324SET
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
123SET
a =
MovingAverage
(
@price, 6, @matype)
SET
g =
LinearRegressionForecast
(
@price, 5)
CROSSOVER
(a, g)
ExitShort Script
Due precisazioni:123SET
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!
-
01-10-14, 08:59 #19
- Data Registrazione
- Apr 2012
- Messaggi
- 43
OK Smash , lo provo oggi stesso.
Armando
-
01-10-14, 09:13 #20
- Data Registrazione
- Apr 2012
- Messaggi
- 43
Sei forte. Fà esattamente quanto volevo!!! Grazie mille Smash
Armando