execute trade in Tuesday open of daily bar

Questions about MultiCharts and user contributed studies.
dingmanhoe123
Posts: 61
Joined: 25 Jul 2013
Has thanked: 18 times

execute trade in Tuesday open of daily bar

Postby dingmanhoe123 » 26 Jun 2017

under condition1 1 bar before Tuesday, I want to excute a trade at the open of Tueday.

If I write
if dayofweek(date)=1 and condition1 then buy next bar at market;

then it doesn't guarantee the trade will execute on tueday because the next trading day may be on wednesday if tuesday is a holiday.
or if monday is a holiday, we will miss a trade on that tuesday.

is there another better way to code my idea?

User avatar
ABC
Posts: 718
Joined: 16 Dec 2006
Location: www.abctradinggroup.com
Has thanked: 125 times
Been thanked: 408 times
Contact:

Re: execute trade in Tuesday open of daily bar

Postby ABC » 27 Jun 2017

dingmanhoe123,

one way to accomplish that is to detect the next trading day. For that you'd require a list of the holidays for your respective market most likely.
This would allow you to check every day if the next trading day is a Tuesday and in case it is, issue an order using your conditions.

Your code would need to perform something along the lines of:
1. Find the next date from the current date
2. Check if this date is a trading/business day for your market
3. Check if this date is not a holiday or half day

In case at least one of the checks 2. and 3. is not valid, you'd have to start over with your check in step 1. and go to the next date from the date
that you just checked.
In case both 2. and 3. are true, you have the date of the next trading day and can check using DayOfWeek if this is a Tuesday and issue your order.

Regards,

ABC


Return to “MultiCharts”