Apologies for the question which will seem straight-forward, but I am a new user so I am trying to figure out the basics.
I am using a 24 hour MACD strategy for auto trading, and I would like to make it more frequent. i.e. if it has decided to sell at 2pm it currently waits until 12am to execute the order. I was thinking that if for example I am using a 24 hour MACD with parameters [12, 26, 9] this should be very similar to a 12 hour MACD of [24, 52, 18] i.e. at 00:00 every night both strategies should be both either long or short. I tried that and it seems it doesn’t work like that, i.e. there are occasions that the 12hour strategy is long and the 24hour is betting short at 00:00 (which is whenn both strategies are executed). What am I missing?
Bonus question: how can I change the time that the strategy is executed? The default time seems to be 00:00 for 24 hr strategies.
Many thanks in advance,
Yanis
Hi Yanis, I think you’ll get a lot more help if you were to post the code so people can see what’s going on. Click the button above that says Insert PRT Code. The instrument and time frame also helpful.
Bonus question: how can I change the time that the strategy is executed? The default time seems to be 00:00 for 24 hr strategies.
Simply run your strategy on a different time frame. You can use MTF to for example get the daily MACD levels and then trade on a 1 second time frame using them if you want to.
For the other question we would need the code to help you as our crystal ball is in for servicing at the moment. 🙂
Thank you both!
It seems that the calculation timeframe can be different to the execution timeframe which is very interesting. Can you please explain to me how I could implemented this?
I am using a very simple MACD strategy as per below.
On a theoretical note though, shouldn’t the 24hr MACD strategy with parameters [a,b,c] produce exactly the same decisions with the 12 hr MACD strategy with parameters [2a, 2b, 2c] every 24 hours?
Many thanks!
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// Conditions to enter long positions
a = 10
b = 34
c = 18
Amount = 4
indicator1 = MACD[a,b,c](close)
c1 = (indicator1 >= 0)
IF c1 THEN
BUY Amount PERPOINT AT MARKET
ENDIF
// Conditions to exit long positions
indicator2 = MACD[a,b,c](close)
c2 = (indicator2 <= 0)
IF c2 THEN
SELL AT MARKET
ENDIF
// Conditions to enter short positions
indicator3 = MACD[a,b,c](close)
c3 = (indicator3 <= 0)
IF c3 THEN
SELLSHORT Amount PERPOINT AT MARKET
ENDIF
// Conditions to exit short positions
indicator4 = MACD[a,b,c](close)
c4 = (indicator4 >= 0)
IF c4 THEN
EXITSHORT AT MARKET
ENDIF
On a theoretical note though, shouldn’t the 24hr MACD strategy with parameters [a,b,c] produce exactly the same decisions with the 12 hr MACD strategy with parameters [2a, 2b, 2c] every 24 hours?
The simple answer to this is no. The proof can be seen with this simple dummy strategy that plots all the different MACD’s. Run it on a 12 hour chart.
See here for how the TIMEFRAME instruction works:
TimeFrame instruction
timeframe (daily,updateonclose)
DailyUPOC = MACD[10,34,18](close)
timeframe (daily,default)
DailyDefault = MACD[10,34,18](close)
timeframe (12 hours)
HR12MACD = MACD[20,68,36](close)
buy at -close limit
graph DailyUPOC
graph DailyDefault
graph HR12MACD
Amazing! Will go through it.
Are you Greek?
Are you Greek?
No – I’m unfortuntely British but I live on a sailing boat and arrived in Greece in 2007. Since then apart from a handful of years in Turkey and Cyprus I have been in Greece. I did wonder if you would ask when I saw the name Yanis. Are you a British Greek or a Greek Greek in Britain!?
You are living the dream! Needs some courage to live everything behind and live on a boat, but I am sure it has paid off! I am a Greek Greek living in London hehe