Need assistance with Coding

 

Good Evening,

First time coding, and used a Simple EA (from the book; thanks to the author!) code as my starting point, altering the basis of the indicators.

The issues with my EA:

1) When compiled, I get the dreaded "end_of_program" - unbalanced left parenthesis error code. I have not been able to identify what the issue is exactly related to. I can identify where the code issue supposedly lies, but darn if I have been able identify where the left parenthesis should be.

2) I can not get this EA to backtest, and not sure if it is related to issue 1 above (thought it probably is), or something else. When I compiled the code as originally taken from the book, it compiled with no errors or warnings. However, that code, in it original form would not back test either. Not sure if the author had set up the code in such a way that it's use could not be actively applied (Marked as for educational purposes only) to back testing or forward testing/use.


Any direction is greatly appreciated.


Thanks in advance!!!


CountingMan

Files:
 

Well, look at the MathFloor() lines, missing ending ) there.

But...

That just lets the compiler uncover more problems...

 

as phy sais

change to this:

else                                         // % of free margin      
      MathFloor(AccountMargin*Prots/MarketInfo(Symb,MODE_MARGINREQUIRED)/MarketInfo(Symb,MODE_LOTSTEP)*MarketInfo(Symb,MODE_LOTSTEP));  // For opening    
   if(MathFloor(AccountFreeMargin()*Prots/MarketInfo(Symb,MODE_MARGINREQUIRED)/MarketInfo(Symb,MODE_LOTSTEP)*MarketInfo(Symb,MODE_LOTSTEP)) > MarketInfo(Symb,MODE_MINLOT))MarketInfo(Symb,MODE_MINLOT);               // Not less than minimal   
  

and you'll discover some errors you've made. happy error searching =)


//enotrek

 
enotrek:

as phy sais

change to this:

and you'll discover some errors you've made. happy error searching =)


//enotrek


enotrek,

Thanks for the code corrections. Wow, you were right; I do have some errors to fix.

To all

I have seen other EA's with lists of function that lay out in an abbreviated fashion what the different components mean. I assumed that if you labled something like this, that MQL would translate the items and assign them correctly:

MA_1_t=iMA(NULL,0,Period_MA_1,0,MODE_LWMA,PRICE_TYPICAL,0); // MA_1
MA_2_t=iMA(NULL,0,Period_MA_2,0,MODE_LWMA,PRICE_TYPICAL,0); // MA_2

if (MA_1_t > MA_2_t + Rastvor) // If difference between
{ // ..MA 1 and 2 is large
Opn_B=true; // Criterion for opening Buy
Cls_S=true; // Criterion for closing Sell
}

Based on the "variable not defined" errors that I have received, this is not the case. So, it is safe to say that in all cases there there is a "listing of defined items" such as the following, and am getting the "variable not defined" error, that those that are causing such error should be deleted?

nt start()
{
int
Total, // Amount of orders in a window
Tip=-1, // Type of selected order (B=0,S=1)
Ticket; // Order number double
MA_1_t, // Current MA_1 value -Compiling error
MA_2_t, // Current MA_2 value -Compiling error
Lot, // Amount of lots in a selected order -Compiling error
Lts, // Amount of lots in an opened order -Compiling error
Min_Lot, // Minimal amount of lots -Compiling error
Step, // Step of lot size change -Compiling error
Free, // Current free margin -Compiling error
One_Lot, // Price of one lot -Compiling error
Price, // Price of a selected order -Compiling error
SL, // SL of a selected order -Compiling error
TP; // TP ?? a selected order -Compiling error
bool
Ans =false, // Server response after closing
Cls_B=false, // Criterion for closing Buy
Cls_S=false, // Criterion for closing Sell
Opn_B=false, // Criterion for opening Buy
Opn_S=false; // Criterion for opening Sell

Thanks again to all for their guidance!

CountingMan

 

nt start()
{
int
Total, // Amount of orders in a window
Tip=-1, // Type of selected order (B=0,S=1)
Ticket; // Order number double

semicolon above closed the statement. need int or double or something
here MA_1_t, // Current MA_1 value -Compiling error
MA_2_t, // Current MA_2 value -Compiling error
Lot, // Amount of lots in a selected order -Compiling error
Lts, // Amount of lots in an opened order -Compiling error
Min_Lot, // Minimal amount of lots -Compiling error
Step, // Step of lot size change -Compiling error
Free, // Current free margin -Compiling error
One_Lot, // Price of one lot -Compiling error
Price, // Price of a selected order -Compiling error
SL, // SL of a selected order -Compiling error
TP; // TP ?? a selected order -Compiling error

Reason: