//+------------------------------------------------------------------+
//|                                       TradeAssistant Advisor.mq4 |
//|                       Copyright © 2009, Djscore, Forexcapital.ru |
//|                                       http://www.forexcapital.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, Djscore, Forexcapital.ru"
#property link      "http://www.forexcapital.ru"

int     TF[]              = {5,15,30,60,240,1440};
int     eCCI[]            = {14,14,6,6,6,6};
int     tCCI[]            = {50,34,14,14,14,14};
int x;
string pokazatel;
bool stochbuy[], stochsell[], rsibuy[], rsisell[], ccibuy[], ccisell[], trendccibuy[], trendccisell[];
string  periodStr[]       = {"5 MIN:","15 MIN:","30 MIN:","1 HR:","4 HR:","1 DAY:"};
string  signalNameStr[]   = {"STOCH","RSI","EntryCCI","TrendCCI"};
extern double Lots=0.01;
extern double TakeProfit=0.07;
extern  string  Stochastic_Settings   = "=== Stochastic Settings ===";
extern  int     PercentK              = 8;
extern  int     PercentD              = 3;
extern  int     Slowing               = 3;

extern  string  RSI_Settings          = "=== RSI Settings ===";
extern  int     RSIP1                 = 14;
extern  int     RSIP2                 = 70;  

extern  string  My_Symbols            = "=== Wingdings Symbols ===";
extern  int     sBuy                  = 233;
extern  int     sSell                 = 234;
extern  int     sWait                 = 54;
extern  int     sCCIAgainstBuy        = 238;
extern  int     sCCIAgainstSell       = 236;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
    //--- stochastics text
    for(x=0;x<6;x++)
    {
      if((iStochastic(NULL,TF[x],PercentK,PercentD,Slowing,MODE_SMA,0,MODE_MAIN,0)) >  
         (iStochastic(NULL,TF[x],PercentK,PercentD,Slowing,MODE_SMA,0,MODE_SIGNAL,0)))
        stochbuy[x]=true;
      else if             
        ((iStochastic(NULL,TF[x],PercentK,PercentD,Slowing,MODE_SMA,0,MODE_SIGNAL,0)) >
        (iStochastic(NULL,TF[x],PercentK,PercentD,Slowing,MODE_SMA,0,MODE_MAIN,0)))
        stochsell[x]=true;
      else
        {stochbuy[x]=false; stochsell[x]=false;}
    }    

    //--- RSI text
    for(x=0;x<6;x++)
    {
      if ((iRSI(NULL,TF[x],RSIP1,PRICE_TYPICAL,0)) > (iRSI(NULL,TF[x],RSIP2,PRICE_TYPICAL,0)))
        rsibuy[x]=true;
      else if             
        ((iRSI(NULL,TF[x],RSIP2,PRICE_TYPICAL,0)) > (iRSI(NULL,TF[x],RSIP1,PRICE_TYPICAL,0)))
        rsisell[x]=true;
      else
        {rsibuy[x]=false; rsisell[x]=false;}
    }  
    
    //--- EntryCCI text
    for(x=0;x<6;x++)
    {
      if ((iCCI(NULL,TF[x],eCCI[x],PRICE_TYPICAL,0)) >0) // if entry cci above zero
        {
        if ((iCCI(NULL,TF[x],eCCI[x],PRICE_TYPICAL,0))>(iCCI(NULL,TF[x],eCCI[x],PRICE_TYPICAL,1)))
        ccibuy[x]=true; 
        else ccisell[x]=true; 
      }
      else if             
        ((iCCI(NULL,TF[x],eCCI[x],PRICE_TYPICAL,0)) <0) // if entry cci below zero
        {
        if ((iCCI(NULL,TF[x],eCCI[x],PRICE_TYPICAL,0))<(iCCI(NULL,TF[x],eCCI[x],PRICE_TYPICAL,1)))
        ccisell[x]=true;
        else ccibuy[x]=true; 
      }
      else
        {ccibuy[x]=false; ccisell[x]=false;} 
    } 
   
    //--- TrendCCI text
    for(x=0;x<6;x++)
    {
      if ((iCCI(NULL,TF[x],tCCI[x],PRICE_TYPICAL,0)) >0) // if entry cci above zero
        {
        if ((iCCI(NULL,TF[x],tCCI[x],PRICE_TYPICAL,0))>(iCCI(NULL,TF[x],tCCI[x],PRICE_TYPICAL,1)))
        trendccibuy[x]=true; 
        else trendccisell[x]=true; 
      }
      else if             
        ((iCCI(NULL,TF[x],tCCI[x],PRICE_TYPICAL,0)) <0) // if entry cci below zero
        {
        if ((iCCI(NULL,TF[x],tCCI[x],PRICE_TYPICAL,0))<(iCCI(NULL,TF[x],tCCI[x],PRICE_TYPICAL,1)))
        trendccisell[x]=true;         
        else trendccibuy[x]=true; 
      }
      else
        {trendccibuy[x]=false;trendccisell[x]=false;}
    } 
    if (stochbuy[0]&&stochbuy[1]&&stochbuy[2]&&stochbuy[3]&&rsibuy[0]&&rsibuy[1]&&rsibuy[2]&&rsibuy[3]&&ccibuy[0]&&ccibuy[1]&&ccibuy[2]&&ccibuy[3]&&trendccibuy[0]&&trendccibuy[1]&&trendccibuy[2]&&trendccibuy[3])
    OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point,"TAA BUY",12435,0,Green);
    if (stochsell[0]&&stochsell[1]&&stochsell[2]&&stochsell[3]&&rsisell[0]&&rsisell[1]&&rsisell[2]&&rsisell[3]&&ccisell[0]&&ccisell[1]&&ccisell[2]&&ccisell[3]&&trendccisell[0]&&trendccisell[1]&&trendccisell[2]&&trendccisell[3])
    OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid-TakeProfit*Point,"TAA SELL",12435,0,Green);
   return(0);
  }

