Thanks
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
resetting flag at end of day or a certain time of day
Collapse
X
-
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.
ThanksTags: None
-
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:
DenNinjaTrader Customer Service
-
// 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.
Comment
-
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, 02:29 PM.DenNinjaTrader Customer Service
Comment
-
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
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by DJ888, Today, 10:57 PM
|
0 responses
1 view
0 likes
|
Last Post
by DJ888
Today, 10:57 PM
|
||
Started by MacDad, 02-25-2024, 11:48 PM
|
7 responses
158 views
0 likes
|
Last Post Today, 10:23 PM | ||
Started by Belfortbucks, Today, 09:29 PM
|
0 responses
7 views
0 likes
|
Last Post
by Belfortbucks
Today, 09:29 PM
|
||
Started by zstheorist, Today, 07:52 PM
|
0 responses
7 views
0 likes
|
Last Post
by zstheorist
Today, 07:52 PM
|
||
Started by pmachiraju, 11-01-2023, 04:46 AM
|
8 responses
151 views
0 likes
|
Last Post
by rehmans
Today, 06:44 PM
|
Comment