NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


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 05-29-2012, 11:41 AM   #1
ajcpereira
Junior Member
 
Join Date: Apr 2012
Posts: 15
Thanks: 1
Thanked 1 time in 1 post
Default Close position before earnings reports

Hi,

I'm new in this forum so I hope I won't ask something too basic or that was already answered in the past.
I want to backtest a system that has multiple exits. One exit is activated market on close on the day before the earnings report to avoid gaps against the trend. Does anyone know how to code it and what source of information can be used to it?

Thanks,

ACP
ajcpereira is offline  
Reply With Quote
Old 05-29-2012, 12:04 PM   #2
NinjaTrader_Joydeep
NinjaTrader Customer Service
 
NinjaTrader_Joydeep's Avatar
 
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
Default

Hello ACP,
Welcome to the forum and I am happy to assist you.

You can limit the timing of your trades using a time filter. Please refer to this sample code which demonstrates it
http://ninjatrader.com/support/forum...ead.php?t=3226

Please let me know if I can assist you any further.
NinjaTrader_Joydeep is offline  
Reply With Quote
Old 05-29-2012, 03:44 PM   #3
ajcpereira
Junior Member
 
Join Date: Apr 2012
Posts: 15
Thanks: 1
Thanked 1 time in 1 post
Default

Hello Joydeep,

Thanks for your quick answer. I'm not looking for a predefined time exit but for an exit that depends on the day of the earnings report (ER) date. Trying to clarify my idea: If I buy ABC stock and while on the trade the company will present their ER I want the position to be closed on the previous day. I want to include this exit on a code for backtest. At the moment, manually I see this information on yahoo http://biz.yahoo.com/research/earncal/20110112.html but I suppose I can't get this data on NT.
Hope you can help me.

ACP
ajcpereira is offline  
Reply With Quote
Old 05-30-2012, 04:51 AM   #4
NinjaTrader_Joydeep
NinjaTrader Customer Service
 
NinjaTrader_Joydeep's Avatar
 
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
Default

Hello ACP,
The sample code is just a reference point/code and not the actual code.

You have to hardcode the date(s) and further custom code it.

in variable
Code:
DateTime agmDate = new DateTime(2012, 5, 30, 15, 30, 0);
in OnBarUpdate
Code:
if (Time[0] > agmDate)
{
    //exit postions
}

Please let me know if I can assist you any further.
NinjaTrader_Joydeep 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
Earnings Data ErikHR NinjaScript File Sharing Discussion 5 09-12-2011 09:20 AM
Position does not close Torso Strategy Development 1 10-26-2010 12:56 PM
Automatically enter position on Market Open, Close position on Market Close kevendickenson SuperDOM and other Order Entry Windows 1 04-02-2010 04:30 AM
Can we display dividends & earnings information on Chart? isitpossible Charting 3 03-29-2010 10:32 PM
position close on close of bar mballagan Miscellaneous Support 3 01-14-2010 10:11 AM


All times are GMT -6. The time now is 08:25 AM.