COMPRA STOP EN PIVOTS
Forums › ProRealTime foro Español › Soporte ProOrder › COMPRA STOP EN PIVOTS
- This topic has 4 replies, 2 voices, and was last updated 4 years ago by Albert0769.
-
-
06/01/2020 at 4:28 PM #134066
Buenas tardes:
Gracias a quien me pueda ayudar con la programación de esta estrategia.
Se trata de activar un orden de compra STOP, 25 puntos por debajo de un nivel Pivot de entrada.
Yo he programado este código adjunto, pero evidentemente no funciona y no activa la orden de compra STOP cuando el Precio cruza el nivel de activación, en ese nivel 25 puntos por debajo del nivel Pivot de entrada.
Gracias por la ayuda tan buena, que me podáis prestar a este respecto.
06/01/2020 at 5:41 PM #13407712345678910111213141516171819202122232425262728293031323334353637383940DEFPARAM PRELOADBARS = 10000DEFPARAM CUMULATEORDERS = FalsePIV = 25282.4*PointSizePIV25 = (PIV-25)*PointSizePRECIO = CloseINIBAR = 0IF PRECIO CROSSES OVER PIV25 THENINIBAR = BarindexINI = 1ENDIFIF NOT ONMARKET AND INI = 1 AND Barindex - INIBAR >= 0 THENBUY 1 CONTRACT AT PIV STOPENDIFstartBreakeven = 25PointsToKeep = 0IF NOT ONMARKET THENbreakevenLevel = 0ENDIFIF LONGONMARKET AND Close-TradePrice(1) >= startBreakeven*Pointsize THENbreakevenLevel = Tradeprice(1)+PointsToKeep*PointsizeENDIFIF breakevenLevel > 0 THENSELL AT breakevenLevel STOPENDIF//// Stops y objetivos:SET STOP LOSS 150SET TARGET pPROFIT 30006/01/2020 at 5:55 PM #134082COMPRA PIVOTSS12345678910111213141516171819202122232425262728293031323334DEFPARAM PRELOADBARS = 10000DEFPARAM CUMULATEORDERS = FalsePIV = 25282.4PIV25 = (PIV-25)PRECIO = CloseIF PRECIO CROSSES OVER PIV25 THENBUY 1 CONTRACT AT PIV STOPENDIFstartBreakeven = 25PointsToKeep = 0IF NOT ONMARKET THENbreakevenLevel = 0ENDIFIF LONGONMARKET AND Close-TradePrice(1) >= startBreakeven*Pointsize THENbreakevenLevel = Tradeprice(1)+PointsToKeep*PointsizeENDIFIF breakevenLevel > 0 THENSELL AT breakevenLevel STOPENDIF//// Stops y objetivos:SET STOP LOSS 150SET TARGET pPROFIT 30006/02/2020 at 12:10 PM #134192El pedido de DETENER solo dura 1 barra, por lo que debe configurarlo en cada lectura de código y eso no es lo que está haciendo, solo lo coloca una vez cuando se produce el cruce. Pruebe con este código modificado:
12345678910111213141516171819202122232425262728293031323334353637DEFPARAM PRELOADBARS = 10000DEFPARAM CUMULATEORDERS = FalsePIV = 25282.4PIV25 = (PIV-25)PRECIO = CloseIF PRECIO CROSSES OVER PIV25 THENvalid = 1ENDIFif onmarket thenvalid = 0endifif not onmarket and valid = 1 thenBUY 1 CONTRACT AT PIV STOPendifstartBreakeven = 25PointsToKeep = 0IF NOT ONMARKET THENbreakevenLevel = 0ENDIFIF LONGONMARKET AND Close-TradePrice(1) >= startBreakeven*Pointsize THENbreakevenLevel = Tradeprice(1)+PointsToKeep*PointsizeENDIFIF breakevenLevel > 0 THENSELL AT breakevenLevel STOPENDIF//// Stops y objetivos:SET STOP LOSS 150SET TARGET pPROFIT 30006/07/2020 at 11:34 PM #135094Buenos días Nicolas:
Primero de todo darte las gracias como siempre en tus respuestas tan buenas y tan rápidas.
Siguiendo con el código que me has pasado, he diseñado estas dos nuevas estrategias, pero no sé por qué no funcionan bien.
Por favor Nicolás puedes revisar estos dos nuevos códigos y decirme donde está el error.
Como siempre muchas gracias por tu ayuda nuevamente.
Saludos,
ALBERT
COMPRA PIVOTS DIARIO123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157DEFPARAM PRELOADBARS = 10000DEFPARAM CUMULATEORDERS = FalseINTRABAR = IntradaybarindexPRECIO = CloseIF INTRABAR = 59 THENMAXD = Highest[1440](High)MIND = Lowest[1440](Low)ENDIFIF INTRABAR = 59 THENPIV = (MAXD+MIND+PRECIO)/3RD1 = (2*PIV)-MINDSD1 = (2*PIV)-MAXDRD2 = PIV+MAXD-MINDSD2 = PIV-MAXD+MINDRD3 = MAXD+(2*(PIV-MIND))SD3 = MIND-(2*(MAXD-PIV))ENDIFV = 50//////////////////// RD3 ////////////////////RD325 = (RD3-V)IF PRECIO CROSSES OVER RD325 THENvalid13 = 1ENDIFif longonmarket thenvalid13 = 0endifif not longonmarket and valid13 = 1 thenBUY 1 CONTRACT AT RD3 STOPendif//////////////////// RD2 //////////////////////RD225 = (RD2-V)IF PRECIO CROSSES OVER RD225 THENvalid12 = 1ENDIFif onmarket thenvalid12 = 0endifif not onmarket and valid12 = 1 thenBUY 1 CONTRACT AT RD2 STOPendif/////////////////// RD1 ///////////////////////RD125 = (RD1-V)IF PRECIO CROSSES OVER RD125 THENvalid11 = 1ENDIFif onmarket thenvalid11 = 0endifif not onmarket and valid11 = 1 thenBUY 1 CONTRACT AT RD1 STOPendif///////////////////// PIV ////////////////////PIV25 = (PIV-V)IF PRECIO CROSSES OVER PIV25 THENvalid0 = 1ENDIFif onmarket thenvalid0 = 0endifif not onmarket and valid0 = 1 thenBUY 1 CONTRACT AT PIV STOPendif/////////////////////// SD1 ////////////////////SD125 = (SD1-V)IF PRECIO CROSSES OVER SD125 THENvalid111 = 1ENDIFif onmarket thenvalid111 = 0endifif not onmarket and valid111 = 1 thenBUY 1 CONTRACT AT SD1 STOPendif/////////////////////// SD2 ///////////////////SD225 = (SD2-V)IF PRECIO CROSSES OVER SD225 THENvalid112 = 1ENDIFif onmarket thenvalid112 = 0endifif not onmarket and valid112 = 1 thenBUY 1 CONTRACT AT SD2 STOPendif///////////////////////// SD3 ///////////////////SD325 = (SD3-V)IF PRECIO CROSSES OVER SD325 THENvalid113 = 1ENDIFif onmarket thenvalid113 = 0endifif not onmarket and valid113 = 1 thenBUY 1 CONTRACT AT SD3 STOPendifstartBreakeven = 25PointsToKeep = 0IF NOT ONMARKET THENbreakevenLevel = 0ENDIFIF LONGONMARKET AND Close-TradePrice(1) >= startBreakeven*Pointsize THENbreakevenLevel = Tradeprice(1)+PointsToKeep*PointsizeENDIFIF breakevenLevel > 0 THENSELL AT breakevenLevel STOPENDIF//// Stops y objetivos:SET STOP LOSS 50SET TARGET pPROFIT 50VENTA PIVOTS DIARIO123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157DEFPARAM PRELOADBARS = 10000DEFPARAM CUMULATEORDERS = FalseINTRABAR = IntradaybarindexPRECIO = CloseIF INTRABAR = 59 THENMAXD = Highest[1440](High)MIND = Lowest[1440](Low)ENDIFIF INTRABAR = 59 THENPIV = (MAXD+MIND+PRECIO)/3RD1 = (2*PIV)-MINDSD1 = (2*PIV)-MAXDRD2 = PIV+MAXD-MINDSD2 = PIV-MAXD+MINDRD3 = MAXD+(2*(PIV-MIND))SD3 = MIND-(2*(MAXD-PIV))ENDIFV = 50//////////////////// RD3 ////////////////////RD325 = (RD3+V)IF PRECIO CROSSES UNDER RD325 THENvalid13 = 1ENDIFif onmarket thenvalid13 = 0endifif not onmarket and valid13 = 1 thenSELLSHORT 1 CONTRACT AT RD3 STOPendif////////////////////// RD2 /////////////////RD225 = (RD2+V)IF PRECIO CROSSES UNDER RD225 THENvalid12 = 1ENDIFif onmarket thenvalid12 = 0endifif not onmarket and valid12 = 1 thenSELLSHORT 1 CONTRACT AT RD2 STOPendif//////////////////// RD1 ///////////////////RD125 = (RD1+V)IF PRECIO CROSSES UNDER RD125 THENvalid11 = 1ENDIFif onmarket thenvalid11 = 0endifif not onmarket and valid11 = 1 thenSELLSHORT 1 CONTRACT AT RD1 STOPendif//////////////////// PIV //////////////////PIV25 = (PIV+V)IF PRECIO CROSSES UNDER PIV25 THENvalid0 = 1ENDIFif onmarket thenvalid0 = 0endifif not onmarket and valid0 = 1 thenSELLSHORT 1 CONTRACT AT PIV STOPendif/////////////////////// SD1 //////////////////SD125 = (SD1+V)IF PRECIO CROSSES UNDER SD125 THENvalid111 = 1ENDIFif onmarket thenvalid111 = 0endifif not onmarket and valid111 = 1 thenSELLSHORT 1 CONTRACT AT SD1 STOPendif////////////////////// SD2 ////////////////////SD225 = (SD2+V)IF PRECIO CROSSES UNDER SD225 THENvalid112 = 1ENDIFif onmarket thenvalid112 = 0endifif not onmarket and valid112 = 1 thenSELLSHORT 1 CONTRACT AT SD2 STOPendif///////////////////// SD3 ///////////////////////SD325 = (SD3+V)IF PRECIO CROSSES UNDER SD325 THENvalid113 = 1ENDIFif onmarket thenvalid113 = 0endifif not onmarket and valid113 = 1 thenSELLSHORT 1 CONTRACT AT SD3 STOPendifstartBreakeven = 25PointsToKeep = 0IF NOT ONMARKET THENbreakevenLevel = 0ENDIFIF SHORTONMARKET AND TradePrice(1)-Close >= startBreakeven*Pointsize THENbreakevenLevel = TradePrice(1)-PointsToKeep*PointsizeENDIFIF breakevenLevel > 0 THENEXITSHORT AT breakevenlevel STOPENDIF//// Stops y objetivos:SET STOP pLOSS 50SET TARGET pPROFIT 50 -
AuthorPosts
Find exclusive trading pro-tools on