Forum PipFlow

Versión completa: NinjaTrader 8 Strategy help!
Actualmente estas viendo una versión simplificada de nuestro contenido. Ver la versión completa con el formato correcto.
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.
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