NexusFi: Find Your Edge


Home Menu

 





Basic 101 Strategy


Discussion in EasyLanguage Programming

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




 
Search this Thread

Basic 101 Strategy

  #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?
About a successful futures trader who didnĀ“t know anyth …
Psychology and Money Management
Cheap historycal L1 data for stocks
Stocks and ETFs
How to apply profiles
Traders Hideout
Better Renko Gaps
The Elite Circle
Quant vue
Trading Reviews and Vendors
 
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

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 Twitter 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: 116



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


© 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