Know Sure Thing

 

Hi Mr Tools,

This might not be the right place to post this thread. But since I don't know where else to post it, I posted it here anyway.

Would you please be so kind to look into an EA I created ?

KST is an indicator I downloaded from this forum. In my opinion, KST has not got the attention it deserves. KST is generally accurate in showing intermediate to long term trend.

I created a prototype EA based on KST. By "prototype" I mean this EA does not have mm, stoploss, and tp features. I only created it to verify the concept.

I created a mtf indicator for EA based on KST. I hardcoded the timeframe into the codes, which is 10080 for weekly. This indicator has two values. What I use for EA is value2, which has two values -1 and+1. At -1, the market is in an down trend. At +1, the market is in an up trend.

The EA is very simple. It works on D1 timeframe. It’s intended to work this way: when the market changes from down trend to up trend (value 2 changes from -1 to+1), it closes a sell order and opens a buy order; when the market changes from up trend to down trend (value 2 changes from +1 to -1), it closes a buy order and opens a sell order.

Attached please find 3 files. KST_EA is the EA. KST_v1 is the original file for KST indicator created by igorad. KST_forEA is the indicator I created for EA based on change of KST. Value 2 is from KST_forEA, it is the 2nd buffer.

To my surprise, such a simple and crude EA is even profitable during 10 years backtest, which tells me something.

The problem now I face is, the EA is trading much more frequently than it is supposed to. For example, in October 2011 the EA opened and closed buy order and sell order multiple times. However, from the attached screens you can see that, throughout Oct 2011, value 2 is at a constant level of -1, which means the EA should not have opened and closed so many trades. It seems that, the value for Value 2 that the EA retrieved through icustom is different from what we see on the chart of KST_forEA.

I spent couple of days trying to figure out the cause of the problem but I still have no clue. Now I am at my wit’s end. Would you please be so kind to look into the EA and indicators to find what causes the problem ?

For the EA to work, you need place KST-v1 and KST_forEA in the indicator folder.

Thanks in advance

Files:
kst_forea.mq4  3 kb
kst_v1.mq4  7 kb
kst_ea.mq4  4 kb
kst_screen1.jpg  78 kb
kst_screen2.jpg  44 kb
 
pooh123:
Hi Mr Tools,

This might not be the right place to post this thread. But since I don't know where else to post it, I posted it here anyway.

Would you please be so kind to look into an EA I created ?

KST is an indicator I downloaded from this forum. In my opinion, KST has not got the attention it deserves. KST is generally accurate in showing intermediate to long term trend.

I created a prototype EA based on KST. By "prototype" I mean this EA does not have mm, stoploss, and tp features. I only created it to verify the concept.

I created a mtf indicator for EA based on KST. I hardcoded the timeframe into the codes, which is 10080 for weekly. This indicator has two values. What I use for EA is value2, which has two values -1 and+1. At -1, the market is in an down trend. At +1, the market is in an up trend.

The EA is very simple. It works on D1 timeframe. It’s intended to work this way: when the market changes from down trend to up trend (value 2 changes from -1 to+1), it closes a sell order and opens a buy order; when the market changes from up trend to down trend (value 2 changes from +1 to -1), it closes a buy order and opens a sell order.

Attached please find 3 files. KST_EA is the EA. KST_v1 is the original file for KST indicator created by igorad. KST_forEA is the indicator I created for EA based on change of KST. Value 2 is from KST_forEA, it is the 2nd buffer.

To my surprise, such a simple and crude EA is even profitable during 10 years backtest, which tells me something.

The problem now I face is, the EA is trading much more frequently than it is supposed to. For example, in October 2011 the EA opened and closed buy order and sell order multiple times. However, from the attached screens you can see that, throughout Oct 2011, value 2 is at a constant level of -1, which means the EA should not have opened and closed so many trades. It seems that, the value for Value 2 that the EA retrieved through icustom is different from what we see on the chart of KST_forEA.

I spent couple of days trying to figure out the cause of the problem but I still have no clue. Now I am at my wit’s end. Would you please be so kind to look into the EA and indicators to find what causes the problem ?

For the EA to work, you need place KST-v1 and KST_forEA in the indicator folder.

Thanks in advance

Sure Pooh i'll look at it shouldn't take to long, as far as where to put the thread not sure, but can always move it if needed. If you don't mind i could put KST into one of our better templates then can go from there.

 
pooh123:
Hi Mr Tools,

This might not be the right place to post this thread. But since I don't know where else to post it, I posted it here anyway.

Would you please be so kind to look into an EA I created ?

KST is an indicator I downloaded from this forum. In my opinion, KST has not got the attention it deserves. KST is generally accurate in showing intermediate to long term trend.

I created a prototype EA based on KST. By "prototype" I mean this EA does not have mm, stoploss, and tp features. I only created it to verify the concept.

I created a mtf indicator for EA based on KST. I hardcoded the timeframe into the codes, which is 10080 for weekly. This indicator has two values. What I use for EA is value2, which has two values -1 and+1. At -1, the market is in an down trend. At +1, the market is in an up trend.

The EA is very simple. It works on D1 timeframe. It’s intended to work this way: when the market changes from down trend to up trend (value 2 changes from -1 to+1), it closes a sell order and opens a buy order; when the market changes from up trend to down trend (value 2 changes from +1 to -1), it closes a buy order and opens a sell order.

Attached please find 3 files. KST_EA is the EA. KST_v1 is the original file for KST indicator created by igorad. KST_forEA is the indicator I created for EA based on change of KST. Value 2 is from KST_forEA, it is the 2nd buffer.

To my surprise, such a simple and crude EA is even profitable during 10 years backtest, which tells me something.

The problem now I face is, the EA is trading much more frequently than it is supposed to. For example, in October 2011 the EA opened and closed buy order and sell order multiple times. However, from the attached screens you can see that, throughout Oct 2011, value 2 is at a constant level of -1, which means the EA should not have opened and closed so many trades. It seems that, the value for Value 2 that the EA retrieved through icustom is different from what we see on the chart of KST_forEA.

I spent couple of days trying to figure out the cause of the problem but I still have no clue. Now I am at my wit’s end. Would you please be so kind to look into the EA and indicators to find what causes the problem ?

For the EA to work, you need place KST-v1 and KST_forEA in the indicator folder.

Thanks in advance

While your waiting you may be interested in this version of KST

https://www.mql5.com/en/forum/general

post # 2644

 

Hi Pooh,

Made this its own thread, this is second version, the Ea has a close on trend change ended up making a nrp of Mladen's version of Kst the color change happens on zero crosses, this to me made it easier to use in the Ea, looking at your version decided it would be easier and quicker to do it this way, no offense meant, most wouldn't have even attempted and it wasn't that bad. Anyway there is an Ema trailing stop,time filter, hedge or no hedge, coded for 5 digit broker and ecn. Put it on a chart looks like just missed the zero cross on daily, so really not sure if it works or not. The signal crossing kst looks interesting might be something to think about in future editions.You will need Kst_nrp for this version.

ps) looking closer at your indicator looked like you were going for the slope so just in case heres a version for slope, Kst_nrp-1 you will need for this version

 

Hi Mr Tools,

Thanks for your attention on this ! That was quick ! In a couple of hours you already coded an EA. Amazing.

No offense at all. You're welcome to do anything to that crude EA of mine. Just that, may I ask that you take a look at my EA and those two indicators to find what caused the problem ? The EA is supposed to place orders only when the indicator changes between -1 and +1 but the actual orders placed in backtest are more frequent than that. I'd like to know the cause of the problem in order to improve my coding skill. Thanks a million.

I tried backtesting the new EA you coded but it didn't place any trade. There were no error message in the journal.

 
pooh123:
Hi Mr Tools,

Thanks for your attention on this ! That was quick ! In a couple of hours you already coded an EA. Amazing.

No offense at all. You're welcome to do anything to that crude EA of mine. Just that, may I ask that you take a look at my EA and those two indicators to find what caused the problem ? The EA is supposed to place orders only when the indicator changes between -1 and +1 but the actual orders placed in backtest are more frequent than that. I'd like to know the cause of the problem in order to improve my coding skill. Thanks a million.

I tried backtesting the new EA you coded but it didn't place any trade. There were no error message in the journal.

Hi,

Try these not sure but there was a trend neutral wasn't exactly sure where to put it and still not sure its right, anyway going to get some sleep will explain about your Ea later today.

 

Hi Pooh,

In your Ea all you had to do is do an icustom, something like this

double longTerm = iCustom(NULL,KSTTimeFrame,"KST_v1",0,KSTMode,0,1)

in your external parameters you would need

extern int KSTTimeFrame = 10080;

extern int KSTMode = 9;

double IntermediateTerm = iCustom(NULL,KSTTimeFrame2,"KST_v1",0,KSTMode2,0,1) in yout external parameters you would need

extern int KSTTimeFrame2 = 10080;

extern int KSTMode2 = 7;

In this case you didn't really need an forEa indicator IMO, and also This way you can have user control of timeframe and Modes.

 

One more version of this Ea this one is using the kst slope and the cross of the kst and signal, is using indicator KST_nrp-1 indicator posted above.

 
mrtools:
Hi Pooh,

In your Ea all you had to do is do an icustom, something like this

double longTerm = iCustom(NULL,KSTTimeFrame,"KST_v1",0,KSTMode,0,1)

in your external parameters you would need

extern int KSTTimeFrame = 10080;

extern int KSTMode = 9;

double IntermediateTerm = iCustom(NULL,KSTTimeFrame2,"KST_v1",0,KSTMode2,0,1) in yout external parameters you would need

extern int KSTTimeFrame2 = 10080;

extern int KSTMode2 = 7;

In this case you didn't really need an forEa indicator IMO, and also This way you can have user control of timeframe and Modes.

Hi Mr Tools,

Thanks for your response. In the above iCustoms equation, what is this 0 before KSTMode ? I checked MT4 help on iCustoms sentax and found that, the custom indicator name should be followed by parameter, ie, KSTMode in this case. So I don't know what this 0 between "KST_v1" and KSTMode is. I underlined it above. Could you please explain it ?

Anyway, I tried what you suggested above both with and without that 0 in the iCustoms sentax. In both cases MT4 allowed me to comile the EA without problem. The EA without 0 issued only one order during backtest in 2004. That order remained open until end of test in 2011. The EA with 0 didn't issue any trades. The journal shows KST_v1 loaded successfully and the next message shows KST_v1 removed. Those two messages pops up in the journal for every minute

I attached here the backtest result of the old version of my prototype EA from my 1st post. You can see its' profitable during 10 years backtest. Most of the EAs I found at this forum cannot withstand 10 years' backtest. And remember, this one doesn't even have mm, sl and tp. The order signal is based on 6 bars ago on a daily chart (a week ago), so the result is as trust worthy as backtest can be. I started on this EA purely out of curiosity. I just wanted to know what a simple EA based on KST would turn out. Now that I see the result from the backtest, my curiosity only grows.

Again and again, I read advice from posts at the forum that you should never base your trades on a single indicator and I totally agree with that advice. But look at this EA, which is based on only one indicator. I believe KST is definitely worth looking into and build something out of it. The key might be weekly timeframe. At daily timeframe, it still generates too many false signals.

Files:
kst_ea_1.gif  9 kb
kst_ea.htm  333 kb
 
mrtools:
The ,0, replaces KSTTimeFrame's 1 and 2 this i never realized until i asked Mladen about the same problem i had with Jurik TrendStrength, about the rest i don't know.

Sorry, I still don't get it. What do you mean that the 0 replaces KSTTimeFrame's 1 and 2 ?

 
pooh123:
Hi Mr Tools,

Thanks for your response. In the above iCustoms equation, what is this 0 before KSTMode ? I checked MT4 help on iCustoms sentax and found that, the custom indicator name should be followed by parameter, ie, KSTMode in this case. So I don't know what this 0 between "KST_v1" and KSTMode is. I underlined it above. Could you please explain it ?

Anyway, I tried what you suggested above both with and without that 0 in the iCustoms sentax. In both cases MT4 allowed me to comile the EA without problem. The EA without 0 issued only one order during backtest in 2004. That order remained open until end of test in 2011. The EA with 0 didn't issue any trades. The journal shows KST_v1 loaded successfully and the next message shows KST_v1 removed. Those two messages pops up in the journal for every minute

I attached here the backtest result of the old version of my prototype EA from my 1st post. You can see its' profitable during 10 years backtest. Most of the EAs I found at this forum cannot withstand 10 years' backtest. And remember, this one doesn't even have mm, sl and tp. The order signal is based on 6 bars ago on a daily chart (a week ago), so the result is as trust worthy as backtest can be. I started on this EA purely out of curiosity. I just wanted to know what a simple EA based on KST would turn out. Now that I see the result from the backtest, my curiosity only grows.

Again and again, I read advice from posts at the forum that you should never base your trades on a single indicator and I totally agree with that advice. But look at this EA, which is based on only one indicator. I believe KST is definitely worth looking into and build something out of it. The key might be weekly timeframe. At daily timeframe, it still generates too many false signals.

The ,0, replaces KSTTimeFrame's 1 and 2 this i never realized until i asked Mladen about the same problem i had with Jurik TrendStrength, about the rest i don't know.

ps) ok here iCustom(NULL,KSTTimeFrame,"KST_v1",0,KSTMode,0,1) if you change the 1 at the end to something like bars1 and on the other to bars2 ,then both KSTModes = 9 the bars1=7,and bars2=13 on your external parameters think that will equal what you have on your Ea, only thing is in your indicator for Ea you used the slope to get extbuffer2, so maybe you need the slope in your Ea too along with the >< 0.

Reason: