I would like to implement the following trading system:
Buy on a certain trading day of the month when the high or low of the previous day is exceeded. Sell after x days at the close of trading if the take profit or stop loss is not reached beforehand.
The correct calculation of the trading day of the month is important. Stock exchange holidays must also be taken into account, i.e. days on which there is no trading on the home exchange, e.g. Cbot, Euwax, CME etc.
It’s not possible to know when there are Holidays. We can only know there was one AFTER that day. So you will have to set the date (or at least the day). In case that day (or date) is a holiday, the trade will not be executed at all that month, or it can be executed the next day.
There must be another possibility. The system knows on which days of the month trading takes place. In a monthly view, each trading day has a candle. Now, for example, the trading system should place an order if the previous day’s high is exceeded on the 5th trading day.
The system therefore only has to count off the trading days starting with the beginning of the month.
Yes, knowing them AFTER they occur is possible:
ONCE Tally = 99
IF OpenMonth <> OpenMonth[1] THEN
Tally = 0
ENDIF
Tally = Tally + 1
IF Tally = 5 AND Not OnMarket THEN //enter on the closing of the 5th trading day
IF high > high[1] THEN
BUY 1 CONTRACT AT MARKET
SET TARGET pPROFIT 300
SET STOP pLOSS 100
Count = 0
ENDIF
ENDIF
IF OnMarket THEN
Count = Count + 1
IF Count = 3 THEN //exit after 3 days
SELL AT MARKET
ENDIF
ENDIF
graph Tally
graph Count
great. however, one condition is still missing. If Stop Loss or Take Profit are not triggered, the trade should be closed after 10 trading days at market on close. (e.g. 11 pm for the S&P500).
by the way: must the computer be active with prorealtime for the orders or are the orders placed on the IG market?
This will do:
ONCE TF = GetTimeFrame
ONCE Tally = 99
IF OpenMonth <> OpenMonth[1] THEN
Tally = 0
ENDIF
IF OpenDay <> OpenDay[1] THEN
Tally = Tally + 1
ENDIF
IF Tally = 5 AND Not OnMarket THEN //enter on the closing of the 5th trading day
IF high > high[1] THEN
BUY 1 CONTRACT AT MARKET
SET TARGET pPROFIT 300
SET STOP pLOSS 100
Count = 0
ENDIF
ENDIF
IF OnMarket THEN
IF OpenDay <> OpenDay[1] THEN
Count = Count + 1
ENDIF
IF TF = 86400 THEN
IF Count = 10 THEN //exit after 10 days
SELL AT MARKET
ENDIF
ELSE
IF Count = 10 AND Time = 230000 THEN //exit after 10 days at closing time
SELL AT MARKET
ENDIF
ENDIF
ENDIF
graph Tally
graph Count
be warned that if it’s run on a intraday TF, the TIME must be that when the last candle of the day closes (on a 4-hour TF there’s NO candle closing at 23, so you will need to use 21).
by the way: must the computer be active with prorealtime for the orders or are the orders placed on the IG market?
@funkytown, No. The orders are placed by PRT servers; your PC can be shut off (after you started the Autotrading System of concern).
Great, thank you very much.