NexusFi: Find Your Edge


Home Menu

 





Please help coding day of month strategy!!


Discussion in Traders Hideout

Updated
      Top Posters
    1. looks_one FastNCurious with 7 posts (2 thanks)
    2. looks_two ABCTG with 4 posts (5 thanks)
    3. looks_3 kevinkdog with 1 posts (2 thanks)
    4. looks_4 biffhero with 1 posts (1 thanks)
      Best Posters
    1. looks_one kevinkdog with 2 thanks per post
    2. looks_two ABCTG with 1.3 thanks per post
    3. looks_3 biffhero with 1 thanks per post
    4. looks_4 FastNCurious with 0.3 thanks per post
    1. trending_up 3,103 views
    2. thumb_up 10 thanks given
    3. group 3 followers
    1. forum 11 posts
    2. attach_file 0 attachments




 
Search this Thread

Please help coding day of month strategy!!

  #11 (permalink)
 
FastNCurious's Avatar
 FastNCurious 
saint louis MO
 
Experience: Intermediate
Platform: TradeStation
Trading: NQ, ES, YM, CL, GC
Posts: 149 since Oct 2017
Thanks Given: 95
Thanks Received: 177


jburke75 View Post
I didn't know there was this dayofmonth fuction but here is the final code that actually works in TS for the idea I have originally which was buy only on a certain number trading day of the month and sellshort on another.

 
Code
//short side
//set your charst to daily, day session only, custom day session 830-1510 central time.  
//ending 5 minutes early to exit on close
//sell short on the 830 oprn of the 5th trading day of the month
//starting with the 2nd day in the trade, exit on the first 3:10pm custom session close 
//that is higher than the previous days close
//do not take new short signal if currently long

//long side
//buy on the 830 open of the 5th trading day of the month
//starting with the 2nd day in the trade, exit on the first 3:10pm custom session close 
//that is lower than the previous days close
//do not take new long signal if currently short







If marketposition=0 then begin
If month(date) <> month(date[4]) 
and month(date) = month(date[3]) 
and month(date) = month(date[2]) 
and month(date) = month(date[1]) 
then sell short next bar at market;

end;
If barssinceentry>=2 and close>close[1] then buytocover next bar at market;

If marketposition=0 then begin
If month(date) <> month(date[19]) 
and month(date) = month(date[1]) 
and month(date) = month(date[2]) 
and month(date) = month(date[3]) 
and month(date) = month(date[4]) 
and month(date) = month(date[5]) 
and month(date) = month(date[6]) 
and month(date) = month(date[7]) 
and month(date) = month(date[8]) 
and month(date) = month(date[9]) 
and month(date) = month(date[10]) 
and month(date) = month(date[11]) 
and month(date) = month(date[12]) 
and month(date) = month(date[13]) 
and month(date) = month(date[14]) 
and month(date) = month(date[15]) 
and month(date) = month(date[16]) 
and month(date) = month(date[17]) 
and month(date) = month(date[18])  
then buy next bar at market;

end;
If barssinceentry>=2 and close<close[1] then sell next bar at market;

Here is an updated easier code that I finally figured out.

 
Code
If marketposition=0 then begin
If month(date) <> month(date[4]) 
and month(date) = month(date[3])
then sell short next bar at market;

end;
If barssinceentry>=2 and close>close[1] then buytocover next bar at market;


If marketposition=0 then begin
If month(date) <> month(date[19])
and month(date) = month(date[18])  
then buy next bar at market;

end;
If barssinceentry>=2 and close<close[1] then sell next bar at market;
Does anyone have any other ways to do this? i.e DayOfMonth function? maybe sellshort next bar after the 10th calendar day of each month? It seems there is no way else to do this but I am open to other ideas. Thank you Kevin and ABC for your help. Your guys really are the real deal.

Visit my NexusFi Trade Journal Started this thread Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
MC PL editor upgrade
MultiCharts
Strategy stop orders partially filled
EasyLanguage Programming
REcommedations for programming help
Sierra Chart
Cheap historycal L1 data for stocks
Stocks and ETFs
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
  #12 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

@jburke75,

there is usually more than one way to accomplish something, but your approach appears to be perfectly fine. Besides that its simplicity has some elegance to it, too.
When you start working with DayOfMonth you will have to deal with holidays or weekends as the desired day of the month might not be a trading day.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:




Last Updated on November 2, 2020


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts