This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.



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

38
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 2,197 03-05-2023, 09:18 PM
Último mensaje: waldo
  Habilitar Tick Replay en NinjaTrader 8 waldo 3 13,899 02-15-2022, 08:01 PM
Último mensaje: [email protected]
  Portar de Ninjatrader 7 a NinjaTrader 8 waldo 4 6,226 05-27-2020, 12:49 AM
Último mensaje: waldo
  Enabling tick replay in Ninjatrader 8 waldo 0 5,762 04-16-2017, 06:00 AM
Último mensaje: waldo

Salto de foro:


Usuarios navegando en este tema:
1 invitado(s)