|
|||||||
| 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 |
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
||||
|
How do I make my EA execute?
this compiles with no errors but it isn't executing any trades when it's conditions are met. I think i did the MACD's ok but I'm not certain. I just want them to be showing positive or negative and I 'think' that means the signal line is above the indicator line for positive? but i'm not sure that it's not the indicator line above the signal line for positive? I'm not used to calling them signal and indicator i just know what they look like on the chart so if i'm not confused on that point then the logic is ok.
but beyond that this is not showing any results in the tester, it's just not executing despite having passed the compiler and giving the smiley face on the corner of the chart when attached... can someone see what's wrong with this? why it's not executing any orders? the other thing i would like to add to it is something to make it only be in one position at a time and not open any others until the previous one is close or simultaneously when it reverses. //+------------------------------------------------------------------+ //| This MQL is generated by Expert Advisor Builder | //| http://sufx.core.t3-ism.net/ExpertAdvisorBuilder/ | //| | //| In no event will author be liable for any damages whatsoever. | //| Use at your own risk. | //| | //| Please do not remove this header. | //+------------------------------------------------------------------+ #property copyright "Expert Advisor Builder" #property link "http://sufx.core.t3-ism.net/ExpertAdvisorBuilder/" extern int MagicNumber = 0; extern bool SignalMail = False; extern bool EachTickMode = False; extern double Lots = 1.0; extern int Slippage = 0; extern bool StopLossMode = True; extern int StopLoss = 8; extern bool TakeProfitMode = True; extern int TakeProfit = 15; extern bool TrailingStopMode = True; extern int TrailingStop = 8; #define SIGNAL_NONE 0 #define SIGNAL_BUY 1 #define SIGNAL_SELL 2 #define SIGNAL_CLOSEBUY 3 #define SIGNAL_CLOSESELL 4 int BarCount; int Current; bool TickCheck = False; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { BarCount = Bars; if (EachTickMode) Current = 0; else Current = 1; return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { int Order = SIGNAL_NONE; int Total, Ticket; double StopLossLevel, TakeProfitLevel; if (EachTickMode && Bars != BarCount) TickCheck = False; Total = OrdersTotal(); Order = SIGNAL_NONE; //+------------------------------------------------------------------+ //| Variable Begin | //+------------------------------------------------------------------+ double Buy1_1 = iMACD("EURUSD", PERIOD_M1, 3, 11, 2, PRICE_CLOSE, MODE_SIGNAL, Current + 0); double Buy1_2 = iMACD("EURUSD", PERIOD_M1, 3, 11, 2, PRICE_CLOSE, MODE_MAIN, Current + 0); double Buy2_1 = iClose("EURUSD", PERIOD_M1, Current + 0); double Buy2_2 = iMA("EURUSD", PERIOD_M1, 2, 0, MODE_EMA, PRICE_CLOSE, Current + 0); double Sell1_1 = iMACD("EURUSD", PERIOD_M1, 3, 11, 2, PRICE_CLOSE, MODE_SIGNAL, Current + 0); double Sell1_2 = iMACD("EURUSD", PERIOD_M1, 3, 11, 2, PRICE_CLOSE, MODE_MAIN, Current + 0); double Sell2_1 = iClose("EURUSD", PERIOD_M1, Current + 0); double Sell2_2 = iMA("EURUSD", PERIOD_M1, 2, 0, MODE_EMA, PRICE_CLOSE, Current + 0); double CloseBuy1_1 = iMACD("EURUSD", PERIOD_M1, 3, 11, 2, PRICE_CLOSE, MODE_SIGNAL, Current + 0); double CloseBuy1_2 = iMACD("EURUSD", PERIOD_M1, 3, 11, 2, PRICE_CLOSE, MODE_MAIN, Current + 0); double CloseBuy2_1 = iClose("EURUSD", PERIOD_M1, Current + 0); double CloseBuy2_2 = iMA("EURUSD", PERIOD_M1, 2, 0, MODE_EMA, PRICE_CLOSE, Current + 0); double CloseSell1_1 = iMACD("EURUSD", PERIOD_M1, 3, 11, 2, PRICE_CLOSE, MODE_SIGNAL, Current + 0); double CloseSell1_2 = iMACD("EURUSD", PERIOD_M1, 3, 11, 2, PRICE_CLOSE, MODE_MAIN, Current + 0); double CloseSell2_1 = iClose("EURUSD", PERIOD_M1, Current + 0); double CloseSell2_2 = iMA("EURUSD", PERIOD_M1, 2, 0, MODE_EMA, PRICE_CLOSE, Current + 0); //+------------------------------------------------------------------+ //| Variable End | //+------------------------------------------------------------------+ //Check position bool IsTrade = False; for (int i = 0; i < Total; i ++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if(OrderType() <= OP_SELL && OrderSymbol() == Symbol()) { IsTrade = True; if(OrderType() == OP_BUY) { //Close //+------------------------------------------------------------------+ //| Signal Begin(Exit Buy) | //+------------------------------------------------------------------+ if (CloseBuy1_1 < CloseBuy1_2 && CloseBuy2_1 < CloseBuy2_2) Order = SIGNAL_CLOSEBUY; continued on next post.... |
|
||||
|
two conditions for opening long.
MACD 3,11,2 is positive (above the zero line) Close is higher than EMA2 two conditions for opening short. MACD 3,11,2 is negative (below the zero line) Close is below the EMA2 the conditions for closing the positions is the same for opening the opposite direction so it reverses. Not because I think this is the best way to do closings but because that's all I could think of to do with the utility. I would like to see these opening rules followed up with a trailing stop loss and a take profit target option. It also needs a limitation to only be engaged in one trade at a time so it doesn't throw multiple orders each bar, just execute the order in the direction of the position the first time the conditions are met and then wait for that to close before executing another order. I would like to see this made so it can run and test on all timeframes. I would like to see a feature to sideline the program during specific hours of the day and have it active during certain hours of the day as many times on and off as the user defines. I would like to be able to change the periods of the MACD around and the periods of the moving averages used for the cross. In this case the two moving averages are a 1 period simple (the close) and a 2 period exponential. That should be able to be changed to allow any two moving averages to be played off. I really like the Hist_StepMA_Stoch_KV1_Ex_03.mq4 MACD but the build utility didn't have it offered it's custom and I didn't know how to get the utility to upload it. I'd really like to see the CatFX50 system built similarly into an EA with these added features. The goal is a trending system based on price movement that is able to be changed around to find what's the best combination of periods and timeframes. I would like to see a parameter to allow the user to rollover into the next position a user defined percentage of the account each time and have it just automatically decide how many lots that is so the user can manage/stabalize/hold constant the margin at risk. I'm open to any other idea to maximize and optimize it but I think that if just this much would be done it would be a great tool. I'm not aware of any other trending EA right now that does this much. Correct me if I'm wrong. Last edited by Aaragorn : 06-14-2006 at 05:20 AM. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Execute SQL from Metatrader | jhernandez | Metatrader 4 | 12 | 06-30-2008 02:57 AM |
| How can an EA Execute Script in the.... | babarmughal | Expert Advisors - Metatrader 4 | 2 | 05-16-2006 10:15 PM |