guys ur help are on my new EA.

 

Hello Everyone,

Am currently building an EA thats base on the ichimoku kinko hyo system i have  manage to code a few lines but am close to no where, cos the EA is incomplete and its giving me errors.

Firstly, am having problem in putting the trailing stop in my code so that once the price hit the take profit it increases in pips specified in the trailing stop and the stop loss reduces in pips too.

secondly, am getting "if' - expressions are not allowed on a global scope" on several lines i have tried everything i know of in MQL4 but it seems its not enough.

thirdly, to those of you that knowns how ichimoku operates, am thinking whether its possible to include the Chikou span strategy - so that if the Chikou span is in price 26

//+------------------------------------------------------------------+
//|                                           Ichimoku Prototype.mq4 |
//|                                              Wami Ikechukwu Kanu |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Wami Ikechukwu Kanu"
#property link      ""
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| EXTERNAL VARIBLE                                                 |
//+------------------------------------------------------------------+
extern double Lots = 0.10;                         // Amount of lots to trade with.
extern double TakeProfit = 0;                      // The requested close price that determines the maximum profit for the given trade.
extern double TrailingStop = 0;                    // Min number of pips in profit for the trailing stop to start
extern double StopLoss = 0;                        // The requested close price that determines the maximum loss allowed for the given trade
extern double TenkanSen = 9;                       // Tenkan-sen (highest high + lowest low)/2 for the last 9 periods
extern double KijunSen = 26;                       // Kijun-sen (highest high + lowest low)/2 for the past 26 periods
extern double SenkouspanA = 26;                    // Senkou-spanA (Tenkan-sen + Kijun-sen)/2 time-shifted forwards (into the future)26 period.
extern double SenkouspanB = 52;                    // Senkou-spanB (highest high + lowest low)/2 for the past 52 periods timeshifted forwards (into the future) 26 period
extern double Chikouspan =26;                      // Current closing price time-shifted backwards (into the past) 26 periods
//-------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| EXPERT INITIALIAZATION FUNCTION                                  |
//+------------------------------------------------------------------+
int Init()                                         // Special function initialiazation
{
  //---
  
  //---
  
  return(0);                                       // Exit Init()
}

//+------------------------------------------------------------------+
//| EXPERT DEINITIALIAZATION FUNCTION                                |
//+------------------------------------------------------------------+
int Deinit()                                       // Special function deinitialiazation        
  {
//---

//---
return(0);                                        // Exit Deinit()
  }
  
//+------------------------------------------------------------------+
//| START ALGORITHM                                                  |
//+------------------------------------------------------------------+

//Indicator Varibles Decleration
{                                                  
double TenkanSen=iIchimoku(NULL, 0, 9, 26, 52, MODE_TENKANSEN, 1, 0);
double KijunSen=iIchimoku(NULL, 0, 9, 26, 52, MODE_KIJUNSEN, 2, 0);
double SenkouspanA=iIchimoku(NULL, 0, 9, 26, 52, MODE_SENKOUSPANA, 3, 0);
double SenkouspanB=iIchimoku(NULL, 0, 9, 26, 52, MODE_SENKOUSPANB, 4, 0);
double Chikouspan=iIchimoku(NULL, 0, 9, 26, 52, MODE_CHIKOUSPAN, 5, 0);
}
      
//---------------------------------------------------------------------

int start()                                       // Special function start
       {
        Alert(Symbol()," Sell = ",AccountFreeMargin()      // At selling    
        -AccountFreeMarginCheck(Symbol(),OP_SELL,1));
        Alert(Symbol()," Buy = ",AccountFreeMargin()       // At buying
        -AccountFreeMarginCheck(Symbol(),OP_BUY,1));
        return(0);                                         // Exit start()
       }
      
          
if (IsTradeAllowed() == false)                     // Header of the operator and condition
{
Comment("Trade not allowed.");                     // This is a Comment
return;
else
Comment("Trade allowed")
}

if (TenkanSen>KijunSen && SenkouspanA>SenkouspanB)  // Header of the operator and condition
{
OrderSend("sysmbol()",OP_BUY,Lots,Ask,0,StopLoss,TakeProfit,NULL,0,0,Blue);
Alert (GetLastError());                       // Error message
return;                                       // Exit start()
else
Alert (TenkanSen is not greater than KijunSen and SenkouspanA is not greater than SenkouspanB /n So it is not a buy signal)
if (Bid==StopLoss)                             // Header of the operator and condition
{
OrderClose(OrderTicket(),Lots,Bid,0,Black);
}  
}

if (TenkanSen<KijunSen && SenkouspanA<SenkouspanB)   // Header of the operator and condition
{
OrderSend("sysmbol()",OP_SELL,Lots,Ask,0,StopLoss,TakeProfit,NULL,0,0,Red);
Alert (GetLastError());                       // Error message
return;                                       // Exit start()
else
Alert(TenkanSen is not less than KijunSen and SenkouspanA is not less than SenkouspanB /n So it is not a sell signal)
if (Bid==StopLoss)
{                            // Header of the operator and condition
OrderClose(OrderTicket(),Lots,Bid,0,Black);
}
}


period ago it will wait until its out of price before executing a buy or sell.

finally, guys i really need your help in this please AM STUCK..... 

'  

 
Nkechi Sonia Kanu: secondly, am getting "if' - expressions are not allowed on a global scope" on several lines i have tried everything i know of in MQL4 but it seems its not enough.
This is your start function
int start()                                       // Special function start
       {
        Alert(Symbol()," Sell = ",AccountFreeMargin()      // At selling    
        -AccountFreeMarginCheck(Symbol(),OP_SELL,1));
        Alert(Symbol()," Buy = ",AccountFreeMargin()       // At buying
        -AccountFreeMarginCheck(Symbol(),OP_BUY,1));
        return(0);                                         // Exit start()
       }
The group just above and everything below that is not inside a function, therefor on global scope. What part of "not allowed" is unclear?