NexusFi: Find Your Edge


Home Menu

 





exit long position at specfic time


Discussion in NinjaTrader

Updated
    1. trending_up 1,949 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 2 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
 Kennyb59 
Washington, DC, USA
 
Experience: Advanced
Platform: ThinkorSwim
Trading: stocks
Posts: 2 since Jan 2012
Thanks Given: 2
Thanks Received: 0

I am trying to exit a long position at 9:05am using 5 min bars. I want it to trade after 10 am.

I have the following code and I would expect it to exit at 9:05am with 5 min bars yet it does not exit. Any suggestions?

{
if ((ToTime(Time[0]) >= 085500) || (ToTime(Time[0]) <= 090000))
{ if (Position.MarketPosition == MarketPosition.Long)


{
ExitLong("MACDlongexit");
}

Ken


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
CFTC Rewrites the Rulebook -- Kalshi Cracks $1B Non-Spor …
Prediction Markets & Event Contracts
US Prop Firms Race Inside the CFTC Perimeter -- Tradeify …
Funded Trading Evaluation Firms
The Feds Stagflation Trap -- Negative Payrolls, $91 Oil, …
Traders Hideout
Khamenei Vetoes Uranium Transfer as Peace Odds Surge to …
Prediction Markets & Event Contracts
The Great Rotation -- Small Caps Crushing Tech as Sectio …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Lady Vols Primer: Trading Volatility Journal
8 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Trying to learn Volume and price action correlation
5 thanks
  #3 (permalink)
 
ratfink's Avatar
 ratfink 
Birmingham UK
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: TST/Rithmic
Trading: YM/Gold
Posts: 3,550 since Dec 2012
Thanks Given: 17,423
Thanks Received: 8,430



Kennyb59 View Post
I am trying to exit a long position at 9:05am using 5 min bars. I want it to trade after 10 am.

I have the following code and I would expect it to exit at 9:05am with 5 min bars yet it does not exit. Any suggestions?

{
if ((ToTime(Time[0]) >= 085500) || (ToTime(Time[0]) <= 090000))
{ if (Position.MarketPosition == MarketPosition.Long)


{
ExitLong("MACDlongexit");
}

Ken

The Ninja bar time will be the bar close time and on minute bars seconds is always zero, just put some Prints on it to see what you want, maybe move the times you have selected and use && rather than || or a single == test and play with different series if you need more precision.

e.g.

if (ToTime(Time[0]) == 090000)
{
Print("Time " + Time[0]);
}

Prints on every 0900 bar into the output window.


Travel Well
Visit my NexusFi Trade Journal Reply With Quote




Last Updated on July 28, 2014


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts