Junior Member
#1

0
Hey, I need a simple strategy code temple that I can add more conditions to, so please add notes in the code where needed. Right now I have this code.
if (CrossBelow(Close,ParabolicSAR1,1))
{EnterShort(Convert.ToInt32(DefaultQuantity), "");}
// Set 2
if (BarsSinceEntryExecution()==4)
{ExitShort(Convert.ToInt32(DefaultQuantity), "", "");}
Which I add the conditions I want, then when they are met it opens a position, then 4 bars have passed it closes the position. I need it to close the positions on 5 minute intervals instead of 4 bars have passed. So if the order was opened at 2:20 it closes at 2:25, if opened at 2:21 it closes at 2:25, if opened at 2:27 it closes at 2:30, if opened at 2:29 it closes at 2:30, and so on and so on.
Responder

Super Moderator
#2

39
Just replace if (BarsSinceEntryExecution()==4)

with something like this just change to 5 min instead of 20

https://stackoverflow.com/questions/7701...ave-passed


You should convert your start time to a UTC time, say 'start'.

You can now compare your start time to the current UTC time using:

start.AddMinutes(20) > DateTime.UtcNow
Responder



Posibles temas similares…
Tema Autor Respuestas Vistas Último mensaje
  Guia para eliminar errores de compilación en Ninjatrader 8 waldo 0 3,385 03-05-2023, 09:18 PM
Último mensaje: waldo
  Habilitar Tick Replay en NinjaTrader 8 waldo 3 14,995 02-15-2022, 08:01 PM
Último mensaje: [email protected]
  Portar de Ninjatrader 7 a NinjaTrader 8 waldo 4 7,028 05-27-2020, 12:49 AM
Último mensaje: waldo
  Enabling tick replay in Ninjatrader 8 waldo 0 6,236 04-16-2017, 06:00 AM
Último mensaje: waldo

Salto de foro:


Usuarios navegando en este tema:
1 invitado(s)