How can I add a parameter (property) to the Strategy, so the user would be able to choose a session from the session list?
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
Using session as exposed property
Collapse
X
-
Using session as exposed property
I would like to add to a strategy properties a session, to be used as a time filter. I don't want to use the standard session, since it mess up the MA's.
How can I add a parameter (property) to the Strategy, so the user would be able to choose a session from the session list?Last edited by Shai Samuel; 02-07-2014, 12:53 AM.Tags: None
-
Hi Shai, there would be currently not a way to force a session, however you can check which one is used and inform the user for example via the MessageBox that he needs to select a different one to be compatible for your script expected working environment.
More flexibility here is planned for our next major release of the platform in this area.BertrandNinjaTrader Customer Service
-
Sorry Bertrand, I was probably not explaining myself right.
I would like to use the 24/7 session, so I get all my Moving Averages stable.
I would like to choose a session from the sessions list and get it as input parameter for my strategy. Then, I will use the session data to determine if I will execute the trades or not. So I am looking for a way to get the session selector as an input parameter (property).
Comment
-
I think I understand what you want Shai. There is not easy or straightforward way to do exactly what you describe. I believe it would entail a lot of sophisticating coding and probably some of it would be of the unsupported variety.
However, something that is simple is to just add an entry condition that is a time filter. Here is an example: http://www.ninjatrader.com/support/f...ead.php?t=3226
Then, code up two additional parameters that serve as a selection for the begin time and end time that you wish to accept trades.
Comment
-
Thanks for clarifying Shai and thanks for the assist coolmoss. The advice would be correct, there's no easy solution to pick from the session template collection to direct them to be a time filter. If you would want multiple things preset to select I would consider an enum for your choices for the time filter times.BertrandNinjaTrader Customer Service
Comment
-
Thank Bertrand and coolmoss. I know how to deal with the session, once I have it, and code the time filter. What I am missing is how to get the sessions list as a property input field. I am sure its has a simple solution since NT does it for its session template field.
It's probably should look like the color, but with session:
Code:[XmlIgnore()] [Description("Color for Buy mark")] [GridCategory("Chart")] public Color BuyColor { get { return buyColor; } set { buyColor = value; } } // Serialize our SecondaryColor object [Browsable(false)] public string BuyColorSerialize { get { return NinjaTrader.Gui.Design.SerializableColor.ToString(buyColor); } set { buyColor = NinjaTrader.Gui.Design.SerializableColor.FromString(value); } }
Thank for your support
Comment
-
Shai,
As stated in prior post, I don't think you can do it the way you're aiming at. You can't select a session per se. You'll need to set up variables for start and end times which define a period of time you wish trading to occur. If time is between the designated begin and end times, then you could set a bool variable to true, and then check for that variable being true whenever trade conditions for an entry were also true. The link I provided in prior post shows an example of this type of code. Good luck.
Comment
-
Coolmoss, I looked at the link you sent, and I understand what to do, but since what I would like to do involve multiple time frames and multiple days, the amount of variables (properties) I would need would be too big (5 time frames x 7 days). The best way for me to use will be used the session template as a structure to hold my data and then manipulate it the same way your link suggest.
So what I need is JUST (!!!), to be able to select a session template from the list and transfer it to my code. Since I am sure NT can handle session template as a parameter in many places.
Thanks for your support.
Comment
-
Hi Shai, I've attached a little indicator example as courtesy for you showing a potential way to deal with it - credit for some skeleton parts go to Derek Phelps and his NinjaWorkShop strategy shared in our forums recently.
However this is pretty deeply out of our documented NinjaScript and what we would be able to support officially, so this comes with clear disclaimer to thoroughly test on in your scenario before putting to use. You are basically playing on your own here for exchange to get some advanced functionalities desired.
All the best,Attached FilesLast edited by NinjaTrader_Bertrand; 02-11-2014, 07:37 AM.BertrandNinjaTrader Customer Service
Comment
-
Dear Bertrand, this is exactly what I was looking for.
Unfortunately, I need it for strategy (as a better interface to define execution windows), and for some reason strategy do not accept String as a property. Am I wrong? Is there a workaround?
Comment
-
You are welcome, for a strategy please try with a public property like the below, it would not accept Template (as we had for the indicator study) as public named string here -
[Description("Select Sessions")]
[GridCategory("Custom Session Select")]
[TypeConverter(typeof(SessionTemplateConverter))]
public string SessionTemplate
{
get { return _Template; }
set {_Template = value; }
}BertrandNinjaTrader Customer Service
Comment
-
Cool, it works. Now the last piece is to get a reference to the chosen session. How can I do this? Thanks for your support.
Comment
-
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by AttiM, 02-14-2024, 05:20 PM
|
12 responses
212 views
0 likes
|
Last Post
by DrakeiJosh
Today, 11:17 AM
|
||
Started by cre8able, 02-11-2023, 05:43 PM
|
3 responses
237 views
0 likes
|
Last Post
by rhubear
Today, 10:46 AM
|
||
Started by frslvr, 04-11-2024, 07:26 AM
|
8 responses
116 views
1 like
|
Last Post Today, 10:30 AM | ||
Started by stafe, 04-15-2024, 08:34 PM
|
10 responses
47 views
0 likes
|
Last Post
by stafe
Today, 10:29 AM
|
||
Started by rocketman7, Today, 09:41 AM
|
3 responses
11 views
0 likes
|
Last Post Today, 10:07 AM |
Comment