| stevehopwoodforex.com https://www.stevehopwoodforex.com/phpBB3/ Print view |
|
| Newbie question on using custom indicators https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=909 |
Page 1 of 1 |
| Author: | Dewey McG [ Sat Oct 27, 2012 8:59 pm ] |
| Post subject: | Newbie question on using custom indicators |
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. |
|
| Author: | gaheitman [ Sat Oct 27, 2012 9:41 pm ] |
| Post subject: | 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/icustom |
|
| Author: | Bruce Flea [ Sat Oct 27, 2012 9:45 pm ] |
| Post subject: | 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. Code: Select all And the bottom line would be: iCustom(NULL,0,"i-Regr",3,2.0,250,0,2,0) |
|
| Author: | SteveHopwood [ Sat Oct 27, 2012 11:28 pm ] |
| Post subject: | 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. |
|
| Author: | Dewey McG [ Sun Oct 28, 2012 5:39 am ] |
| Post subject: | 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. |
|
| All times are UTC | Page 1 of 1 |
|
Powered by phpBB® Forum Software © phpBB Limited |
|