DTAParticipant
Junior
Buenos días a todos,
Tengo un problema con la validación del código. No puedo enviarlo a ProOrder ya que me sale un error que dice que el código es invalido.
Primero decir que es mi primer código en la vida, pues seguro que tengo fallos básicos para corregir…
Este es el código que me gustaría poder utilizar:
//Epecifications
StopOrderValidation = True
ProfitOrderValidation = True
Year = 2019
Month = 4
Day = 18
Hour = 00
Minute = 55
ContractsValue = 3.4
Direccion = SELLSHORT
pLossValue = 860
pProfitValue = 85
QuitValue = 20190418
//Close market days_for Safty!!!!!!!!
IF (Month = 1 AND Day =1) OR (Month = 5 AND Day = 1) OR (Month = 12 AND (Day = 24 OR Day = 25 OR Day = 26 OR Day = 30 OR Day = 31)) THEN
TradingDay = 0
ELSE
TradingDay = 1
//Automatic trading conditions
If (Currentyear = Year) AND (Currentmonth = Month) AND (CurrentDayOfWeek = Day) AND (CurrentHour = Hour) AND (CurrentMinute = Minute) THEN
StartTradingDay = 1
ELSE
StartTradingDay = 0
//We initialize this variable once at the beginning of the trading system, we chek de conditions of close safty days and time
IF TradingDay = 1 AND StartTradingDay = 1 THEN
Direccion ContractsValue CONTRACTS AT MARKET
//Stop losss by pips
DEFPARM CumulateOrders = StopOrderValidation
SET STOP pLOSS pLossValue
//Target Profit by pips
DEFPARM CumulateOrders = ProfitOrderValidation
SET TARGET pPROFIT pProfitValue
ENDIF
ENDIF
ENDIF
//Stopping a trading system with QUIT
If date > QuitValue THEN
QUIT
ENDIF
La Idea final, es poder tener un código donde yo pueda seleccionar: la fecha y hora de entrada, los contratos que quiero comprar o vender, la dirección BID ASK, los pips de SL y de TP y finalmente, si quiero o no utilizar TP o SL.
Decir que estoy investigando mucho para poder aprender a programar, pero yo solo de momento no me salgo del bucle de donde estoy….
Gracias por avanzado!!!!!
Saludos.
Las líneas 33 y 37 están equivocadas, ¿no sé por qué está utilizando "cumulateorders" de esta manera? ¿Dónde viste eso antes? 🙂 De todos modos, la instrucción defparam no se puede colocar en medio de un código, solo se coloca en la parte superior de este. Si no desea acumular pedidos, agregue esta línea solo en la parte superior del código:
defparam cumulateorders=false
DTAParticipant
Junior
Buenas tardes Nicolas,
Muchas gracias por la corrección de mi código. Ahora he cambiado alguna cosillas y ya funciona.
La verdad es que no entiendo muy bien el funcionamiento del “cumulateorders”… pensaba que me serviría para activar o desactivar código. Por esta razón estaba encima del código de Stop loss y del Target profit. Hay veces que no quiero profit y pensaba que me ayudaría a deshabilitarlo o habilitarlo según si arriba escribía un true o un false.
Así ha quedado finalmente el código que me funciona:
Defparam Cumulateorders = false
//Epecifications of my control Program
//Programed Date
YearParameter = 2019
MonthParameter = 4
DayParameter = 18
//Programed Schedule
HourParameter = 00
MinuteParameter = 55
//Programed Contracts
ContractsValue = 3.4
//Gain and Losses
pLossValue = 860
pProfitValue = 85
//Time to Leave
QuitValue = 20190418
//Close market days_for Safty!!!!!!!!
IF (Month = 1 AND Day =1) OR (Month = 5 AND Day = 1) OR (Month = 12 AND (Day = 24 OR Day = 25 OR Day = 26 OR Day = 30 OR Day = 31)) THEN
TradingDay = 0
ELSE
TradingDay = 1
//Automatic trading conditions
If (Currentyear = YearParameter) AND (Currentmonth = MonthParameter) AND (CurrentDayOfWeek = DayParameter) AND (CurrentHour = HourParameter) AND (CurrentMinute = MinuteParameter) THEN
StartTradingDay = 1
ELSE
StartTradingDay = 0
//We initialize this variable once at the beginning of the trading system, we chek de conditions of close safty days and time
IF TradingDay = 1 AND StartTradingDay = 1 THEN
SELLSHORT ContractsValue CONTRACTS AT MARKET
//Stop losss by pips
SET STOP pLOSS pLossValue
//Target Profit by pips
SET TARGET pPROFIT pProfitValue
ENDIF
ENDIF
ENDIF
//Stopping a trading system with QUIT
If date > QuitValue THEN
QUIT
ENDIF
Una pregunta Nicolas, En principio el código que tengo ahora solo se ejecutara una vez, verdad? No me gustaría ver que durante el minuto que tengo programada la entrada, se ejecutara 60 veces.. (los 60 segundos).
Un abrazo y muchas gracias otra vez por toda tu ayuda y conocimiento.
Si inicia la estrategia en un período de tiempo de 1 minuto, el código se leerá solo al cierre de la vela de 1 minuto, por lo tanto, solo puede tener 1 pedido en cada vela, pero dependiendo de sus condiciones, obviamente. Cumulateorders se utiliza para permitir que la estrategia agregue más pedidos en el mercado que solo uno a la vez.
DTAParticipant
Junior
Muchas gracias por la respuesta.
Un saludo!
DTAParticipant
Junior
Buenos días.
Hoy he probado el código en mi cuenta demo, y no me funciona. He podido cargar el código hasta el ProOrder Auto Trading, he puesto el sistema en RUNING (adjunto imagen de como se ha quedado), y no ha entrado en corto…
¿Tengo alguna condición mal hecha en mi código? La idea principal, es poder dejarlo en Running y que él solito entre la operativa según día y hora programada (parte superior del código).
En fin, toda ayuda será bien recibida.
Este es exactamente el código que he cargado en ProOrder:
Defparam Cumulateorders = false
//Epecifications of my control Program
//Programed Date
YearParameter = 2019
MonthParameter = 4
DayParameter = 22
//Programed Schedule
HourParameter = 08
MinuteParameter = 40
//Programed Contracts
ContractsValue = 1
//Gain and Losses
pLossValue = 135
pProfitValue = 30
//Time to Leave
QuitValue = 20190423
//Close market days_for Safty!!!!!!!!
IF (Month = 1 AND Day =1) OR (Month = 5 AND Day = 1) OR (Month = 12 AND (Day = 24 OR Day = 25 OR Day = 26 OR Day = 30 OR Day = 31)) THEN
TradingDay = 0
ELSE
TradingDay = 1
//Automatic trading conditions
If (Currentyear = YearParameter) AND (Currentmonth = MonthParameter) AND (CurrentDayOfWeek = DayParameter) AND (CurrentHour = HourParameter) AND (CurrentMinute = MinuteParameter) THEN
StartTradingDay = 1
ELSE
StartTradingDay = 0
//We initialize this variable once at the beginning of the trading system, we chek de conditions of close safty days and time
IF TradingDay = 1 AND StartTradingDay = 1 THEN
SELLSHORT ContractsValue CONTRACTS AT MARKET
//Stop losss by pips
SET STOP pLOSS pLossValue
//Target Profit by pips
SET TARGET pPROFIT pProfitValue
ENDIF
ENDIF
ENDIF
//Stopping a trading system with QUIT
If date > QuitValue THEN
QUIT
ENDIF
Un saludo!! Y gracias!!!
DTAParticipant
Junior
Buenas tardes a todos,
Por favor, alguien podría echarle un ojo al mensaje que está encima de este!! Es importante ya que no puedo entender que es lo que me falta para que se ejecute el código según las fechas ..
Muchas gracias y perdonad las molestias.
CurrentDayOfWeek devuelve un número entre 0 o 1 y 7, no es el día del mes. Debe ver todas las instrucciones de fecha posibles aquí: https://www.prorealcode.com/documentation/category/dateandtime/
DTAParticipant
Junior
Hola Nicolás,
Gracias por tu respuesta. He cambiado lo que me dices y todavía no funciona. Adjunto imagen de cómo queda el ProOrder con el sistema en “Running”. He marcado en rojo la parte donde se puede ver que no estamos dentro de mercado (CADNOK).
Este es el código actual:
Defparam Cumulateorders = false
//Epecifications of my control Program
//Programed Date
YearParameter = 2019
MonthParameter = 4
DayParameter = 3
//Programed Schedule
HourParameter = 8
MinuteParameter = 40
//Programed Contracts
ContractsValue = 1
//Gain and Losses
pLossValue = 135
pProfitValue = 30
//Time to Leave
QuitValue = 20190425
//Close market days_for Safty!!!!!!!!
IF (Month = 1 AND Day =1) OR (Month = 5 AND Day = 1) OR (Month = 12 AND (Day = 24 OR Day = 25 OR Day = 26 OR Day = 30 OR Day = 31)) THEN
TradingDay = 0
ELSE
TradingDay = 1
//Automatic trading conditions
If (Currentyear = YearParameter) AND (Currentmonth = MonthParameter) AND (CurrentDayOfWeek = DayParameter) AND (CurrentHour = HourParameter) AND (CurrentMinute = MinuteParameter) THEN
StartTradingDay = 1
ELSE
StartTradingDay = 0
//We initialize this variable once at the beginning of the trading system, we chek de conditions of close safty days and time
IF TradingDay = 1 AND StartTradingDay = 1 THEN
SELLSHORT ContractsValue CONTRACTS AT MARKET
//Stop losss by pips
SET STOP pLOSS pLossValue
//Target Profit by pips
SET TARGET pPROFIT pProfitValue
ENDIF
ENDIF
ENDIF
//Stopping a trading system with QUIT
If date > QuitValue THEN
QUIT
ENDIF
Si tienes alguna idea, de por qué no funciona el código, te lo agradecería, de todas formas gracias por tu ayuda hasta ahora.
(debajo está la imagen de como se queda la orden en ProOrder)
Saludos.