//+------------------------------------------------------------------+
//|                                          LinearRegression EA.mq5 |
//|                                                       Joy D Moyo |
//|                                               www.latvianfts.com |
//+------------------------------------------------------------------+
#property copyright "Joy D Moyo"
#property link      "www.latvianfts.com"
#property version   "1.00"

#include <Trade\Trade.mqh>
CTrade *Trade;
CPositionInfo PositionInfo;

input group "GENERAL INPUTS"
input int EAMagic = 1232;
input string MySymbol = "EURUSD";
input ENUM_TIMEFRAMES MyTimeFrame = PERIOD_M15;
input int MaxSlippage = 1;

input group "INDICATOR INPUTS"
input int RegressionPeriod = 1000;

input group "RISK INPUTS"
input double BalanceIncrease = 3000;
input double VolumeIncrease = 0.02;

input group "TRADE MANAGEMENT INPUTS"
input int MinTradeDistance = 10;

int OldNumBars,LRHandle,MyDigits;
double RegressionLine[],OverBoughtLine[],OverSoldLine[],UpperExtremeLine[],LowerExtremeLine[],PriceClose[],Ask,Bid,MyPoint,LotMax,LotMin,LotStep,
       NextBuyPrice,NextSellPrice,MinTradeDistancePnts;
string BuyComment = "Buy",SellComment = "Sell";


//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool NewBar()
  {
   if(OldNumBars!=Bars(MySymbol,MyTimeFrame))
     {OldNumBars=Bars(MySymbol,MyTimeFrame);return true;}
   return false;
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int NumTrades(const ENUM_POSITION_TYPE PosType)
  {
   int Num = 0;
   for(int i=PositionsTotal()-1;i>=0;i--)
     {
      if(PositionInfo.SelectByIndex(i))
        {
         if(PositionInfo.Magic()!=EAMagic)
            continue;
         if(PositionInfo.Symbol()!=MySymbol)
            continue;
         if(PositionInfo.PositionType()!=PosType)
            continue;
         Num++;
        }
     }
   return Num;
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double LotSize()
  {
   double Lot = VolumeIncrease*AccountInfoDouble(ACCOUNT_BALANCE)/BalanceIncrease;
   Lot = MathRound(Lot/LotStep)*LotStep;
   if(Lot>LotMax)
      Lot = LotMax;
   if(Lot<LotMin)
      Lot = LotMin;
   return Lot;
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool OSBuySignal()
  {
   if(PriceClose[1]>OverSoldLine[1]&&PriceClose[2]<OverSoldLine[2])
      return true;
   return false;
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool ExBuySignal()
  {
   if(PriceClose[1]>LowerExtremeLine[1]&&PriceClose[2]<LowerExtremeLine[2])
      return true;
   return false;
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool OBSellSignal()
  {
   if(PriceClose[1]<OverBoughtLine[1]&&PriceClose[2]>OverBoughtLine[2])
      return true;
   return false;
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool ExSellSignal()
  {
   if(PriceClose[1]<UpperExtremeLine[1]&&PriceClose[2]>UpperExtremeLine[2])
      return true;
   return false;
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool CloseBuySignal()
  {
   if(PriceClose[1]>RegressionLine[1]&&PriceClose[2]<RegressionLine[2])
      return true;
   return false;
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool CloseSellSignal()
  {
   if(PriceClose[1]<RegressionLine[1]&&PriceClose[2]>RegressionLine[2])
      return true;
   return false;
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool BullishGradient()
  {
   if(RegressionLine[1]>RegressionLine[2])
      return true;
   return false;
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool BearishGradient()
  {
   if(RegressionLine[1]<RegressionLine[2])
      return true;
   return false;
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OSBuy()
  {
   if(!OSBuySignal())
      return;

   if(NumTrades(POSITION_TYPE_BUY)!=0)
      if(Ask>NextBuyPrice)
         return;
   double LotUsed;
   if(BullishGradient())
      LotUsed = 3*LotSize();
   else
      LotUsed = LotSize();

   if(Trade.Buy(LotUsed,MySymbol,Ask,0,0,BuyComment))
      NextBuyPrice = Ask-MinTradeDistancePnts;
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void ExBuy()
  {
   if(!ExBuySignal())
      return;

   if(NumTrades(POSITION_TYPE_BUY)!=0)
      if(Ask>NextBuyPrice)
         return;
   double LotUsed;
   if(BullishGradient())
      LotUsed = 4*LotSize();
   else
      LotUsed = 2*LotSize();

   if(Trade.Buy(LotUsed,MySymbol,Ask,0,0,BuyComment))
      NextBuyPrice = Ask-MinTradeDistancePnts;
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OBSell()
  {
   if(!OBSellSignal())
      return;
   if(NumTrades(POSITION_TYPE_SELL)!=0)
      if(Bid<NextSellPrice)
         return;
   double LotUsed;
   if(BearishGradient())
      LotUsed = 3*LotSize();
   else
      LotUsed = LotSize();

   if(Trade.Sell(LotUsed,MySymbol,Bid,0,0,SellComment))
      NextSellPrice = Bid+MinTradeDistancePnts;
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void ExSell()
  {
   if(!ExSellSignal())
      return;
   if(NumTrades(POSITION_TYPE_SELL)!=0)
      if(Bid<NextSellPrice)
         return;
   double LotUsed;
   if(BearishGradient())
      LotUsed = 4*LotSize();
   else
      LotUsed = 2*LotSize();

   if(Trade.Sell(LotUsed,MySymbol,Bid,0,0,SellComment))
      NextSellPrice = Bid+MinTradeDistancePnts;
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double AvgPrice(const ENUM_POSITION_TYPE PosType)
  {
   double tot = 0,avg = 0;
   int Num = 0;
   for(int i=PositionsTotal()-1;i>=0;i--)
     {
      if(PositionInfo.SelectByIndex(i))
        {
         if(PositionInfo.Magic()!=EAMagic)
            continue;
         if(PositionInfo.Symbol()!=MySymbol)
            continue;
         if(PositionInfo.PositionType()!=PosType)
            continue;
         Num++;
         tot+=PositionInfo.PriceOpen();
        }
     }
   avg = tot/Num;
   return NormalizeDouble(avg,MyDigits);
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CloseTrades(const ENUM_POSITION_TYPE PosType)
  {
   for(int i=PositionsTotal()-1;i>=0;i--)
     {
      if(PositionSelectByTicket(PositionGetTicket(i)))
        {
         if(PositionGetInteger(POSITION_MAGIC)!=EAMagic)
            continue;
         if(PositionGetInteger(POSITION_TYPE)!=PosType)
            continue;
         Trade.PositionClose(PositionGetInteger(POSITION_TICKET));
        }
     }
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CloseBuy()
  {
   if(NumTrades(POSITION_TYPE_BUY)>1)
     {
      if(Ask>AvgPrice(POSITION_TYPE_BUY))
         CloseTrades(POSITION_TYPE_BUY);
      else
         return;
     }
   else
     {
      if(CloseBuySignal())
         CloseTrades(POSITION_TYPE_BUY);
      else
         return;
     }
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CloseSell()
  {
   if(NumTrades(POSITION_TYPE_SELL)>1)
     {
      if(Bid<AvgPrice(POSITION_TYPE_SELL))
         CloseTrades(POSITION_TYPE_SELL);
      else
         return;
     }
   else
     {
      if(CloseSellSignal())
         CloseTrades(POSITION_TYPE_SELL);
      else
         return;
     }
  }

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   ChartSetInteger(0,CHART_SHOW_GRID,false);
   ChartSetInteger(0,CHART_SHOW_VOLUMES,false);
   ChartSetInteger(0,CHART_COLOR_STOP_LEVEL,clrGold);
   ChartSetInteger(0,CHART_COLOR_BACKGROUND,clrBlack);
   ChartSetInteger(0,CHART_COLOR_FOREGROUND,clrWhite);
   ChartSetInteger(0,CHART_COLOR_CANDLE_BEAR,clrWhite);
   ChartSetInteger(0,CHART_COLOR_CHART_DOWN,clrWhite);
   ChartSetInteger(0,CHART_COLOR_CANDLE_BULL,clrDodgerBlue);
   ChartSetInteger(0,CHART_COLOR_CHART_UP,clrDodgerBlue);
   ChartSetInteger(0,CHART_MODE,CHART_CANDLES);

   OldNumBars = Bars(MySymbol,MyTimeFrame);

   Trade = new CTrade;
   Trade.SetExpertMagicNumber(EAMagic);
   Trade.SetDeviationInPoints(MaxSlippage*10);

   LRHandle = iCustom(MySymbol,MyTimeFrame,"LinearRegression",RegressionPeriod);

   ArraySetAsSeries(RegressionLine,true);
   ArraySetAsSeries(OverBoughtLine,true);
   ArraySetAsSeries(OverSoldLine,true);
   ArraySetAsSeries(UpperExtremeLine,true);
   ArraySetAsSeries(LowerExtremeLine,true);
   ArraySetAsSeries(PriceClose,true);

   MyPoint = SymbolInfoDouble(MySymbol,SYMBOL_POINT);
   MyDigits = (int)SymbolInfoInteger(MySymbol,SYMBOL_DIGITS);

   LotMax = SymbolInfoDouble(MySymbol,SYMBOL_VOLUME_MAX);
   LotMin = SymbolInfoDouble(MySymbol,SYMBOL_VOLUME_MIN);
   LotStep = SymbolInfoDouble(MySymbol,SYMBOL_VOLUME_STEP);

   MinTradeDistancePnts = MinTradeDistance*10*MyPoint;

   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   delete Trade;

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   if(!NewBar())
      return;

   Ask = SymbolInfoDouble(MySymbol,SYMBOL_ASK);
   Bid = SymbolInfoDouble(MySymbol,SYMBOL_BID);

   CopyBuffer(LRHandle,0,0,4,RegressionLine);
   CopyBuffer(LRHandle,1,0,4,OverBoughtLine);
   CopyBuffer(LRHandle,2,0,4,OverSoldLine);
   CopyBuffer(LRHandle,3,0,4,UpperExtremeLine);
   CopyBuffer(LRHandle,4,0,4,LowerExtremeLine);

   CopyClose(MySymbol,MyTimeFrame,0,4,PriceClose);

   OSBuy();
   ExBuy();
   OBSell();
   ExSell();
   
   CloseBuy();
   CloseSell();

  }
//+------------------------------------------------------------------+


quero que o codigo sempre abra ordens de apenas 0.01 nada de aumentar o lote mesmo caso tenha maior probabilidade de asserto  da analise!
altere isso e me entregue o codigo completo