NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 09-22-2008, 12:05 PM   #1
sauer11155
Member
 
Join Date: Aug 2008
Posts: 48
Thanks: 0
Thanked 0 times in 0 posts
Default resetting flag at end of day or a certain time of day

I have a flag condition with my strategy. Can I have this flag reset at for instance 1.55pm if I wanted? Or when backtesting, can I have it reset in the am? This way I would only do one trade either for the whole day or perhaps up until 1.55pm.

Thanks
sauer11155 is offline  
Reply With Quote
Old 09-22-2008, 01:14 PM   #2
NinjaTrader_Ben
NinjaTrader Customer Service
 
NinjaTrader_Ben's Avatar
 
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
Default

Hello,

I'm not sure what you mean by "flag". Do you mean a flag price formation or something that signals/flags you to place a discretionary trade?

Either way, what you probably want to to is monitor your strategy via time. You can do this by building a condition usging ToTime(Time[0]). This link will help with this:
http://www.ninjatrader-support.com/v...ead.php?t=3226
NinjaTrader_Ben is offline  
Reply With Quote
Old 09-22-2008, 01:35 PM   #3
sauer11155
Member
 
Join Date: Aug 2008
Posts: 48
Thanks: 0
Thanked 0 times in 0 posts
Default

// Condition set 1
if (Close[0] < SMA(SMA200period)[0] && (Position.MarketPosition == MarketPosition.Flat)
&& CrossAbove(SMA(5), SMA(SMA20period), 1))
AFlag = true;


{
if (Close[0] < SMA(SMA200period)[0] && (CrossBelow(Stochastics(PeriodD, PeriodK, Smooth).K, TopLine, 1)
&& AFlag == true))

{
EnterShort(Entry2target, "Entry2TargetSIGNALNAME");
EnterShort(Entry8target, "Entry8TargetSIGNALNAME");
AFlag = false;
}

}

Sry, I mean the way I use "AFlag" in this code. I have the Aflag be reset after an order is taken. I was just wondering if I could have that flag reset with a time based parameter, like either at the end of the day, or a specific time of day.
sauer11155 is offline  
Reply With Quote
Old 09-22-2008, 01:47 PM   #4
NinjaTrader_Ben
NinjaTrader Customer Service
 
NinjaTrader_Ben's Avatar
 
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
Default

Hello,


Perhaps you mean a bool toggle for when it is time to trade and when it is not time to trade?

If so you will want to use the same concepts illustrated in the link but perhaps do it in this way:

bool do_not_trade = false;

if(ToTime(Time[0]) > 131500)
{
do_not_trade = true;
}

if(do_not_trade == false)
{
//some other conditions and place orders here
}

Note: the code above does not reset the toggle. You will want to build a condition to reset it back from true to false. So you might want to use something like this:

if(Bars.FirstBarOfSession) //resets it at the start of the new session
{
do_not_trade = false;
}
Last edited by NinjaTrader_Ben; 09-22-2008 at 02:29 PM.
NinjaTrader_Ben is offline  
Reply With Quote
Old 09-22-2008, 05:29 PM   #5
sauer11155
Member
 
Join Date: Aug 2008
Posts: 48
Thanks: 0
Thanked 0 times in 0 posts
Default

if(Bars.FirstBarOfSession) //resets it at the start of the new session

What exactly is the start of a new session, is this the next time I open the program, or is it based on my strategy settings such as the period of time I am running the strategy? TY
sauer11155 is offline  
Reply With Quote
Old 09-23-2008, 08:30 AM   #6
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

Sessions are defined by the time settings of your chart or strategy. The start time you define will dictate when Bars.FirstBarOfSession evaluates to true.
NinjaTrader_Josh is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
debug compile flag and export script tb2000 General Programming 7 04-05-2013 10:01 AM
Resetting account performance ? T2020 Miscellaneous Support 2 09-08-2008 07:25 AM
Resetting SIM trades gygraham Strategy Analyzer 1 04-14-2008 07:01 PM
Profit Target and Flag Agamenon General Programming 1 11-08-2007 01:41 PM
resetting Sim101 account Oli Miscellaneous Support 2 02-27-2007 04:03 AM


All times are GMT -6. The time now is 11:36 PM.