TWO TIME FRAME MACD STOCHASTIC STRATEGY

Strategies are published here.

Moderator: admin

TWO TIME FRAME MACD STOCHASTIC STRATEGY

Postby Apprentice » Thu Jan 26, 2017 5:10 am

1.png

2.png


A. Histogram Level: Off

i. If MACD histogram is rising in higher time frame
then, in lower time frame, stochastic K is smaller than oversold level or crosses oversold level declining
Open Long

ii. If MACD histogram is declining in higher time frame
then, in lower time frame, stochastic K is bigger than overbought level or crosses overbought level rising
Open Short

B. Histogram Level: On

i. If MACD histogram is rising in higher time frame
and histogram is smaller than zero
then, in lower time frame, stochastic K is smaller than oversold level or crosses oversold level declining
Open Long

ii. If MACD histogram is declining in higher time frame
and histogram is bigger than zero
then, in lower time frame, stochastic K is bigger than ovebought level or crosses overbought level rising
Open Short

TWO TIME FRAME MACD STOCHASTIC STRATEGY.lua
(26 KiB) Downloaded 981 times
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36435
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: TWO TIME FRAME MACD STOCHASTIC STRATEGY

Postby foreveryoung » Thu Jan 26, 2017 6:42 am

That was fast Apprentice. Thank you very much!

However, trying to back test it, it says "238: MACD time frame must be equal or bigger than Stochastic time frame!" although this is not true with the strategy dialogue. The opposite works (i.e. small time frame for MACD, big time frame for stochastic).
foreveryoung
 
Posts: 45
Joined: Wed Jan 25, 2017 6:25 am

Re: TWO TIME FRAME MACD STOCHASTIC STRATEGY

Postby foreveryoung » Thu Jan 26, 2017 7:25 am

Additionally, I had a look into it and found following bugs:

1. In the strategy dialogue, the time frame of stochastic controls the MACD (probably that is why it gives the in-previous-post-described error).
2. It uses the same time frame for stochastic as for MACD.
2. If Close On Opposite is set to "No", then no trade is executed.

Thanks
foreveryoung
 
Posts: 45
Joined: Wed Jan 25, 2017 6:25 am

Re: TWO TIME FRAME MACD STOCHASTIC STRATEGY

Postby foreveryoung » Thu Jan 26, 2017 7:57 am

Finally, and most important, the clarification I made last night is the opposite (I got confused, sorry).
The order is triggered by the stochastic K, i.e.

1. If MACD histogram on long time frame is below zero & rising, open long when stochastic K on the short time frame is in the oversold territory or crosses the oversold level declining
2. If MACD histogram on long time frame is above zero & declining, open short when stochastic K on the short time frame is in the overbought territory or crosses the overbought level rising
3. Close on opposite

Thanks
foreveryoung
 
Posts: 45
Joined: Wed Jan 25, 2017 6:25 am

Re: TWO TIME FRAME MACD STOCHASTIC STRATEGY

Postby Apprentice » Thu Jan 26, 2017 8:01 am

Time frame issue resolved.
Try to set "Account Type" to appropriate method
Now it is set as "Automatic"
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36435
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: TWO TIME FRAME MACD STOCHASTIC STRATEGY

Postby foreveryoung » Thu Jan 26, 2017 9:31 am

Hi Apprentice

Tested it again, it now says "238: Stochastic time frame must be equal to or bigger than MACD time frame!", which obviously is not the case.

A final request, kindly introduce a "Histogram Level: Yes/No" in the strategy dialogue, which shall turn on/turn off the MACD histogram level precondition, i.e., when "No", strategy will be as well able to go long as when the histogram rises above the zero line, & vice versa.

Thank you very much your efforts
foreveryoung
 
Posts: 45
Joined: Wed Jan 25, 2017 6:25 am

Re: TWO TIME FRAME MACD STOCHASTIC STRATEGY

Postby Apprentice » Fri Jan 27, 2017 3:24 am

Tested it again, it now says "238: Stochastic time frame must be equal to or bigger than MACD time frame!", which obviously is not the case.

Can you share your settings.
A final request, kindly introduce a "Histogram Level: Yes/No" in the strategy dialogue, which shall turn on/turn off the MACD histogram level precondition, i.e., when "No", strategy will be as well able to go long as when the histogram rises above the zero line, & vice versa.

Can you formulate this as pseudo code.

If ...
and ...
then ...
Open Long
...
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36435
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: TWO TIME FRAME MACD STOCHASTIC STRATEGY

Postby foreveryoung » Fri Jan 27, 2017 4:15 am

Good Morning From Greece!

I. Settings Request

MACD Time Frame :5 minutes
Stochastic Time Frame: 1 minute
Account type : non FIFO

All other settings at default, it gives the following error when back tested: "238: Stochastic time frame must be equal to or bigger than MACD time frame!", which is not what we are looking for, it is the MACD time frame that needs to be bigger than the stochastic one in this strategy.

II. Psedocode Request

A. Histogram Level: Off

i. If MACD histogram is rising in higher time frame
then, in lower time frame, stochastic K is smaller than oversold level or crosses oversold level declining
Open Long

ii. If MACD histogram is declining in higher time frame
then, in lower time frame, stochastic K is bigger than overbought level or crosses overbought level rising
Open Short

B. Histogram Level: On

i. If MACD histogram is rising in higher time frame
and histogram is smaller than zero
then, in lower time frame, stochastic K is smaller than oversold level or crosses oversold level declining
Open Long

ii. If MACD histogram is declining in higher time frame
and histogram is bigger than zero
then, in lower time frame, stochastic K is bigger than ovebought level or crosses overbought level rising
Open Short

Thanks!
foreveryoung
 
Posts: 45
Joined: Wed Jan 25, 2017 6:25 am


Re: TWO TIME FRAME MACD STOCHASTIC STRATEGY

Postby foreveryoung » Sat Jan 28, 2017 1:21 pm

Hi Apprentice

It is great to have a manual strategy automated to that success, the only thing that is missing is the right stop loss. Back tested it with many different parameters, it always gives more winning orders than losing ones, however, in this version, losing orders are way too damaging, therefore, should a trade is not to work fast, better stop it. This could be implemented by introducing an optional exit where:

Optional Exit: Yes

If Long
Then MACD histogram at the higher time frame declines
Close

If Short
Then MACD histogram at the higher time frame rises
Close

Thank you for your prompt response & actions, as always
foreveryoung
 
Posts: 45
Joined: Wed Jan 25, 2017 6:25 am

Next

Return to Custom Strategies

Who is online

Users browsing this forum: No registered users and 11 guests