Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, degenerate_762), 1,309 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
EMA of multiple time frames #413714
12/16/12 18:56
12/16/12 18:56
Joined: Dec 2012
Posts: 14
P
Pipinator Offline OP
Newbie
Pipinator  Offline OP
Newbie
P

Joined: Dec 2012
Posts: 14
Hello,

I am trying to create a multi-TF indicator. I would like to have a 38 hr EMA, 8 hr EMA on the 5 minute TF for scalping.

I'm running into the problem not being able to get a Price array

vars Price = series(price()); with a fixed time frame, All I see is offset. Is it possible?

vars Price60min = series(price(0,60));
vars Price5min = series(price(0,5));

plot("EMA60",EMA(Price60min,38),0,0x222222);
plot("EMA5",EMA(Price5min,8),0,0x992222);

Thanks!

T

Re: EMA of multiple time frames [Re: Pipinator] #413739
12/17/12 08:08
12/17/12 08:08
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
For setting a time frame, use the TimeFrame variable. How to use it is described in the manual with an example:

http://manual.zorro-trader.com/barperiod.htm

As to my knowledge, scalping ceased to be profitable around the year 2000, though.

Re: EMA of multiple time frames [Re: jcl] #414174
12/24/12 16:30
12/24/12 16:30
Joined: Nov 2012
Posts: 209
S
SFF Offline
Member
SFF  Offline
Member
S

Joined: Nov 2012
Posts: 209
Could you explain how to use 1 week, 1 month even 1 year chart?

Re: EMA of multiple time frames [Re: SFF] #414232
12/27/12 08:47
12/27/12 08:47
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
For week bars, set BarPeriod to 7*24*60.

There are no month bars, because months have a different number of days and can not be expressed with a bar period.

Re: EMA of multiple time frames [Re: jcl] #414379
12/31/12 03:54
12/31/12 03:54
Joined: Nov 2012
Posts: 209
S
SFF Offline
Member
SFF  Offline
Member
S

Joined: Nov 2012
Posts: 209
Thanks. I have made this code but It looks like I had errors about BarPeriod/TimeFrame.

The strategy is simple - I will buy 15min MACD cross over if MACD of 30 and 60 min are in the same direction.( For buy, upside).

Thank you for any advice.

Code:
function run(){
	
	set(LOGFILE);
	
   int FastPeriod = 8;
   int SlowPeriod = 21;
	int SignalPeriod = 9;
	
	BarPeriod = 15;
	vars Close = series(priceClose());
	TimeFrame = 1;
	
	MACD(Close,FastPeriod,SlowPeriod,SignalPeriod);
	vars MainLine = series(rMACD);
	vars SignalLine = series(rMACDSignal);
	vars Hist = series(rMACDHist);
	
	MACD(Close,FastPeriod*2,SlowPeriod*2,SignalPeriod*2);
	vars MainLine30 = series(rMACD);
	vars SignalLine30 = series(rMACDSignal);
	vars Hist30 = series(rMACDHist);
	
	MACD(Close,FastPeriod*4,SlowPeriod*4,SignalPeriod*4);
	vars MainLine60 = series(rMACD);
	vars SignalLine60 = series(rMACDSignal);
	vars Hist60 = series(rMACDHist);
	
	MACD(Close,FastPeriod*16,SlowPeriod*16,SignalPeriod*16);
	vars MainLine240 = series(rMACD);
	vars SignalLine240 = series(rMACDSignal);
	vars Hist240 = series(rMACDHist);
	
	

if(crossOver(MainLine,SignalLine) && MainLine30[0] > SignalLine30[0]
   && MainLine30[0] > SignalLine60[0] && MainLine240[0] > SignalLine240[0]){

    
exitShort();
    enterLong();
    }

if(crossUnder(MainLine,SignalLine) && MainLine30[0] < SignalLine30[0]
   && MainLine30[0] < SignalLine60[0] && MainLine240[0] < SignalLine240[0]){


exitLong();
    enterShort();
    }

            
}


Last edited by SFF; 01/04/13 13:08.
Re: EMA of multiple time frames [Re: SFF] #414385
12/31/12 08:25
12/31/12 08:25
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Timeframe is a) not needed and b) used wrong here.

It's not needed because you can get your 30 and 60 min MACD just by multiplying the MACD timeperiod with 2 and 4.

It's used wrong because your Close series is still from TimeFrame = 1. A 60 min MACD would need a price series with 60 min candles, like this:

TimeFrame = 4;
vars Close60 = series(priceClose());
TimeFrame = 1;

Look in the manual under "TimeFrame", there you can see how it's used for price series with different time frames. However different time frames are needed for very special cases only, for instance a daily ATR.

Also, one suggestion - when you are not sure if your signals do what you want them to do, plot them. Make it a habit to plot all your signals in the chart. Seeing how your signals behave is essential for strategy development.

Re: EMA of multiple time frames [Re: jcl] #414386
12/31/12 09:52
12/31/12 09:52
Joined: Nov 2012
Posts: 209
S
SFF Offline
Member
SFF  Offline
Member
S

Joined: Nov 2012
Posts: 209
Thanks.

I had it working by multiplying timeperiod for each bars.

I have used plot function but the image I have got is very small thus I am not able to see where the signal has been for simple crossover systems and win-loss mark for each trades.

So I make a logfile and go to MT4 to check the signals.

Re: EMA of multiple time frames [Re: SFF] #414506
01/03/13 14:09
01/03/13 14:09
Joined: Nov 2012
Posts: 209
S
SFF Offline
Member
SFF  Offline
Member
S

Joined: Nov 2012
Posts: 209
Code was updated at post #414379.

It is producing signals which I am not expect to see.
Where is wrong?

I only enter 15min MACD cross when 30,60 and 240 MACD are in the same direction.
It enters or closes trades every 15min from the log.

Thanks in advance.

Re: EMA of multiple time frames [Re: SFF] #414514
01/03/13 18:09
01/03/13 18:09
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Originally Posted By: SFF
It is producing signals which I am not expect to see.
Where is wrong?

Well, if your script is producing signals which you are not expect to see, the "where" happens between the first line of your script, and the last line - that's at least what I can tell you without seeing your script. wink

Re: EMA of multiple time frames [Re: jcl] #414553
01/04/13 10:50
01/04/13 10:50
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Your updated code has still a bug: It exits only when the signals match, but it enters trades on every bar with these lines:

if(!NumOpenLong) enterLong();
...
if(!NumOpenShort) enterShort();

I believe you've forgotten the { } brackets.

Page 1 of 2 1 2

Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1