I'm trying to back-test an option strategy. I would like to add a condition where a long position or a short position closes every 3rd Friday of the month because then the options expire. How can I build this condition in strategy builder? Someone who can help me with this?
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
Option expiration date
Collapse
X
-
Option expiration date
Hello,
I'm trying to back-test an option strategy. I would like to add a condition where a long position or a short position closes every 3rd Friday of the month because then the options expire. How can I build this condition in strategy builder? Someone who can help me with this?
Tags: None
-
Hello Jimmy73,
Thanks for your post.
Options support on the NinjaTrader platform is in a preliminary phase. NinjaScript strategies are not yet supported. Support for NinjaScript strategies is intended for some point in the future, but we cannot offer an ETA on when that support will be available.
Let us know if you have any questions.JimNinjaTrader Customer Service
-
Is there maybe a way to do this with a certain code in Ninjascript instead of doing this in Strategy Builder?
I don't think it's going to be easy to write a code to determine every 3rd Friday of the month together with closing a long position or a short position.
Is there anyone who can help me get started with this?
Comment
-
I cannot make it work to close an open position on every 3rd friday of the month.
I have found an indicator that marks a weekday or every 3rd friday of the month but it is written for Ninjatrader 7. Is there a way to convert this to Ninjatrader 8?
Attached Files
Comment
-
Hello Jimmy73,
You will need the source code if you want to convert the indicator to NinjaTrader 8. If you have the source code, you can use our Code Breaking Changes page of the Help Guide to direct you further for implementation changes and changes to NinjaScript objects from NinjaTrader 7 to NinjaTrader 8.
Code Breaking Changes - https://ninjatrader.com/support/help...ng_changes.htm
You could use DateTime checks to see if Time[0] is the third Friday of the month. The example code below should get you moving in the right direction.
Code:private int lastMonth = 0; private int fridayCount = 0; protected override void OnBarUpdate() { if (Time[0].Month != lastMonth) { lastMonth = Time[0].Month; fridayCount = 0; } if (Time[0].DayOfWeek == DayOfWeek.Friday) fridayCount++; if (fridayCount == 3 && Time[0].DayOfWeek == DayOfWeek.Friday) { Draw.Dot(this, "tag" + CurrentBar, true, 0, High[0] + 5 * TickSize, Brushes.White); } }
Another publicly available resource can be found here - https://www.dotnetperls.com/datetime
We look forward to assisting.JimNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Noerclou, Today, 04:55 AM
|
0 responses
2 views
0 likes
|
Last Post
by Noerclou
Today, 04:55 AM
|
||
Started by llanqui, Yesterday, 09:59 AM
|
2 responses
17 views
0 likes
|
Last Post
by llanqui
Today, 04:00 AM
|
||
Started by ThoriSten, Today, 03:56 AM
|
0 responses
6 views
0 likes
|
Last Post
by ThoriSten
Today, 03:56 AM
|
||
Started by PhillT, 04-19-2024, 02:16 PM
|
3 responses
23 views
0 likes
|
Last Post
by mangel2000
Today, 03:04 AM
|
||
Started by TraderBCL, Today, 02:37 AM
|
0 responses
4 views
0 likes
|
Last Post
by TraderBCL
Today, 02:37 AM
|
Comment