Forex-ID10T EA (Working but not trading!)

 

Author: ForexID10T

EA created from code generated by EA Builder (http://eatbuilder.com/). Added my own code and enhancements, plus ideas adapted from this forum. Many ideas to still impliment, but first this initial EA must work before applying further enhancements. (More than one open trade etc) There are brilliant ideas and complicated code on this forum, but the idea is to first do something simple before engaging into the complicated algorythms and advanced code found on this site. I would rather create something simple first and build from there than trying to take / steal something and claim it as my own.

I NEED HELP!:

I have been trying to debug my code for the reason why the EA is not trading for the past two days without any luck! The comments on chart screen shows that everything is working as it is supposed to - show when buy or sell and exits are generated but no trades!

I have double checked the open and closing of curley brackets and even re-applied the code to a empty template - no success! I know this must work but obviously I either broken the rules of MQL4 programming or I did something foolish. Your assistance to find the issue why the EA is not trading would will be highly appreciated. I am really starting to look at my own eyelids and feel really stupid!

EA Description:

EA is gathering signal information from different standard indicators (MA Slow & Fast, Bollinger, Stohastic, MACD, RSI) to determine if the market trend is either Bullish, Bearish or Flat (ZigZag). The final idea is to apply 3 strategies of which only one (RSI & STOH signals) with Buy/Sell and Exit signals are currently coded into the EA. The other two will be based upon BEAR/BULL signals (Of which most of the code is already included, except the buy/sell and exit codes) and Bollinger events (Of which most of the code is already included, except the buy/sell and exit codes).

The purpose of the code is to extract the maximum PIPS from any trade entered into. Theorotically the Take Profit, Stop Loss and Trailing Stop should never hit as the BUY/SELL and EXIT signals should initiate and close trades before any stops are hit (Same as ZigZag indicator). These setting are only there to safeguard the deposit in the event something goes wrong with the entry/exit signals. I also need to add filters to ensure the EA only enters a trade once - if you look at the comments on the chart you will see thousands of SELL signals but no BUY signals. This is also baffling as the BUY/SELL signals is supposed to be symetric?

As a novice, I think the descriptions inside the code will be easy enough for anybody to read. Note that I only started with MQL4 in December 2009 and my background is mostly VB scripting (Google copy and paster!) - thus all this is both familiar and new to me. The syntax is different and obviously the rules of coding is different. Still a LOT to learn about MQL4!

EA must be compiled before using - mq4 extension must become ex4 & the ex4 compiled file must be loaded into the experts directory

Template included will add all the indicators I used to the active chart - provided you have these indicators ... All are standard except zigzag - can be downloaded from this forum.

To spare you the download I have place all the source code here, just copy and past into the MQL editor and save.

The source code:

(Source code removed as it takes up too much space - check latest post - 05 January 2010)

 
Just in case you cannot find the ZigZag indicator ...
Files:
zigzag.mq4  4 kb
 
Template of my settings - Have not yet determined the best currency pair or timeframe. I just know EUR/USD and EUR/CHF are supposed to give nice swings and huge profits (If you get it right!)
Files:
 

The first thing ..what errors are being generated..??

Actually on Alpari demo it does trade..(doesn't make any profit though)....

 
No errors! In backtest it is running like a charm, showing everything on the chart, BUT NO TRADES! I really feel like an ID10t!
 
ForexID10T wrote >>
No errors! In backtest it is running like a charm, showing everything on the chart, BUT NO TRADES! I really feel like an ID10t!

After the Ordersend function you check to see if the ticket > 0

If the statement returns a true value it means that your order was placed.

You do not check the false of that statement

include an else statement.

This will be when the trade instruction failed.

use the GetLstError() function in there to see what errors are being generated.

You can not say that no errors are being generated if you did not check to verify that statement!

whocares

 
Maybe if you can provide some "error handling code" we could become wiser? Try the EA on a backtest - M15 using EUR/CHF and see what I am talking about. I am really frustrated ... because I know it MUST work!
 
whocares wrote >>

After the Ordersend function you check to see if the ticket > 0

If the statement returns a true value it means that your order was placed.

You do not check the false of that statement

include an else statement.

This will be when the trade instruction failed.

use the GetLstError() function in there to see what errors are being generated.

You can not say that no errors are being generated if you did not check to verify that statement!

whocares

Dear whocares

I am completely new to MQL4 language programming - I know what you are suggesting but I am not that familiar with what exactly to do - please provide the code I must add and I will test again.

If you please? AND Thank you in advance!

 
n8937g wrote >>

The first thing ..what errors are being generated..??

Actually on Alpari demo it does trade..(doesn't make any profit though)....

Dear n8937g

Trading? You want to tell me that my code is actually WORKING? Making trades?

(Reason not trading because it was the weekend? Cannot be that simple :)

I will imediately test again!

 
ForexID10T wrote >>

Dear whocares

I am completely new to MQL4 language programming - I know what you are suggesting but I am not that familiar with what exactly to do - please provide the code I must add and I will test again.

If you please? AND Thank you in advance!

There is already a getlasterror function in the code. However, it looks like (on first inspection) that your curly brackets claaing it is in the wrong place

This is what you have (I just shuffled the layout to make it easier to read):

Ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, StopLossLevel, TakeProfitLevel, "Buy(#" + MagicNumber + ")", MagicNumber, 0, DodgerBlue);
if(Ticket > 0)

{
if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES))

{
Print("BUY order opened : ", OrderOpenPrice());
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Open Buy");
}

else

{
Print("Error opening BUY order : ", GetLastError());
}
}
if (EachTickMode) TickCheck = True;
etc...

If you count the open curly brackets against the close curly brackets, it appears as if the else statement relates to the OrderSelect if statement and not the previous Ticket>0 statement.

Try making this modification:

Ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, StopLossLevel, TakeProfitLevel, "Buy(#" + MagicNumber + ")", MagicNumber, 0, DodgerBlue);
if(Ticket > 0)

{
if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES))

{
Print("BUY order opened : ", OrderOpenPrice());
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Open Buy");
}

}

else

{
Print("Error opening BUY order : ", GetLastError());
}
if (EachTickMode) TickCheck = True;
etc...

Note that the change is only in where the brackets are.

Remember to do the same for the other Ordersend function.

whocares

 

Dear whocares

Thank you for spotting this OBVIOUS mistake - being a Google Copy & Paster I would never have found this! I will add the corrections as suggested, test and get back to you.

THANK YOU once again!