Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
How do I close positions 5 bars after they are opned
Hey, I'm currently switching over from thinkorswim to ninjatrader 8 and I need to know the code I need to add to ninjascript or how I add it to the strategy builder. But I would like to close all short positions 5 bars after the position was opened. (or 5 mins or would be even better If I could close the position on the next 5 min increment, so if short position was opened at 10:22 it will close at 10:25)
Here is the current code
// Set 1
if (CrossAbove(ParabolicSAR1, Close, 1))
{
EnterShort(Convert.ToInt32(DefaultQuantity), "");
}
// Set 2
if (CrossAbove(ParabolicSAR1, Close, 1))
{
ExitShort(Convert.ToInt32(DefaultQuantity), "", "");
}
Also what does the 1 mean after the para crossabove the close?
Thank you so much for your time and help!
Can you help answer these questions from other members on NexusFi?
Thanks for that quote and telling me what that 1 meant! This is code for me that closes my last position 5 bars later.
// Set 1
if (CrossAbove(ParabolicSAR1, Close, 1))
{
EnterShort(Convert.ToInt32(DefaultQuantity), "");
}
// Set 2
if (BarsSinceEntryExecution()==5)
{
ExitShort(Convert.ToInt32(DefaultQuantity), "", "");
}
which will work, still trying to learn how to close it on 5 minute increments though