NexusFi: Find Your Edge


Home Menu

 





Basic 101 Strategy


Discussion in EasyLanguage Programming

Updated
    1. trending_up 4,524 views
    2. thumb_up 1 thanks given
    3. group 3 followers
    1. forum 2 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
kwt4
New York + NY
 
Posts: 1 since Jun 2020
Thanks Given: 0
Thanks Received: 1

H All,

New to the community and new to programming on TradeStation. Building a simple strategy for practice. Creating an automated strategy to buy SPY on the 14th day of each month and sell on the 16th day (2 days after). I am having trouble building out the match for trading day.

For example if the entry or exit day falls on a non-trading day, how do I execute the last trading day before the non-trading day? My code so far:

//This is entry on the 14th of each month
If dayofmonth(date)=13 then buy ("Entry") next bar open;


//This is exit on the 16th of each month
If dayofmonth(date)=16 then Setexitonclose;

Thank you so much,
Kevin


Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
April 2026 Jobs Report: +115k vs +65k Expected
Traders Hideout
TradingView Deploys AI to Monitor SEC Filings in Real Ti …
TradingView
Netherlands & Germany Surge as World Cup Field Narro …
Prediction Markets & Event Contracts
Iran Forward Curve: June 30 at 56% vs June 15 at 28% -- …
Prediction Markets & Event Contracts
Orban at 29pct as Hungary Votes Tomorrow -- McIlroy Surg …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
197 thanks
Sober Journey With S&P
27 thanks
30 Sessions
20 thanks
BERN ALGOS algo trading journal
8 thanks
Volume Indicators
8 thanks
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,642

kwt4,

you will likely need code that is able to detect holidays and weekends first. This would allow you to check at the beginning of every month if the 13th and 14th days are regular trading days and adjust the days accordingly if they are not.

Regards,

ABCTG


kwt4 View Post
H All,

New to the community and new to programming on TradeStation. Building a simple strategy for practice. Creating an automated strategy to buy SPY on the 14th day of each month and sell on the 16th day (2 days after). I am having trouble building out the match for trading day.

For example if the entry or exit day falls on a non-trading day, how do I execute the last trading day before the non-trading day? My code so far:

//This is entry on the 14th of each month
If dayofmonth(date)=13 then buy ("Entry") next bar open;


//This is exit on the 16th of each month
If dayofmonth(date)=16 then Setexitonclose;

Thank you so much,
Kevin


Follow me on X Reply With Quote
  #3 (permalink)
 bchip 
Torino, Italy
 
Experience: Advanced
Platform: TradeStation
Trading: ES,YM,CL,GC
Posts: 132 since Sep 2017
Thanks Given: 160
Thanks Received: 117



kwt4 View Post
H All,

New to the community and new to programming on TradeStation. Building a simple strategy for practice. Creating an automated strategy to buy SPY on the 14th day of each month and sell on the 16th day (2 days after). I am having trouble building out the match for trading day.

For example if the entry or exit day falls on a non-trading day, how do I execute the last trading day before the non-trading day? My code so far:

//This is entry on the 14th of each month
If dayofmonth(date)=13 then buy ("Entry") next bar open;


//This is exit on the 16th of each month
If dayofmonth(date)=16 then Setexitonclose;

Thank you so much,
Kevin


Rather use a > than sign, so if dayofmonth >= 16 then exit next bar.
This will help with one of the issues as you exit on the 1st day after that date.

But as ABCTG pointed out, logically you still need to answer the question, what happens if the 13th falls on a Sat/Sunday or Public holiday


Reply With Quote




Last Updated on June 14, 2020


© 2026 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 - Downloads - Top
no new posts