Chiudere definitivamente una strateggia
Forums › ProRealTime forum Italiano › Supporto ProOrder › Chiudere definitivamente una strateggia
- This topic has 13 replies, 3 voices, and was last updated 1 year ago by Ciccarelli Franco.
-
-
10/27/2023 at 9:34 AM #222973
Che istruzioni dovrei usare per chiudere definitivamente una strategia al raggiungimento di un livello di prezzo?
Grazie
10/27/2023 at 9:42 AM #222974QUIT, questa è l’istruzione per chiudere una strategia ed interromperne l’autotrading.
Se poi volessi riattivarla basta la la esegui nuovamente in autotrading.
10/27/2023 at 9:44 AM #22297510/27/2023 at 10:35 AM #222977Grazie per le risposte, mi andrebbe bene l’esempio 1, ma invece dell’ora vorrei mettere il prezzo. Come devo fare?
10/27/2023 at 10:49 AM #222982Metti il prezzo che desideri al posto dell’ora:
1IF ShortOnMarket AND PrezzoUscita = XXXXX THEN10/27/2023 at 2:36 PM #222987Vale anche per la versione short del codice?
Grazie
10/27/2023 at 2:55 PM #222988Non mi funziona, allego versione long e short, ditemi per cortesia se le istruzioni da me messe sono giuste.
Grazie
DEFPARAM CumulateOrders = FALSE
TradingTime=Time>=080000and Time<=180000// LONG
indicator1 = Volume
indicator2 = ExponentialAverage[14](Volume)
c1 = (indicator1 >= indicator2)IF ( close > open and close[1] > open[1] ) and c1 and TradingTime Then
BUY 1 CONTRACTS AT MARKET
endif
PrezzoUscita= 1.3900
IF ShortOnMarket AND PrezzoUscita then
QUITSET STOP LOSS l*AverageTrueRange[10](close)
SET TARGET PROFIT p*AverageTrueRange[12](close)
ENDIf//trailing stop
trailingstop = tra//resetting variables when no trades are on market
if not onmarket then
MAXPRICE = 0
MINPRICE = close
priceexit = 0
endif//case SHORT order
if shortonmarket then
MINPRICE = MIN(MINPRICE,close) //saving the MFE of the current trade
if tradeprice(1)-MINPRICE>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
priceexit = MINPRICE+trailingstop*pointsize //set the exit price at the MFE + trailing stop price level
endif
endif//case LONG order
if longonmarket then
MAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current trade
if MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
priceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE – trailing stop price level
endif
endif//exit on trailing stop price levels
if onmarket and priceexit>0 then
EXITSHORT AT priceexit STOP
SELL AT priceexit STOP
endifDEFPARAM CumulateOrders = False
TradingTime=Time>=090000and Time<=210000
// SHORT
indicator1 = Volume
indicator2 = ExponentialAverage[14](Volume)
c1 = (indicator1 >= indicator2)IF ( ( close < open and close[1] < open[1] )) and c1 and TradingTime THEN
SELLSHORT 1 CONTRACTS AT MARKET
endif
PrezzoUscita= 1.3500
IF shortOnMarket AND PrezzoUscita then
QUITSET STOP LOSS l*AverageTrueRange[10](close)
SET TARGET PROFIT p*AverageTrueRange[12](close)ENDIF
//trailing stop
trailingstop = tra//resetting variables when no trades are on market
if not onmarket then
MAXPRICE = 0
MINPRICE = close
priceexit = 0
endif//case SHORT order
if shortonmarket then
MINPRICE = MIN(MINPRICE,close) //saving the MFE of the current trade
if tradeprice(1)-MINPRICE>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
priceexit = MINPRICE+trailingstop*pointsize //set the exit price at the MFE + trailing stop price level
endif
endif//case LONG order
if longonmarket then
MAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current trade
if MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
priceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE – trailing stop price level
endif
endif//exit on trailing stop price levels
if onmarket and priceexit>0 then
EXITSHORT AT priceexit STOP
SELL AT priceexit STOP
endif10/27/2023 at 3:46 PM #222992Manca il confronto, con cosa vuoi confrontare il prezzo di uscita? Immagino con CLOSE:
123IF shortOnMarket AND close = PrezzoUscita thenQUITENDIFvale anche per le operazioni LONG.
10/28/2023 at 9:55 AM #222996Grazie sempre gentile.
10/28/2023 at 5:49 PM #223016Scusami Roberto, contrariamente a quando credevo non funziona , praticamente nei backtest che eseguo, ultimamente sull’argento TF 1 ora , le entrate e le uscite sono determinate dalle date ma non dal valore che inserisco.
Ti allego i due codici che uso per vedere dove sbaglio.
Versione long
DEFPARAM CumulateOrders = FALSE
TradingTime=Time>=080000and Time<=180000// LONG
indicator1 = Volume
indicator2 = ExponentialAverage[14](Volume)
c1 = (indicator1 >= indicator2)IF ( close > open and close[1] > open[1] ) and c1 and TradingTime Then
BUY 1 CONTRACTS AT MARKET
endif
PrezzoUscita =2400
IF shortOnMarket AND close = PrezzoUscita then
QUIT
endifSET STOP LOSS l*AverageTrueRange[10](close)
SET TARGET PROFIT p*AverageTrueRange[12](close)//trailing stop
trailingstop = tra//resetting variables when no trades are on market
if not onmarket then
MAXPRICE = 0
MINPRICE = close
priceexit = 0
endif//case SHORT order
if shortonmarket then
MINPRICE = MIN(MINPRICE,close) //saving the MFE of the current trade
if tradeprice(1)-MINPRICE>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
priceexit = MINPRICE+trailingstop*pointsize //set the exit price at the MFE + trailing stop price level
endif
endif//case LONG order
if longonmarket then
MAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current trade
if MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
priceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE – trailing stop price level
endif
endif//exit on trailing stop price levels
if onmarket and priceexit>0 then
EXITSHORT AT priceexit STOP
SELL AT priceexit STOP
endifVersione short
DEFPARAM CumulateOrders = False
TradingTime=Time>=090000and Time<=210000
// SHORT
indicator1 = Volume
indicator2 = ExponentialAverage[14](Volume)
c1 = (indicator1 >= indicator2)IF ( ( close < open and close[1] < open[1] )) and c1 and TradingTime THEN
SELLSHORT 1 CONTRACTS AT MARKET
endif
PrezzoUscita= 2150
IF shortOnMarket AND close = PrezzoUscita then
QUITSET STOP LOSS l*AverageTrueRange[10](close)
SET TARGET PROFIT p*AverageTrueRange[12](close)ENDIF
//trailing stop
trailingstop = tra//resetting variables when no trades are on market
if not onmarket then
MAXPRICE = 0
MINPRICE = close
priceexit = 0
endif//case SHORT order
if shortonmarket then
MINPRICE = MIN(MINPRICE,close) //saving the MFE of the current trade
if tradeprice(1)-MINPRICE>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
priceexit = MINPRICE+trailingstop*pointsize //set the exit price at the MFE + trailing stop price level
endif
endif//case LONG order
if longonmarket then
MAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current trade
if MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
priceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE – trailing stop price level
endif
endif//exit on trailing stop price levels
if onmarket and priceexit>0 then
EXITSHORT AT priceexit STOP
SELL AT priceexit STOP
endif11/02/2023 at 9:06 AM #223138Roberto, forse non lo ritieni interessante?
11/03/2023 at 4:51 PM #223180Nella versione LONG devi usare LongOnMarket.
Questa LONG sul DAX funziona, con il livello che ho indicato:
12345678910111213141516//Versione longDEFPARAM CumulateOrders = FALSETradingTime=Time>=080000 and Time<=180000// LONGindicator1 = Volumeindicator2 = ExponentialAverage[14](Volume)c1 = (indicator1 >= indicator2)IF ( close > open and close[1] > open[1] ) and c1 and TradingTime ThenBUY 1 CONTRACTS AT MARKETendifPrezzoUscita = 15400IF LongOnMarket AND close = PrezzoUscita thenQUITendifSET STOP LOSS 10*AverageTrueRange[10](close)SET TARGET PROFIT 10*AverageTrueRange[12](close)anche questa versione SHORT funziona:
12345678910111213141516//Versione shortDEFPARAM CumulateOrders = FalseTradingTime=Time>=090000and Time<=210000// SHORTindicator1 = Volumeindicator2 = ExponentialAverage[14](Volume)c1 = (indicator1 >= indicator2)IF ( ( close < open and close[1] < open[1] )) and c1 and TradingTime THENSELLSHORT 1 CONTRACTS AT MARKETendifPrezzoUscita = 15400IF shortOnMarket AND close = PrezzoUscita thenQUITENDIFSET STOP LOSS 10*AverageTrueRange[10](close)SET TARGET PROFIT 10*AverageTrueRange[12](close)Se vuoi puoi aggiungere il trailing stop, ma con un valore alto, altrimenti entra in funzione quello e difficilmente esce con QUIT. Io ho provato con TRA=100.
11/04/2023 at 11:24 AM #223197Si funziona , ma esce esattamente a quel prezzo, io invece vorrei che uscisse da quel prezzo in su o in giù per la variante short.
Grazie
11/04/2023 at 12:09 PM #223198Risolto grazie.
-
AuthorPosts
Find exclusive trading pro-tools on