|
|||
|
|||||||
| Notices |
| Register in Forex TSD! | |
|
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time). Click here to register and get more information |
|
![]() |
|
|
Thread Tools | Display Modes |
|
||||
|
The best option is probably to take a look at modifying the MACD sample EA that metatrader provides.
Alternatively you could take a look at one of the code generation tools available such as Forex Software - Gordago although in my experience you'll still need to code for these tools to be of any use. You might get lucky and someone who's trying to learn MQL might just take a look. To get a good coder interested it helps if you can convince them that the method is something worth taking a look at, such as results from a hand back test, or results from a live forward test |
|
|||
|
How about using the iCustom function.
sngSlope0 = NormalizeDouble(iCustom(NULL, 0, "Slope Direction Line", 80, 3, 0, 0, 0), 4); sngSlope1 = NormalizeDouble(iCustom(NULL, 0, "Slope Direction Line", 80, 3, 0, 1, 0), 4); if (sngSlope1>=sngSlope0) { // Long } else { // Short } If you have the .mq4 code for the indicator, you can use the iCustom function. I'm assuming "Slope Direction Line.mq4" is the name of the indicator you are using. |
|
||||
|
Who can write simple MQL4-Code?
Can One say me, how I can made of a Indicator a Expert Advisor (EA)?
For example on the Slope Direction Line. When the Slope Direction Line change the colour of green to red (see Picture) then the Expert Advisor shall make a SELL-Order. When now the colour once more become green, then closed the SELL-Order and make a new BUY-Order. The BUY-Order shall closed when red comes again, and a new SELL-Order start now… I hope One here can help me! Thank you for read this message! Here is the Picture: (capture_09092008_191556 [150%].jpg) Here is the Code of the Indicator: #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 LightBlue #property indicator_color2 Tomato //---- input parameters extern int period=80; extern int method=3; // MODE_SMA extern int price=0; // PRICE_CLOSE //---- buffers double Uptrend[]; double Dntrend[]; double ExtMapBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { IndicatorBuffers(3); SetIndexBuffer(0, Uptrend); //ArraySetAsSeries(Uptrend, true); SetIndexBuffer(1, Dntrend); //ArraySetAsSeries(Dntrend, true); SetIndexBuffer(2, ExtMapBuffer); ArraySetAsSeries(ExtMapBuffer, true); SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2); SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2); IndicatorShortName("Slope Direction Line("+period+")"); return(0); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { // ???? ????? ?????? ?????? return(0); } //+------------------------------------------------------------------+ //| ?????????? ??????? | //+------------------------------------------------------------------+ double WMA(int x, int p) { return(iMA(NULL, 0, p, 0, method, price, x)); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars = IndicatorCounted(); if(counted_bars < 0) return(-1); int x = 0; int p = MathSqrt(period); int e = Bars - counted_bars + period + 1; double vect[], trend[]; if(e > Bars) e = Bars; ArrayResize(vect, e); ArraySetAsSeries(vect, true); ArrayResize(trend, e); ArraySetAsSeries(trend, true); for(x = 0; x < e; x++) { vect[x] = 2*WMA(x, period/2) - WMA(x, period); // Print("Bar date/time: ", TimeToStr(Time[x]), " close: ", Close[x], " vect[", x, "] = ", vect[x], " 2*WMA(p/2) = ", 2*WMA(x, period/2), " WMA(p) = ", WMA(x, period)); } for(x = 0; x < e-period; x++) ExtMapBuffer[x] = iMAOnArray(vect, 0, p, 0, method, x); for(x = e-period; x >= 0; x--) { trend[x] = trend[x+1]; if (ExtMapBuffer[x]> ExtMapBuffer[x+1]) trend[x] =1; if (ExtMapBuffer[x]< ExtMapBuffer[x+1]) trend[x] =-1; if (trend[x]>0) { Uptrend[x] = ExtMapBuffer[x]; if (trend[x+1]<0) Uptrend[x+1]=ExtMapBuffer[x+1]; Dntrend[x] = EMPTY_VALUE; } else if (trend[x]<0) { Dntrend[x] = ExtMapBuffer[x]; if (trend[x+1]>0) Dntrend[x+1]=ExtMapBuffer[x+1]; Uptrend[x] = EMPTY_VALUE; } //Print( " trend=",trend[x]); } return(0); } ANSWERS ARE: sngSlope0 = NormalizeDouble(iCustom(NULL, 0, "Slope Direction Line", 80, 3, 0, 0, 0), 4); sngSlope1 = NormalizeDouble(iCustom(NULL, 0, "Slope Direction Line", 80, 3, 0, 1, 0), 4); if (sngSlope1>=sngSlope0) { // Long } else { // Short } 2nd Writing: Hi! I'am a totally beginner of MQL4 programming. ![]() I don’t understand how I can made a Expert Advisor with Sell & Buy Signals of Line Colored. For example on the Slope Direction Line. When the Slope Direction Line change the colour of green to red (see Picture) then the Expert Advisor shall make a SELL-Order. When now the colour once more become green, then closed the SELL-Order and make a new BUY-Order. The BUY-Order shall closed when red comes again, and a new SELL-Order start now… I hope One here can help me! Thank you for read this message! Here is the Code of the Indicator: -------------------------------------------------------------------------- #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 LightBlue #property indicator_color2 Tomato //---- input parameters extern int period=80; extern int method=3; // MODE_SMA extern int price=0; // PRICE_CLOSE //---- buffers double Uptrend[]; double Dntrend[]; double ExtMapBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { IndicatorBuffers(3); SetIndexBuffer(0, Uptrend); //ArraySetAsSeries(Uptrend, true); SetIndexBuffer(1, Dntrend); //ArraySetAsSeries(Dntrend, true); SetIndexBuffer(2, ExtMapBuffer); ArraySetAsSeries(ExtMapBuffer, true); SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2); SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2); IndicatorShortName("Slope Direction Line("+period+")"); return(0); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { // ???? ????? ?????? ?????? return(0); } //+------------------------------------------------------------------+ //| ?????????? ??????? | //+------------------------------------------------------------------+ double WMA(int x, int p) { return(iMA(NULL, 0, p, 0, method, price, x)); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars = IndicatorCounted(); if(counted_bars < 0) return(-1); int x = 0; int p = MathSqrt(period); int e = Bars - counted_bars + period + 1; double vect[], trend[]; if(e > Bars) e = Bars; ArrayResize(vect, e); ArraySetAsSeries(vect, true); ArrayResize(trend, e); ArraySetAsSeries(trend, true); for(x = 0; x < e; x++) { vect[x] = 2*WMA(x, period/2) - WMA(x, period); // Print("Bar date/time: ", TimeToStr(Time[x]), " close: ", Close[x], " vect[", x, "] = ", vect[x], " 2*WMA(p/2) = ", 2*WMA(x, period/2), " WMA(p) = ", WMA(x, period)); } for(x = 0; x < e-period; x++) ExtMapBuffer[x] = iMAOnArray(vect, 0, p, 0, method, x); for(x = e-period; x >= 0; x--) { trend[x] = trend[x+1]; if (ExtMapBuffer[x]> ExtMapBuffer[x+1]) trend[x] =1; if (ExtMapBuffer[x]< ExtMapBuffer[x+1]) trend[x] =-1; if (trend[x]>0) { Uptrend[x] = ExtMapBuffer[x]; if (trend[x+1]<0) Uptrend[x+1]=ExtMapBuffer[x+1]; Dntrend[x] = EMPTY_VALUE; } else if (trend[x]<0) { Dntrend[x] = ExtMapBuffer[x]; if (trend[x+1]>0) Dntrend[x+1]=ExtMapBuffer[x+1]; Uptrend[x] = EMPTY_VALUE; } //Print( " trend=",trend[x]); } return(0); } -------------------------------------------------------------------------- I have to attempt insert this code but the Expert Advisor don`t start! sngSlope0 = NormalizeDouble(iCustom(NULL, 0, "Slope Direction Line", 80, 3, 0, 0, 0), 4); sngSlope1 = NormalizeDouble(iCustom(NULL, 0, "Slope Direction Line", 80, 3, 0, 1, 0), 4); if (sngSlope1>=sngSlope0) { // Long } else { // Short } Have One here qualities in MQL4 programming and can help me this EA to program? |
|
|||
|
Quote:
|
|
|||
|
Hi everyone.
I have made this EA. It works. I have not analyzed the Indicator well, but it is maybe a kind of <Heiken Ashi> or something. Type of Trading System is like MA cross reverse entry. It means You always have buy or sell position. note: 1. You need Custom Indicator named "Slope Direction Line" ,of course. 2. This EA uses previous bar to judge if Trend has changed. So it doesn't use "Future" Indicator value. 3. I added "TradeSwitch" function on this EA. You can turn off Buy or Sell Order. 4. I added "Fake Position Sizing" function on this EA. This algorithm decides lot size by volatility(ATR). But remember This EA doesn't set any stoploss. So you can't limit loss to be exact. That's why I call it "Fake". You can turn off the function if you don't want. 5. I recommend D1 timeframe to use this EA. 6. Don't use this EA on real money. It will need many improvements. enjoy. |
|
||||
|
is it has the ebook how to build EA?
![]()
__________________
Forex Technical Analysis : http://bankami.blogspot.com Forex Indicators : http://indicators-forex.blogspot.com |
|
|||
|
I have added some codes to indicate current entry price on the right side (for more fun).
System Logic itself has not changed at all. additional note: This EA open and close trade only at the bar opening. So you can backtest this EA by Open Price Only. Last edited by latimeria; 09-23-2008 at 09:58 AM. |
![]() |
| Bookmarks |
| Tags |
| slope direction line expert advisor, SlopeDirectionLine_v3, TrendEnvelopes_v2, slope direction, slope direction line, expert advisor, slope direction line ea, forex |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to create Expert Advisor for this wonderful indicator | torreseemee | Setup Questions | 3 | 07-24-2008 06:37 AM |
| How to make an expert advisor run other expert advisors in MQL4 | activetc | Metatrader 4 | 0 | 08-30-2007 04:29 AM |
| How to stop expert advisor from trading, when profit is made | joko75 | Expert Advisors - Metatrader 4 | 9 | 05-27-2007 12:16 PM |
| Need an indicator made | hidethereal | Indicators - Metatrader 4 | 12 | 09-28-2006 06:10 PM |