First ea attempt

 
Hi can someone please assist me. I have no knowledge of MQL but i have created my first EA. I am not sure if it will work and would appreciate some pointers from the experts. 
Files:
 
Martin I have no knowledge of MQL
  1. <edited by moderator>

  2. extern double lots = AccountBalance() / 3000; 
    RefreshRates();
    extern double SMAFast = iMA(NULL,0,MAFastPeriod,0,MODE_EMA,PRICE_CLOSE,1);
    extern double SMAMedium = iMA(NULL,0,MAMediumPeriod,0,MODE_EMA,PRICE_CLOSE,1);
    extern double SMASlow = iMA(NULL,0,MASlowPeriod,0,MODE_EMA,PRICE_CLOSE,1);
    
    Externs or global variables or static variable must be initialized with constants. Those variables never change. They are not input/external variables. Assign them in OnInit.
  3. Code can no be on global scope, only in functions.

  4. int start(){
    Start using the new Event Handling Functions.
              Event Handling Functions - Functions - Language Basics - MQL4 Reference

  5. IF trade_active = false && ((SMAFastPrev    <  SMAFast ...
    
    ELSE
    IF trade_active = true && ...
    
    
    IF @SMAFastPrev < @SMAFast
     && @SMAFast >= @SMASlow
     && @SMAFastPrev < @SMASlow
    
    
    Don't post code that won't even compile.

  6. extern int trade_type;
    Can't be an extern. What does trade_type 1, 9, and zero mean? Perhaps you mean an enumeration not an int.

  7. ticket=OrderSend(Symbol(),OP_BUY,lots,Ask,slippage,stopLoss,takeProfit,"buy",magicNumber,0,Green;
    
    Check your return codes for errors and report them.
              What are Function return values ? How do I use them ? - MQL4 and MetaTrader 4 - MQL4 programming forum
              Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles

  8. OrderClose(OrderTicket(),lots,Ask,slippage,Red);
    Check your return codes for errors and report them.
  9. You can not use any Trade Functions until you select an order.
  10. You buy at the Ask and sell at the Bid.
    • Your buy order's TP/SL are triggered when the Bid reaches it. Not the Ask.
    • Your sell order's TP/SL will be triggered when the Ask reaches it. To trigger at a specific Bid price, add the average spread.
                MODE_SPREAD (Paul) - MQL4 and MetaTrader 4 - MQL4 programming forum - Page 3
    • The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools -> Options {control-O} -> charts -> Show ask line.)
Reason: