For you coders, this is probabbly very basic but for a newb like me I can't seem to figure it out. I am actually using a little tool that helps to create the EA once I define the trade rules, i.e. the IF...THE... statements.
I am trying to design an EA built around using a polynomial regression channel and stochs for confirmation. The stochs part is easy enough, but the first part is placing a sell order if price touches the top of the channel and a long order if it touches the bottom of the channel. TP would be the middle of the channel. It is probably MQL 101, but I don't see how to return a value of each line into the EA where I can say:
If price = top line
Then...
I have attached the indicator and a PIC so you can see what I am trying to do.
Newbie question on using custom indicators
-
Dewey McG
- Trader
- Posts: 435
- Joined: Sat Nov 26, 2011 4:20 pm
- Location: Tampa FL
Newbie question on using custom indicators
You do not have the required permissions to view the files attached to this post.
- gaheitman
- Trader
- Posts: 655
- Joined: Tue Nov 15, 2011 10:55 pm
- Location: Richmond, VA, US
Re: Newbie question on using custom indicators
You need to call the indicator with the iCustom() function. You pass the appropriate parameters to the indicator and then specify which of the buffers (which correspond to the lines drawn on the chart) that you want to return. To get all three values you would have to call the indicator via iCustom() three times. Take a look at this for more information: http://docs.mql4.com/indicators/icustomDewey McG wrote:For you coders, this is probabbly very basic but for a newb like me I can't seem to figure it out. I am actually using a little tool that helps to create the EA once I define the trade rules, i.e. the IF...THE... statements.
I am trying to design an EA built around using a polynomial regression channel and stochs for confirmation. The stochs part is easy enough, but the first part is placing a sell order if price touches the top of the channel and a long order if it touches the bottom of the channel. TP would be the middle of the channel. It is probably MQL 101, but I don't see how to return a value of each line into the EA where I can say:
If price = top line
Then...
I have attached the indicator and a PIC so you can see what I am trying to do.
-
Bruce Flea
- Trader
- Posts: 18
- Joined: Mon Feb 13, 2012 4:43 am
Re: Newbie question on using custom indicators
Tough to tell what your little app is actually doing with the code, but since you have the indicator, the easiest solution is probably iCustom.
The middle line would be: iCustom(NULL,0,"i-Regr",3,2.0,250,0,0,0)
And the bottom line would be: iCustom(NULL,0,"i-Regr",3,2.0,250,0,2,0)
Code: Select all
if (Ask=>iCustom(NULL,0,"i-Regr",3,2.0,250,0,1,0){
do_whatever=whatever_you_want_it_to_do;
}
And the bottom line would be: iCustom(NULL,0,"i-Regr",3,2.0,250,0,2,0)
- SteveHopwood
- Owner
- Posts: 9904
- Joined: Tue Nov 15, 2011 8:43 am
- Location: Misterton - an insignificant village in England. Very pleasant to live in.
Re: Newbie question on using custom indicators
Both the above two posts are true, but only if the indi is well coded.
Don't count on this. Most custom indis are total abortions of code. Dragging information kicking and screaming from them is not an easy task.
'Dragging information kicking and screaming from them is not an easy task' is Steve code for damn nearly bloody impossible. You would be stunned at the number of ways the coders of these damn things find to derail the attempts of intelligent coders to access the information they are supposed to provide. Most custom indi's are total Abortions. The first thing I look for when asked to code an ea using one is the identity of the coder; if it is not one of the regular indi coders in this forum, I know I am in for trouble.
(An aside. Why is it, I wonder, that ea coders are expected to provide 50 lines of comment explanation for every line of code we produce, whilst Abortion coders are not required to provide any? Ever. No matter how complex what they are failing to achieve. Anyone here actually come across an Abortion that includes comments? I bloody well have not - well, not useful comments.)
Sorry about the aside. A bit of a raw nerve there.
So, having established that most custom indis are total crap (and if you have not done this yet, you will do, I promise) you then think that some sort of 'Instant EA' creating software will creat an ea for you that works?
Dream on.
If instant ea creation actually worked, everybody would do it. It doesn't. The best thing you can do is learn to code Crapql4 from scratch, then you stand a chance of achieving what you want.
Guess how I know?
If you have no idea how to get started, then http://www.stevehopwoodforex.com/phpBB3 ... f=15&t=301 will offer a few clues.

Don't count on this. Most custom indis are total abortions of code. Dragging information kicking and screaming from them is not an easy task.
'Dragging information kicking and screaming from them is not an easy task' is Steve code for damn nearly bloody impossible. You would be stunned at the number of ways the coders of these damn things find to derail the attempts of intelligent coders to access the information they are supposed to provide. Most custom indi's are total Abortions. The first thing I look for when asked to code an ea using one is the identity of the coder; if it is not one of the regular indi coders in this forum, I know I am in for trouble.
(An aside. Why is it, I wonder, that ea coders are expected to provide 50 lines of comment explanation for every line of code we produce, whilst Abortion coders are not required to provide any? Ever. No matter how complex what they are failing to achieve. Anyone here actually come across an Abortion that includes comments? I bloody well have not - well, not useful comments.)
Sorry about the aside. A bit of a raw nerve there.
So, having established that most custom indis are total crap (and if you have not done this yet, you will do, I promise) you then think that some sort of 'Instant EA' creating software will creat an ea for you that works?
Dream on.
If instant ea creation actually worked, everybody would do it. It doesn't. The best thing you can do is learn to code Crapql4 from scratch, then you stand a chance of achieving what you want.
Guess how I know?
If you have no idea how to get started, then http://www.stevehopwoodforex.com/phpBB3 ... f=15&t=301 will offer a few clues.
Read the effing manual, ok?
Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.
I still suffer from OCCD. Good thing, really.
Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.
To see The Weekly Roundup of stuff you guys might have missed Click here
My special thanks to Thomas (tomele) for all the incredible work he does here.
Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.
I still suffer from OCCD. Good thing, really.
Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.
To see The Weekly Roundup of stuff you guys might have missed Click here
My special thanks to Thomas (tomele) for all the incredible work he does here.
-
Dewey McG
- Trader
- Posts: 435
- Joined: Sat Nov 26, 2011 4:20 pm
- Location: Tampa FL
Re: Newbie question on using custom indicators
Thanks! I appreciate all the help, including Steve's warnings about crappy indicators. I have been burnt by a few.
This might look simple to those of you with experience, but I was able to make my first EA. I have lots of reading and catching up to do, but it is certainly interesting.
The relevant part of the code is here:
manageOrders();
//--------------------------------------
// Go long
if (((Bid <= iCustom(NULL, 0 , "i-Regr", 3 , 2 , 250 , 0 , 2, 0)) && (iStochastic(NULL, 0 , 30 , 3 , 3 , 0 , 0 , 0 , 1) > iStochastic(NULL, 0 , 30 , 3 , 3 , 0 , 0 , 1 , 1)))) {
// Action #1
sqCloseOrder(200);
// Action #2
sqOpenOrder("NULL", OP_BUY, getOrderSize(100, OP_BUY ), getOrderPrice(100), "", 100);
}
//--------------------------------------
// Go Short
if (((Bid >= iCustom(NULL, 0 , "i-Regr", 3 , 2 , 250 , 0 , 1, 0)) && (iStochastic(NULL, 0 , 30 , 3 , 3 , 0 , 0 , 0 , 1) < iStochastic(NULL, 0 , 30 , 3 , 3 , 0 , 0 , 1 , 1)))) {
// Action #1
sqCloseOrder(100);
// Action #2
sqOpenOrder("NULL", OP_SELL, getOrderSize(200, OP_SELL ), getOrderPrice(200), "", 200);
}
//--------------------------------------
// take tp short
if (((sqGetMarketPosition() == -1) && (Bid <= iCustom(NULL, 0 , "i-Regr", 3 , 2 , 250 , 0 , 0, 0)))) {
sqCloseOrder(200);
}
//--------------------------------------
// take tp long
if (((sqGetMarketPosition() == 1) && (Bid >= iCustom(NULL, 0 , "i-Regr", 3 , 2 , 250 , 0 , 0, 0)))) {
sqCloseOrder(100);
}
return(0);
}
The good news is I tested the EA on different pairs , Eur/Usd, Aus/Usd, Gbp/Usd and Aus/Jpy. So far all of them show a profit on the 4 hour chart in backtesting with good profit factors. Before posting the whole EA and proving how inept I am, I want to tidy up the code (among other things clicking "Bid" instead of "Ask"), make it so I can optimise it and run some more tests to make sure it is worthwhile before getting too excited.
This might look simple to those of you with experience, but I was able to make my first EA. I have lots of reading and catching up to do, but it is certainly interesting.
The relevant part of the code is here:
manageOrders();
//--------------------------------------
// Go long
if (((Bid <= iCustom(NULL, 0 , "i-Regr", 3 , 2 , 250 , 0 , 2, 0)) && (iStochastic(NULL, 0 , 30 , 3 , 3 , 0 , 0 , 0 , 1) > iStochastic(NULL, 0 , 30 , 3 , 3 , 0 , 0 , 1 , 1)))) {
// Action #1
sqCloseOrder(200);
// Action #2
sqOpenOrder("NULL", OP_BUY, getOrderSize(100, OP_BUY ), getOrderPrice(100), "", 100);
}
//--------------------------------------
// Go Short
if (((Bid >= iCustom(NULL, 0 , "i-Regr", 3 , 2 , 250 , 0 , 1, 0)) && (iStochastic(NULL, 0 , 30 , 3 , 3 , 0 , 0 , 0 , 1) < iStochastic(NULL, 0 , 30 , 3 , 3 , 0 , 0 , 1 , 1)))) {
// Action #1
sqCloseOrder(100);
// Action #2
sqOpenOrder("NULL", OP_SELL, getOrderSize(200, OP_SELL ), getOrderPrice(200), "", 200);
}
//--------------------------------------
// take tp short
if (((sqGetMarketPosition() == -1) && (Bid <= iCustom(NULL, 0 , "i-Regr", 3 , 2 , 250 , 0 , 0, 0)))) {
sqCloseOrder(200);
}
//--------------------------------------
// take tp long
if (((sqGetMarketPosition() == 1) && (Bid >= iCustom(NULL, 0 , "i-Regr", 3 , 2 , 250 , 0 , 0, 0)))) {
sqCloseOrder(100);
}
return(0);
}
The good news is I tested the EA on different pairs , Eur/Usd, Aus/Usd, Gbp/Usd and Aus/Jpy. So far all of them show a profit on the 4 hour chart in backtesting with good profit factors. Before posting the whole EA and proving how inept I am, I want to tidy up the code (among other things clicking "Bid" instead of "Ask"), make it so I can optimise it and run some more tests to make sure it is worthwhile before getting too excited.