#include<Trade\Trade.mqh>
#include <Trade\PositionInfo.mqh>
#include <Trade\Trade.mqh>
#include <Trade\SymbolInfo.mqh>  
#include <Trade\AccountInfo.mqh>
#include <Trade\DealInfo.mqh>
#include <Trade\OrderInfo.mqh>
#include <Expert\Money\MoneyFixedMargin.mqh>
CPositionInfo  m_position;                   // trade position object
CTrade         m_trade;                      // trading object
CSymbolInfo    m_symbol;                     // symbol info object
CAccountInfo   m_account;                    // account info wrapper
CDealInfo      m_deal;                       // deals object
COrderInfo     m_order;                      // pending orders object
CMoneyFixedMargin *m_money;

         
// Create an instance from CTrade
CTrade trade;

void OnTick()
   {
   //We calculate the ask price
   double Ask=NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK),_Digits);
   
   //We calculate the bid price
   double Bid=NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID),_Digits);
   
   // Create String for the signal
   string signal="";
   
   //Create an array from prices
   MqlRates PriceInformation[];
   
   // Sort the array from the current candle downwards
   ArraySetAsSeries(PriceInformation, true);
   
   // Copy prices data into the array
   int Data=CopyRates(Symbol(),Period(),0,3, PriceInformation);
   
   double ao_array[];
   ArraySetAsSeries(ao_array,true);
   int buffer=0,start_pos=-100,count=1;
   
   
   // Create a price array
   double PriceArray[];
   
   // define the Awesome oscillator EA
   int AwesomeOscillatorDefinition = iAO(_Symbol,_Period);
   
   //Sort the array from the current candle downwards
   ArraySetAsSeries(PriceArray,true);
   
   // Define EA, current candle, 3 candles, save the result
   CopyBuffer(AwesomeOscillatorDefinition, 0, 0, 5, PriceArray);
   
   //Calculate the EA for the current candle
   double AwesomeOscillatorValue=NormalizeDouble(PriceArray[0],6);
   
   //If AO value is below -3
   if (AwesomeOscillatorValue>3 && PriceArray[2]< PriceArray[1])
   
   signal="sell";
   
   //Sell 15 microlots
   if (signal =="sell"&& PositionsTotal()<1)
   trade.Sell(0.30,NULL,Bid,Bid+150*_Point,(Bid-2000*_Point),NULL);
   
   if (AwesomeOscillatorValue<-3 && PriceArray[1]< PriceArray[2])
   
   signal="Sell+"; 
   
   if (signal=="Sell+")
   if (PositionsTotal () <10)
   trade.Sell(0.30,NULL,Bid,Bid+150*_Point, Bid-2000*_Point,NULL);  
  
   //Create chart output
   Comment ("The current signal is: ",signal);

}
//+------------------------------------------------------------------+
