|
A stochf problem
#430231
09/25/13 22:45
09/25/13 22:45
|
Joined: Jun 2013
Posts: 41 Ohio, USA
Pork
OP
Newbie
|
OP
Newbie
Joined: Jun 2013
Posts: 41
Ohio, USA
|
Hi all, I'm trying to replicate a multi-time frame stoch ea. But every 4 hours the stochs for H4, 1 and M15 are the same. I understand how they could be the samae, but every 4 hours seems wrong. I've looked and looked and don't see a problem, but there has to be one. Thanks for any help. P
#define D1 (1440/BarPeriod) #define H4 (240/BarPeriod) #define H1 (60/BarPeriod) #define M15 (15/BarPeriod)
function run() { BarPeriod = 15; TimeFrame=H4; vars PriceH4=series(price()); StochF(5,3,MAType_SMA); vars StoH4=series(rFastK); TimeFrame=H1; vars PriceH1=series(price()); StochF(5,3,MAType_SMA); vars StoH1=series(rFastK); TimeFrame=M15; vars PriceM15=series(price()); StochF(5,3,MAType_SMA); vars StoM15=series(rFastK); Lots=1; StartDate=20080102; EndDate=20080631; Margin=0; Spread=2*PIP; set(LOGFILE|PLOTNOW|PLOTPRICE);
Asset=("AUDUSD"); printf("# \n"); printf("# Price Stoc \n"); printf("# H4 %5.5f %5.5f \n", PriceH4[0],StoH4[0]); printf("# H1 %5.5f %5.5f \n", PriceH1[0],StoH1[0]); printf("# M15 %5.5f %5.5f \n", PriceM15[0],StoM15[0]);
//Oversold if((NumOpenTotal<2)&&(StoH4[0]<20)&&(StoH1[0]<20)&&(StoM15[0]<20)) { exitShort(); enterLong(); } //Overbought if((NumOpenTotal<2)&&(StoH4[0]>80)&&(StoH1[0]>80)&&(StoM15[0]>80)) { exitLong(); enterShort(); } plot("StoH4",StoH4[0],NEW,RED); plot("StoH1",StoH1[0],NEW,BLUE); plot("StoM15",StoM15[0],NEW,GREEN); }
|
|
|
Re: A stochf problem
[Re: Sundance]
#430265
09/26/13 10:26
09/26/13 10:26
|
acidburn
Unregistered
|
acidburn
Unregistered
|
#define is a C pre-processor thingy. Think of it as a templating system. Wherever in the code you see D1, you replace it (either in your mind, or for real) with (1440/BarPeriod). It's only there in the code that it is actually executed, #defines are declarations only.
|
|
|
Re: A stochf problem
[Re: Sundance]
#430285
09/26/13 12:48
09/26/13 12:48
|
Joined: Jun 2013
Posts: 41 Ohio, USA
Pork
OP
Newbie
|
OP
Newbie
Joined: Jun 2013
Posts: 41
Ohio, USA
|
Thanks all. Once again very helpful. Nice to know how the stoch actually works. I'm starting to see a pattern that maybe I should adjust my thinking to eliminate the old mt4 indicators and start using the new, to me, statistical indicators. Looks to me like more reading and less coding is needed. Quickly references the reading list Thanks All P
|
|
|
|