Strict Standards: Non-static method JFactory::getUser() should not be called statically in /homepages/34/d227044908/htdocs/traderninja/foro/joomphpbb_engine2.php on line 688

Strict Standards: Non-static method JLoader::import() should not be called statically in /homepages/34/d227044908/htdocs/traderninja/libraries/loader.php on line 186

Strict Standards: Non-static method JFactory::getSession() should not be called statically in /homepages/34/d227044908/htdocs/traderninja/libraries/joomla/factory.php on line 163
traderninja.com • Ver Tema - ¿como definir las horas de entrada y salida del sistema?

Últimos Mensajes

» encriptar estrategia
Magnolia 17-05 11:17

» APLICACIÓN PARA IPAD
meg 15-05 19:36

» Alarma Cruce Medias
gonzalogj 14-05 18:52

» A alguien le interesa mi licencia N...
valencianito12 10-05 16:16

» Alucinante lo de Mirus Futures
Consultor 10-05 13:43

» duda de sistemas en tiempo real
cavendish 09-05 21:05

» Duda cancelar suscripción NinjaTra...
danirles 09-05 09:28

» 2 CONEXIONES
TraderNinja 09-05 02:33

» Skew de Volatilidad en el VIX, una ...
Consultor 07-05 13:50

» Ayuda parte financiera Broker.
Sett 04-05 20:40

» Separador linea vertical sesiones d...
jaialro 03-05 11:59

» Salida al cierre de la vela
cls 29-04 09:50

banner1_TGCG
cuenta_demo  mas_info

¿como definir las horas de entrada y salida del sistema?

Desarrollo de sistemas automáticos de inversión

Re: ¿como definir las horas de entrada y salida del sistema?

Notapor CJS » Vie, 27 Jul 2012, 22:48

Hola Serotonina,

Si no quieres usar estructuras DateTime, una forma muy simple de hacerlo es la siguiente:

Declara las siguientes variables:

private int Inicio1 = 900;
private int Fin1 = 1300;
private int Inicio2 = 1500;
private int Fin2 = 1800


Luego en OnBarUpdate () haces el siguiente ajuste ya que la función ToTime() devuelve un Integer con la siguiente estructura Hmmss :

int HI1 = Inicio1 * 100;
int HF1 = Fin1 * 100;
int HI2 = Inicio2 * 100;
int HF2 = Fin2 * 100;


Ahora ya puedes usarlo como condiciones usando la siguiente sintaxis:

if((ToTime(Time[0])> HI1 && ToTime(Time[0])< HF1) || (ToTime(Time[0])> HI2 && ToTime(Time[0])< HF2) && ….)

Aquí está explicado:

http://www.ninjatrader.com/support/help ... totime.htm

Saludos,
CJS
 
Mensajes: 96
Registrado: Mié, 23 Mar 2011, 10:58

{ SO_SELECT }

Share on Facebook Facebook Share on Twitter Twitter Share on Delicious Delicious

Re: ¿como definir las horas de entrada y salida del sistema?

Notapor serotonina » Lun, 03 Sep 2012, 16:05

Gracias CJS, pero debo ser más tosco de lo q creía pues he copiado lo que me indicas en el código del sistema y no consigo que defina las horas. No sé si podrías especificarlo de manera que lo pueda copiar desde aquí y pegarlo en el código de ninja. Ya te digo que en programación estoy bastante pillao y aunque me estoy comiendo tutorial tras tutorial, aún no controlo el tema.

Gracias por tu aportación.

Un saludo.

serotonina..-
serotonina
 
Mensajes: 28
Registrado: Mar, 23 Ago 2011, 20:36

Re: ¿como definir las horas de entrada y salida del sistema?

Notapor TraderNinja » Mié, 05 Sep 2012, 13:35

Os dejo un ejemplo que acabo de programar... destripando el código podéis ver el funcionamiento. En el ejemplo el sistema compra en el inicio de la sesión y vende en el fin. La hora de entrada y salida se pasa por parámetros (es optimizable, vamos...).

Saludos!
Adjuntos
EjemploHorario.zip
(1.19 KiB) 97 veces
Avatar de Usuario
TraderNinja
Administrador del Sitio
 
Mensajes: 1557
Registrado: Mar, 28 Dic 2010, 12:46

Re: ¿como definir las horas de entrada y salida del sistema?

Notapor xaviss629 » Dom, 10 Feb 2013, 10:18

Hola Chicos,
Creo que lo pongo bien y no me hace ni caso... El horario que le marco no lo respeta para nada.
¿que tengo mal?

/// <summary>
/// Maximos y Minimos
/// </summary>
[Description("Maximos y Minimos")]
public class Contra : Strategy
{
#region Variables
// Wizard generated variables
private int perdida = 1; // Default setting for Perdida
private int objetivo = 1; // Default setting for Objetivo
private int horaInicio = 0; // Default setting for HoraInicio
private int horaFin = 0; // Default setting for HoraFin
private int minutoInicio = 0; // Default setting for MinutoInicio
private int minutoFin = 0; // Default setting for MinutoFin
// User defined variables (add any user defined variables below)
int iniciosesion=0;
int finsesion=0;

#endregion

/// <summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
/// </summary>
protected override void Initialize()
{
SetProfitTarget("", CalculationMode.Ticks, Objetivo);
SetStopLoss("", CalculationMode.Ticks, Perdida, false);

CalculateOnBarClose = true;
iniciosesion=(horaInicio*10000)+(minutoInicio*100);
finsesion=(horaFin*10000)+(minutoFin*100);
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1
if (Close[0] < Open[0])
{
EnterLongStop(DefaultQuantity, High[0], "");
}

// Condition set 2
if (Close[0] > Open[0])
{
EnterShortStop(DefaultQuantity, Low[0], "");
}
{
if(ToTime(Time[0])==iniciosesion) EnterLong();

if(ToTime(Time[0])==finsesion) ExitLong();
}
}

#region Properties
[Description("")]
[GridCategory("Parameters")]
public int Perdida
{
get { return perdida; }
set { perdida = Math.Max(1, value); }
}

[Description("")]
[GridCategory("Parameters")]
public int Objetivo
{
get { return objetivo; }
set { objetivo = Math.Max(1, value); }
}

[Description("")]
[GridCategory("Parameters")]
public int HoraInicio
{
get { return horaInicio; }
set { horaInicio = Math.Max(1, value); }
}

[Description("")]
[GridCategory("Parameters")]
public int HoraFin
{
get { return horaFin; }
set { horaFin = Math.Max(0, value); }
}

[Description("")]
[GridCategory("Parameters")]
public int MinutoInicio
{
get { return minutoInicio; }
set { minutoInicio = Math.Max(0, value); }
}

[Description("")]
[GridCategory("Parameters")]
public int MinutoFin
{
get { return minutoFin; }
set { minutoFin = Math.Max(0, value); }
}
#endregion
}
xaviss629
 
Mensajes: 1
Registrado: Sab, 09 Feb 2013, 20:07

Re: ¿como definir las horas de entrada y salida del sistema?

Notapor TraderNinja » Mié, 13 Feb 2013, 03:39

Tu operativa sólo depende del horario de sesión cuando lo pides:

if(ToTime(Time[0])==iniciosesion) EnterLong();

if(ToTime(Time[0])==finsesion) ExitLong();

En el resto de condicionales entran libremente...

Saludos!
Avatar de Usuario
TraderNinja
Administrador del Sitio
 
Mensajes: 1557
Registrado: Mar, 28 Dic 2010, 12:46

Re: ¿como definir las horas de entrada y salida del sistema?

Notapor elgrajillo » Jue, 07 Mar 2013, 21:13

buenos tardes, yo con el archivo de Traderninja he nconseguido que la operacion me entre/salga a la hora que quiero, pero cuando le pongo un bracket (entrada y stop como yo quiero) ya no me dibuja nada y se me queda sin hacer ninguna operación, alguien me podria decir a que se debe, que he hecho mal.

SISTEMA

#region Variables
// Wizard generated variables
private int tARGET = 30; // Default setting for TARGET
private int sTOP = 30; // Default setting for STOP
private int horaInicio = 8; // Default setting for HORAINICIO
private int minutoInicio = 55; // Default setting for MINUTOINICIO
private int segundoInicio = 1; // Default setting for SEGUNDOINICIO
private int horaFin = 11; // Default setting for HORAFIN
private int minutoFin = 5; // Default setting for MINUTOFIN
private int segundoFin = 1; // Default setting for SEGUNDOFIN
int iniciosesion=0;
int finsesion=0;
// User defined variables (add any user defined variables below)
#endregion

/// <summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
/// </summary>
protected override void Initialize()
{
CalculateOnBarClose = true;

SetProfitTarget("", CalculationMode.Ticks, TARGET);
SetStopLoss("", CalculationMode.Ticks, STOP, false);

CalculateOnBarClose = true;
//Calculamos las variables para que las entienda la orden "ToTime":
iniciosesion=(horaInicio*10000)+(minutoInicio*100)+segundoInicio;
finsesion=(horaFin*10000)+(minutoFin*100)+segundoFin;
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if((ToTime(Time[0])==iniciosesion) && Close[0] < Open[0])
{EnterLong (); }



if((ToTime(Time[0])==iniciosesion) && Close[0] < Open[0])
{EnterShort ();}
}
elgrajillo
 
Mensajes: 14
Registrado: Mar, 29 Mar 2011, 12:32

Re: ¿como definir las horas de entrada y salida del sistema?

Notapor TraderNinja » Vie, 08 Mar 2013, 14:23

Creo que la condición de entrada debería ser:

if(ToTime(Time[0])>=iniciosesion && ToTime(Time[0])<=finsesion && Close[0] < Open[0])
{EnterLong (); }



if(ToTime(Time[0])>=iniciosesion && ToTime(Time[0])<=finsesion && Close[0] < Open[0])
{EnterShort ();}


Saludos!
Avatar de Usuario
TraderNinja
Administrador del Sitio
 
Mensajes: 1557
Registrado: Mar, 28 Dic 2010, 12:46

Re: ¿como definir las horas de entrada y salida del sistema?

Notapor elgrajillo » Vie, 08 Mar 2013, 18:44

muchas gracias, era justo eso, ya funciona como yo quiero.


un saludo crack
elgrajillo
 
Mensajes: 14
Registrado: Mar, 29 Mar 2011, 12:32

Anterior

Volver a Sistemas

¿Quién está conectado?

Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 0 invitados

Bridge by mehdiplugins.com

Strict Standards: Non-static method JFactory::getDBO() should not be called statically, assuming $this from incompatible context in /homepages/34/d227044908/htdocs/traderninja/libraries/joomla/session/storage/database.php on line 84

Strict Standards: Non-static method JTable::getInstance() should not be called statically, assuming $this from incompatible context in /homepages/34/d227044908/htdocs/traderninja/libraries/joomla/session/storage/database.php on line 89

Strict Standards: Non-static method JFactory::getDBO() should not be called statically, assuming $this from incompatible context in /homepages/34/d227044908/htdocs/traderninja/libraries/joomla/database/table.php on line 112