forex software

Create and Test Forex Strategies

forex software

Skip to forum content

Forex Forum

Forex Software, Forex Strategies, Expert Advisors Generator

You are not logged in. Please login or register.


Forex Forum → Expert Advisor Modifications → Portfolio Risk Per trade

Pages 1

You must login or register to post a reply

RSS topic feed

Posts: 1

Topic: Portfolio Risk Per trade

Hey guys so I just need some help with a little coding problem. Im trying to get the portfolio EA's to open X amount per trade so the SL is set at a fixed % of account equity.
However when tsting I find that the SL value to get gretaer than risk %per trade.

Just wonderig if someone can shed some light on the matter:\






double   Entry_Amount;
input double MaxRiskPerTrade = 1;
input int Maximum_Lots = 5;
input double Minimum_Lots = 0.01;
static input int    Base_Magic_Number = 757;  // Base Magic Number

#define TRADE_RETRY_COUNT 4
#define TRADE_RETRY_WAIT  100
#define OP_FLAT           -1

// Session time is set in seconds from 00:00
const int sessionSundayOpen           = 0;     // 00:00
const int sessionSundayClose          = 86400; // 24:00
const int sessionMondayThursdayOpen   = 0;     // 00:00
const int sessionMondayThursdayClose  = 86400; // 24:00
const int sessionFridayOpen           = 0;     // 00:00
const int sessionFridayClose          = 86400; // 24:00
const bool sessionIgnoreSunday        = true;
const bool sessionCloseAtSessionClose = false;
const bool sessionCloseAtFridayClose  = true;

const int    strategiesCount = 19;
const double sigma           = 0.000001;

datetime barTime;
int      digits;
double   stopLevel;
double   pip;
bool     setProtectionSeparately = false;



//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
enum OrderScope
  {
   ORDER_SCOPE_UNDEFINED,
   ORDER_SCOPE_ENTRY,
   ORDER_SCOPE_EXIT
  };
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
enum OrderDirection
  {
   ORDER_DIRECTION_NONE,
   ORDER_DIRECTION_BUY,
   ORDER_DIRECTION_SELL,
   ORDER_DIRECTION_BOTH
  };
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
struct Position
  {
   int               Type;
   int               Ticket;
   int               MagicNumber;
   double            Lots;
   double            Price;
   double            StopLoss;
   double            TakeProfit;
  };
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
struct Signal
  {
   int               MagicNumber;
   OrderScope        Scope;
   OrderDirection    Direction;
   int               StopLossPips;
   int               TakeProfitPips;
   bool              IsTrailingStop;
  };
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
  {
   barTime   = Time[0];
   digits    = (int) MarketInfo(_Symbol, MODE_DIGITS);
   stopLevel = MarketInfo(_Symbol, MODE_STOPLEVEL);
   pip       = GetPipValue();

   const ENUM_INIT_RETCODE initRetcode = ValidateInit();

   return (initRetcode);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTick()
  {
  int margin=(int) MarketInfo(_Symbol,MODE_MARGINREQUIRED);
      Entry_Amount=(AccountEquity()*MaxRiskPerTrade/1000)/(stopLevel);
      Entry_Amount = NormalizeEntrySize(Entry_Amount);
   if(Time[0]>barTime)
     {
      barTime=Time[0];
      OnBar();
     }
  }
  double NormalizeEntrySize(double size) {
   double minlot  = MarketInfo(_Symbol, MODE_MINLOT);
   double maxlot  = MarketInfo(_Symbol, MODE_MAXLOT);
   double lotstep = MarketInfo(_Symbol, MODE_LOTSTEP);

   if  (size <= minlot)
        size = minlot;
    if   (size <=Minimum_Lots)
        size = Minimum_Lots;

 

   if (size >= maxlot)
       size = maxlot;
   if (size >=Maximum_Lots)
       size = Maximum_Lots;
       
   size = NormalizeDouble(size, digits);   

   return (size);

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnBar()
  {
   if(IsOutOfSession()) return;

   Signal signalList[];
   SetSignals(signalList);
   int signalsCount=ArraySize(signalList);

   for(int i=0;i<signalsCount;i++)
     {
      Signal signal=signalList;
      ManageSignal(signal);
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void ManageSignal(Signal &signal)
  {
   Position position=CreatePosition(signal.MagicNumber);

   if(position.Type!=OP_FLAT && signal.Scope==ORDER_SCOPE_EXIT)
     {
      if(signal.Direction==ORDER_DIRECTION_BOTH ||
         (position.Type==OP_BUY && signal.Direction==ORDER_DIRECTION_SELL) ||
         (position.Type==OP_SELL && signal.Direction==ORDER_DIRECTION_BUY))
        {
         ClosePosition(position);
        }
     }

   if(position.Type!=OP_FLAT && signal.Scope==ORDER_SCOPE_EXIT && signal.IsTrailingStop)
     {
      double trailingStop=GetTrailingStop(position,signal.StopLossPips);
      Print(trailingStop);
      ManageTrailingStop(position,trailingStop);
     }

   if(position.Type==OP_FLAT && signal.Scope==ORDER_SCOPE_ENTRY)
     {
      if(signal.Direction==ORDER_DIRECTION_BUY || signal.Direction==ORDER_DIRECTION_SELL)
        {
         OpenPosition(signal);
        }
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Position CreatePosition(const int magicNumber)
  {
   Position position;
   position.MagicNumber = magicNumber;
   position.Type        = OP_FLAT;
   position.Ticket      = 0;
   position.Lots        = 0;
   position.Price       = 0;
   position.StopLoss    = 0;
   position.TakeProfit  = 0;

   int total=OrdersTotal();
   for(int pos=total-1; pos>=0; pos--)
     {
      if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES) &&
         OrderSymbol()      == _Symbol &&
         OrderMagicNumber() == magicNumber &&
         OrderCloseTime()   == 0)
        {
         position.Type       = OrderType();
         position.Lots       = OrderLots();
         position.Ticket     = OrderTicket();
         position.Price      = OrderOpenPrice();
         position.StopLoss   = OrderStopLoss();
         position.TakeProfit = OrderTakeProfit();
         break;
        }
     }

   return (position);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Signal CreateEntrySignal(const int strategyIndex,const bool canOpenLong,const bool canOpenShort,const int stopLossPips,const int takeProfitPips, const bool isTrailingStop)
  {
   Signal signal;
   signal.MagicNumber    = GetMagicNumber(strategyIndex);
   signal.Scope          = ORDER_SCOPE_ENTRY;
   signal.Direction      = canOpenLong&&canOpenShort ? ORDER_DIRECTION_BOTH : canOpenLong ? ORDER_DIRECTION_BUY : canOpenShort ? ORDER_DIRECTION_SELL : ORDER_DIRECTION_NONE;
   signal.StopLossPips   = stopLossPips;
   signal.TakeProfitPips = takeProfitPips;
   signal.IsTrailingStop = isTrailingStop;

   return (signal);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Signal CreateExitSignal(const int strategyIndex,const bool canCloseLong,const bool canCloseShorts,const int stopLossPips,const int takeProfitPips, const bool isTrailingStop)
  {
   Signal signal;
   signal.MagicNumber    = GetMagicNumber(strategyIndex);
   signal.Scope          = ORDER_SCOPE_EXIT;
   signal.Direction      = canCloseLong&&canCloseShorts ? ORDER_DIRECTION_BOTH : canCloseLong ? ORDER_DIRECTION_SELL : canCloseShorts ? ORDER_DIRECTION_BUY : ORDER_DIRECTION_NONE;
   signal.StopLossPips   = stopLossPips;
   signal.TakeProfitPips = takeProfitPips;
   signal.IsTrailingStop = isTrailingStop;

   return (signal);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OpenPosition(Signal &signal)
  {
   for(int attempt=0; attempt<TRADE_RETRY_COUNT; attempt++)
     {
      int    ticket     = 0;
      int    lastError  = 0;
      bool   modified   = false;
      int    command    = OrderDirectionToCommand(signal.Direction);
      double amount     = Entry_Amount;
      double stopLoss   = signal.StopLossPips>0 ? GetStopLoss(command, signal.StopLossPips) : 0;
      double takeProfit = signal.TakeProfitPips>0 ? GetTakeProfit(command, signal.TakeProfitPips) : 0;
      string comment    = IntegerToString(signal.MagicNumber);
      color  arrowColor = command==OP_BUY ? clrGreen : clrRed;

      if(IsTradeContextFree())
        {
         double price=MarketInfo(_Symbol,command==OP_BUY ? MODE_ASK : MODE_BID);
         if(setProtectionSeparately)
           {
            ticket=OrderSend(_Symbol,command,amount,price,10,0,0,comment,signal.MagicNumber,0,arrowColor);
            if(ticket>0 && (signal.StopLossPips>0 || signal.TakeProfitPips>0))
               modified=OrderModify(ticket,0,stopLoss,takeProfit,0,clrBlue);
           }
         else
           {
            ticket=OrderSend(_Symbol,command,amount,price,10,stopLoss,takeProfit,comment,signal.MagicNumber,0,arrowColor);
            lastError=GetLastError();
            if(ticket<=0 && lastError==130)
              {
               ticket=OrderSend(_Symbol,command,amount,price,10,0,0,comment,signal.MagicNumber,0,arrowColor);
               if(ticket>0 && (signal.StopLossPips>0 || signal.TakeProfitPips>0))
                  modified=OrderModify(ticket,0,stopLoss,takeProfit,0,clrBlue);
               if(ticket>0 && modified)
                 {
                  setProtectionSeparately=true;
                  Print("Detected ECN type position protection.");
                 }
              }
           }
        }

      if(ticket>0) break;

      lastError=GetLastError();

      if(lastError!=135 && lastError!=136 && lastError!=137 && lastError!=138) break;

      Sleep(TRADE_RETRY_WAIT);
      Print("Open Position retry no: "+IntegerToString(attempt+2));
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void ClosePosition(Position &position)
  {
   for(int attempt=0; attempt<TRADE_RETRY_COUNT; attempt++)
     {
      bool closed;
      int lastError=0;

      if(IsTradeContextFree())
        {
         double price=MarketInfo(_Symbol,position.Type==OP_BUY ? MODE_BID : MODE_ASK);
         closed=OrderClose(position.Ticket,position.Lots,price,10,clrYellow);
         lastError=GetLastError();
        }

      if(closed)
        {
         position.Type       = OP_FLAT;
         position.Lots       = 0;
         position.Price      = 0;
         position.StopLoss   = 0;
         position.TakeProfit = 0;

         break;
        }

      if(lastError==4108) break;

      Sleep(TRADE_RETRY_WAIT);
      Print("Close Position retry no: "+IntegerToString(attempt+2));
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void ModifyPosition(Position &position)
  {
   for(int attempt=0; attempt<TRADE_RETRY_COUNT; attempt++)
     {
      bool modified;
      int lastError=0;

      if(IsTradeContextFree())
        {
         modified=OrderModify(position.Ticket,0,position.StopLoss,position.TakeProfit,0,clrBlue);
         lastError=GetLastError();
        }

      if(modified)
        {
         const int magicNumber=position.MagicNumber;
         position=CreatePosition(magicNumber);

         break;
        }

      if(lastError==4108)
         break;

      Sleep(TRADE_RETRY_WAIT);
      Print("Modify Position retry no: "+IntegerToString(attempt+2));
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CloseAllPositions()
  {
   for(int i=0;i<strategiesCount;i++)
     {
      int magicNumber=GetMagicNumber(i);
      Position position=CreatePosition(magicNumber);

      if(position.Type==OP_BUY || position.Type==OP_SELL)
         ClosePosition(position);
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double GetStopLoss(int command,int stopLossPips)
  {
   if(stopLossPips==0) return (0);

   double deltaPips      = MathMax(pip*stopLossPips, _Point*stopLevel);
   double referencePrice = MarketInfo(_Symbol, command==OP_BUY ? MODE_BID : MODE_ASK);
   double stopLossPoints = command==OP_BUY ? referencePrice-deltaPips : referencePrice+deltaPips;
   double finalStopLoss  = NormalizeDouble(stopLossPoints, digits);

   return (finalStopLoss);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double GetTakeProfit(int command,int takeProfitPips)
  {
   if(takeProfitPips==0) return (0);

   double deltaPips        = MathMax(pip*takeProfitPips, _Point*stopLevel);
   double referencePrice   = MarketInfo(_Symbol, command==OP_BUY ? MODE_BID : MODE_ASK);
   double takeProfitPoints = command==OP_BUY ? referencePrice+deltaPips : referencePrice-deltaPips;
   double finalTakeProfit  = NormalizeDouble(takeProfitPoints, digits);

   return (finalTakeProfit);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double GetTrailingStop(Position &position, int stopLoss)
  {
   double bid=MarketInfo(_Symbol,MODE_BID);
   double ask=MarketInfo(_Symbol,MODE_ASK);
   double stopLevelPoints=_Point*stopLevel;
   double stopLossPoints=pip*stopLoss;

   if(position.Type==OP_BUY)
     {
      double stopLossPrice=High[1]-stopLossPoints;
      if(position.StopLoss<stopLossPrice-pip)
        {
         if(stopLossPrice<bid)
           {
            if(stopLossPrice>=bid-stopLevelPoints)
               return (bid - stopLevelPoints);
            else
               return (stopLossPrice);
           }
         else
           {
            return (bid);
           }
        }
     }

   else if(position.Type==OP_SELL)
     {
      double stopLossPrice=Low[1]+stopLossPoints;
      if(position.StopLoss>stopLossPrice+pip)
        {
         if(stopLossPrice>ask)
           {
            if(stopLossPrice<=ask+stopLevelPoints)
               return (ask + stopLevelPoints);
            else
               return (stopLossPrice);
           }
         else
           {
            return (ask);
           }
        }
     }

   return (position.StopLoss);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void ManageTrailingStop(Position &position, double trailingStop)
  {
   double bid=MarketInfo(_Symbol,MODE_BID);
   double ask=MarketInfo(_Symbol,MODE_ASK);

   if(position.Type==OP_BUY && MathAbs(trailingStop-bid)<_Point)
     {
      ClosePosition(position);
     }

   else if(position.Type==OP_SELL && MathAbs(trailingStop-ask)<_Point)
     {
      ClosePosition(position);
     }

   else if(MathAbs(trailingStop-position.StopLoss)>_Point)
     {
      position.StopLoss=NormalizeDouble(trailingStop,digits);
      ModifyPosition(position);
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool IsTradeContextFree()
  {
   if(IsTradeAllowed()) return (true);

   uint startWait=GetTickCount();
   Print("Trade context is busy! Waiting...");

   while(true)
     {
      if(IsStopped()) return (false);

      uint diff=GetTickCount()-startWait;
      if(diff>30*1000)
        {
         Print("The waiting limit exceeded!");
         return (false);
        }

      if(IsTradeAllowed())
        {
         RefreshRates();
         return (true);
        }
      Sleep(TRADE_RETRY_WAIT);
     }

   return (true);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool IsOutOfSession()
  {
   MqlDateTime time0; TimeToStruct(Time[0],time0);
   int weekDay           = time0.day_of_week;
   long timeFromMidnight = Time[0]%86400;
   int periodLength      = PeriodSeconds(_Period);
   bool skipTrade        = false;

   if(weekDay==0)
     {
      if(sessionIgnoreSunday) return true;
      int lastBarFix=sessionCloseAtSessionClose ? periodLength : 0;
      skipTrade=timeFromMidnight<sessionSundayOpen || timeFromMidnight+lastBarFix>sessionSundayClose;
     }
   else if(weekDay<5)
     {
      int lastBarFix=sessionCloseAtSessionClose ? periodLength : 0;
      skipTrade=timeFromMidnight<sessionMondayThursdayOpen || timeFromMidnight+lastBarFix>sessionMondayThursdayClose;
     }
   else
     {
      int lastBarFix=sessionCloseAtFridayClose || sessionCloseAtSessionClose ? periodLength : 0;
      skipTrade=timeFromMidnight<sessionFridayOpen || timeFromMidnight+lastBarFix>sessionFridayClose;
     }

   return (skipTrade);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool IsForceSessionClose()
  {
   if(!sessionCloseAtFridayClose && !sessionCloseAtSessionClose)
      return (false);

   MqlDateTime time0; TimeToStruct(Time[0],time0);
   int weekDay           = time0.day_of_week;
   long timeFromMidnight = Time[0]%86400;
   int periodLength      = PeriodSeconds(_Period);
   int lastBarFix        = sessionCloseAtSessionClose ? periodLength : 0;

   bool forceExit=false;
   if(weekDay==0)
     {
      forceExit=timeFromMidnight+lastBarFix>sessionSundayClose;
     }
   else if(weekDay<5)
     {
      forceExit=timeFromMidnight+lastBarFix>sessionMondayThursdayClose;
     }
   else
     {
      int fridayBarFix=sessionCloseAtFridayClose || sessionCloseAtSessionClose ? periodLength : 0;
      forceExit=timeFromMidnight+fridayBarFix>sessionFridayClose;
     }

   return (forceExit);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
datetime Time(int bar)
  {
   return Time[bar];
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double Open(int bar)
  {
   return Open[bar];
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double High(int bar)
  {
   return High[bar];
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double Low(int bar)
  {
   return Low[bar];
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double Close(int bar)
  {
   return Close[bar];
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double GetPipValue()
  {
   switch((int) MarketInfo(_Symbol,MODE_DIGITS))
     {
      case  5: case  4: return (0.0001);
      case  3: case  2: return (0.01);
      case  1:          return (0.1);
     }

   return (1);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int GetMagicNumber(int strategyIndex)
  {
   int magic=1000*Base_Magic_Number+strategyIndex;
   return (magic);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OrderDirectionToCommand(OrderDirection dir)
  {
   if(dir==ORDER_DIRECTION_BUY)  return (OP_BUY);
   if(dir==ORDER_DIRECTION_SELL) return (OP_SELL);

   return (OP_FLAT);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void SetSignals(Signal &signalList[])
  {
   int i=0;
   ArrayResize(signalList,2*strategiesCount);
   HideTestIndicators(true);

   /*STRATEGY CODE {"properties":{"entryLots":0.01,"stopLoss":603,"takeProfit":100,"useStopLoss":true,"useTakeProfit":false,"isTrailingStop":false},"openFilters":[{"name":"Entry Time","listIndexes":[0,0,0,0,0],"numValues":[3,0,22,59,0,0]},{"name":"Money Flow Index","listIndexes":[4,0,0,0,0],"numValues":[39,34,0,0,0,0]},{"name":"RSI","listIndexes":[0,3,0,0,0],"numValues":[20,30,0,0,0,0]}],"closeFilters":[{"name":"Moving Average","listIndexes":[2,0,3,0,0],"numValues":[40,0,0,0,0,0]}]} */
   signalList[i++] = GetExitSignal_00();
   signalList[i++] = GetEntrySignal_00();

   /*STRATEGY CODE {"properties":{"entryLots":0.01,"stopLoss":552,"takeProfit":100,"useStopLoss":true,"useTakeProfit":false,"isTrailingStop":false},"openFilters":[{"name":"Entry Time","listIndexes":[0,0,0,0,0],"numValues":[3,0,22,59,0,0]},{"name":"Money Flow Index","listIndexes":[4,0,0,0,0],"numValues":[41,33,0,0,0,0]}],"closeFilters":[{"name":"Alligator","listIndexes":[0,3,4,0,0],"numValues":[15,16,21,11,15,6]}]} */
   signalList[i++] = GetExitSignal_01();
   signalList[i++] = GetEntrySignal_01();

   /*STRATEGY CODE {"properties":{"entryLots":0.01,"stopLoss":621,"takeProfit":100,"useStopLoss":true,"useTakeProfit":false,"isTrailingStop":false},"openFilters":[{"name":"Entry Time","listIndexes":[0,0,0,0,0],"numValues":[3,0,22,59,0,0]},{"name":"Directional Indicators","listIndexes":[0,0,0,0,0],"numValues":[28,0,0,0,0,0]},{"name":"RVI Signal","listIndexes":[0,0,0,0,0],"numValues":[38,0,0,0,0,0]},{"name":"Moving Average","listIndexes":[0,0,3,0,0],"numValues":[3,0,0,0,0,0]}],"closeFilters":[{"name":"Bollinger Bands","listIndexes":[2,3,0,0,0],"numValues":[27,2.12,0,0,0,0]}]} */
   signalList[i++] = GetExitSignal_02();
   signalList[i++] = GetEntrySignal_02();

   /*STRATEGY CODE {"properties":{"entryLots":0.01,"stopLoss":510,"takeProfit":100,"useStopLoss":true,"useTakeProfit":false,"isTrailingStop":false},"openFilters":[{"name":"Entry Time","listIndexes":[0,0,0,0,0],"numValues":[3,0,22,59,0,0]},{"name":"Money Flow Index","listIndexes":[4,0,0,0,0],"numValues":[43,33,0,0,0,0]}],"closeFilters":[{"name":"RVI","listIndexes":[2,0,0,0,0],"numValues":[33,0.01,0,0,0,0]}]} */
   signalList[i++] = GetExitSignal_03();
   signalList[i++] = GetEntrySignal_03();

   /*STRATEGY CODE {"properties":{"entryLots":0.01,"stopLoss":654,"takeProfit":100,"useStopLoss":true,"useTakeProfit":false,"isTrailingStop":false},"openFilters":[{"name":"Entry Time","listIndexes":[0,0,0,0,0],"numValues":[3,0,22,59,0,0]},{"name":"RSI","listIndexes":[4,3,0,0,0],"numValues":[4,93,0,0,0,0]}],"closeFilters":[{"name":"RSI","listIndexes":[5,3,0,0,0],"numValues":[15,62,0,0,0,0]}]} */
   signalList[i++] = GetExitSignal_04();
   signalList[i++] = GetEntrySignal_04();

   /*STRATEGY CODE {"properties":{"entryLots":0.01,"stopLoss":562,"takeProfit":100,"useStopLoss":true,"useTakeProfit":false,"isTrailingStop":false},"openFilters":[{"name":"Entry Time","listIndexes":[0,0,0,0,0],"numValues":[3,0,22,59,0,0]},{"name":"Money Flow Index","listIndexes":[4,0,0,0,0],"numValues":[44,35,0,0,0,0]}],"closeFilters":[{"name":"Directional Indicators","listIndexes":[2,0,0,0,0],"numValues":[41,0,0,0,0,0]}]} */
   signalList[i++] = GetExitSignal_05();
   signalList[i++] = GetEntrySignal_05();

   /*STRATEGY CODE {"properties":{"entryLots":0.01,"stopLoss":526,"takeProfit":100,"useStopLoss":true,"useTakeProfit":false,"isTrailingStop":false},"openFilters":[{"name":"Entry Time","listIndexes":[0,0,0,0,0],"numValues":[3,0,22,59,0,0]},{"name":"Stochastic","listIndexes":[4,0,0,0,0],"numValues":[6,1,1,31,0,0]},{"name":"Stochastic","listIndexes":[6,0,0,0,0],"numValues":[3,4,6,20,0,0]},{"name":"RVI Signal","listIndexes":[0,0,0,0,0],"numValues":[37,0,0,0,0,0]}],"closeFilters":[{"name":"Commodity Channel Index","listIndexes":[5,5,0,0,0],"numValues":[18,45,0,0,0,0]}]} */
   signalList[i++] = GetExitSignal_06();
   signalList[i++] = GetEntrySignal_06();

   /*STRATEGY CODE {"properties":{"entryLots":0.01,"stopLoss":696,"takeProfit":100,"useStopLoss":true,"useTakeProfit":false,"isTrailingStop":false},"openFilters":[{"name":"Entry Time","listIndexes":[0,0,0,0,0],"numValues":[3,0,22,59,0,0]},{"name":"Force Index","listIndexes":[4,0,0,0,0],"numValues":[28,0,0,0,0,0]},{"name":"ADX","listIndexes":[7,0,0,0,0],"numValues":[31,0,0,0,0,0]}],"closeFilters":[{"name":"RVI Signal","listIndexes":[1,0,0,0,0],"numValues":[40,0,0,0,0,0]}]} */
   signalList[i++] = GetExitSignal_07();
   signalList[i++] = GetEntrySignal_07();

   /*STRATEGY CODE {"properties":{"entryLots":0.01,"stopLoss":348,"takeProfit":100,"useStopLoss":true,"useTakeProfit":false,"isTrailingStop":false},"openFilters":[{"name":"Entry Time","listIndexes":[0,0,0,0,0],"numValues":[3,0,22,59,0,0]},{"name":"Directional Indicators","listIndexes":[0,0,0,0,0],"numValues":[13,0,0,0,0,0]},{"name":"Average True Range","listIndexes":[3,0,0,0,0],"numValues":[42,1.68,0,0,0,0]},{"name":"Directional Indicators","listIndexes":[3,0,0,0,0],"numValues":[28,0,0,0,0,0]}],"closeFilters":[{"name":"Williams' Percent Range","listIndexes":[3,0,0,0,0],"numValues":[15,-72,0,0,0,0]}]} */
   signalList[i++] = GetExitSignal_08();
   signalList[i++] = GetEntrySignal_08();

   /*STRATEGY CODE {"properties":{"entryLots":0.01,"stopLoss":468,"takeProfit":100,"useStopLoss":true,"useTakeProfit":false,"isTrailingStop":false},"openFilters":[{"name":"Entry Time","listIndexes":[0,0,0,0,0],"numValues":[3,0,22,59,0,0]},{"name":"Money Flow Index","listIndexes":[4,0,0,0,0],"numValues":[42,36,0,0,0,0]}],"closeFilters":[{"name":"Directional Indicators","listIndexes":[2,0,0,0,0],"numValues":[44,0,0,0,0,0]}]} */
   signalList[i++] = GetExitSignal_09();
   signalList[i++] = GetEntrySignal_09();

   /*STRATEGY CODE {"properties":{"entryLots":0.01,"stopLoss":450,"takeProfit":100,"useStopLoss":true,"useTakeProfit":false,"isTrailingStop":false},"openFilters":[{"name":"Entry Time","listIndexes":[0,0,0,0,0],"numValues":[3,0,22,59,0,0]},{"name":"Money Flow Index","listIndexes":[4,0,0,0,0],"numValues":[42,36,0,0,0,0]}],"closeFilters":[{"name":"Directional Indicators","listIndexes":[2,0,0,0,0],"numValues":[44,0,0,0,0,0]}]} */
   signalList[i++] = GetExitSignal_010();
   signalList[i++] = GetEntrySignal_010();

   /*STRATEGY CODE {"properties":{"entryLots":0.01,"stopLoss":564,"takeProfit":100,"useStopLoss":true,"useTakeProfit":false,"isTrailingStop":false},"openFilters":[{"name":"Entry Time","listIndexes":[0,0,0,0,0],"numValues":[3,0,22,59,0,0]},{"name":"Money Flow Index","listIndexes":[4,0,0,0,0],"numValues":[34,38,0,0,0,0]}],"closeFilters":[{"name":"Bollinger Bands","listIndexes":[3,3,0,0,0],"numValues":[18,1.68,0,0,0,0]}]} */
   signalList[i++] = GetExitSignal_011();
   signalList[i++] = GetEntrySignal_011();

   /*STRATEGY CODE {"properties":{"entryLots":0.01,"stopLoss":472,"takeProfit":100,"useStopLoss":true,"useTakeProfit":false,"isTrailingStop":false},"openFilters":[{"name":"Entry Time","listIndexes":[0,0,0,0,0],"numValues":[3,0,22,59,0,0]},{"name":"Money Flow Index","listIndexes":[2,0,0,0,0],"numValues":[6,65,0,0,0,0]},{"name":"Money Flow Index","listIndexes":[5,0,0,0,0],"numValues":[24,53,0,0,0,0]},{"name":"Williams' Percent Range","listIndexes":[2,0,0,0,0],"numValues":[36,-66,0,0,0,0]}],"closeFilters":[{"name":"ADX","listIndexes":[7,0,0,0,0],"numValues":[31,0,0,0,0,0]}]} */
   signalList[i++] = GetExitSignal_012();
   signalList[i++] = GetEntrySignal_012();

   /*STRATEGY CODE {"properties":{"entryLots":0.01,"stopLoss":649,"takeProfit":100,"useStopLoss":true,"useTakeProfit":false,"isTrailingStop":false},"openFilters":[{"name":"Entry Time","listIndexes":[0,0,0,0,0],"numValues":[3,0,22,59,0,0]},{"name":"Momentum","listIndexes":[7,3,0,0,0],"numValues":[30,100,0,0,0,0]},{"name":"Stochastic Signal","listIndexes":[1,0,0,0,0],"numValues":[8,4,8,0,0,0]},{"name":"Williams' Percent Range","listIndexes":[2,0,0,0,0],"numValues":[51,-35,0,0,0,0]}],"closeFilters":[{"name":"Envelopes","listIndexes":[4,3,0,0,0],"numValues":[9,0.12,0,0,0,0]}]} */
   signalList[i++] = GetExitSignal_017();
   signalList[i++] = GetEntrySignal_017();

   /*STRATEGY CODE {"properties":{"entryLots":0.01,"stopLoss":596,"takeProfit":100,"useStopLoss":true,"useTakeProfit":false,"isTrailingStop":false},"openFilters":[{"name":"Entry Time","listIndexes":[0,0,0,0,0],"numValues":[3,0,22,59,0,0]},{"name":"RVI","listIndexes":[4,0,0,0,0],"numValues":[24,0,0,0,0,0]},{"name":"Williams' Percent Range","listIndexes":[6,0,0,0,0],"numValues":[29,-20,0,0,0,0]}],"closeFilters":[{"name":"Bollinger Bands","listIndexes":[0,3,0,0,0],"numValues":[25,1.68,0,0,0,0]}]} */
   signalList[i++] = GetExitSignal_018();
   signalList[i++] = GetEntrySignal_018();

   HideTestIndicators(false);
   if(i!=2*strategiesCount)
      ArrayResize(signalList,i);
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Signal GetEntrySignal_00()
  {

   int fromTime0  = 3*3600 + 0*60;
   int untilTime0 = 22*3600 + 59*60;

   MqlDateTime mqlTime0; TimeToStruct(Time(0), mqlTime0);
   int barMinutes0 = mqlTime0.hour*3600 + mqlTime0.min*60;

   bool isOnTime0 = fromTime0 < untilTime0
      ? barMinutes0 >= fromTime0 && barMinutes0 <= untilTime0
      : barMinutes0 >= fromTime0 || barMinutes0 <= untilTime0;

   bool ind0long  = isOnTime0;
   bool ind0short = isOnTime0;
   double ind1val1 = iMFI(NULL,0,39,1);
   double ind1val2 = iMFI(NULL,0,39,2);
   bool ind1long  = ind1val1 > 34 + sigma && ind1val2 < 34 - sigma;
   bool ind1short = ind1val1 < 100 - 34 - sigma && ind1val2 > 100 - 34 + sigma;
   double ind2val1 = iRSI(NULL,0,20,PRICE_CLOSE,1);
   double ind2val2 = iRSI(NULL,0,20,PRICE_CLOSE,2);
   bool ind2long  = ind2val1 > ind2val2 + sigma;
   bool ind2short = ind2val1 < ind2val2 - sigma;

   Signal signal = CreateEntrySignal(0, ind0long && ind1long && ind2long, ind0short && ind1short && ind2short, 603, 0, false);
   return (signal);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Signal GetExitSignal_00()
  {
   double ind3val1 = iMA(NULL,0,40,0,MODE_SMA,PRICE_CLOSE,1);
   bool ind3long  = Open(0) > ind3val1 + sigma;
   bool ind3short = Open(0) < ind3val1 - sigma;

   Signal signal = CreateExitSignal(0, ind3long, ind3short, 603, 0, false);
   return (signal);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Signal GetEntrySignal_01()
  {

   int fromTime0  = 3*3600 + 0*60;
   int untilTime0 = 22*3600 + 59*60;

   MqlDateTime mqlTime0; TimeToStruct(Time(0), mqlTime0);
   int barMinutes0 = mqlTime0.hour*3600 + mqlTime0.min*60;

   bool isOnTime0 = fromTime0 < untilTime0
      ? barMinutes0 >= fromTime0 && barMinutes0 <= untilTime0
      : barMinutes0 >= fromTime0 || barMinutes0 <= untilTime0;

   bool ind0long  = isOnTime0;
   bool ind0short = isOnTime0;
   double ind1val1 = iMFI(NULL,0,41,1);
   double ind1val2 = iMFI(NULL,0,41,2);
   bool ind1long  = ind1val1 > 33 + sigma && ind1val2 < 33 - sigma;
   bool ind1short = ind1val1 < 100 - 33 - sigma && ind1val2 > 100 - 33 + sigma;

   Signal signal = CreateEntrySignal(1, ind0long && ind1long, ind0short && ind1short, 552, 0, false);
   return (signal);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Signal GetExitSignal_01()
  {
   double ind2val1 = iAlligator(NULL,0,15,16,21,11,15,6,MODE_SMMA,PRICE_MEDIAN,MODE_GATORLIPS,1);
   double ind2val2 = iAlligator(NULL,0,15,16,21,11,15,6,MODE_SMMA,PRICE_MEDIAN,MODE_GATORLIPS,2);
   bool ind2long  = ind2val1 > ind2val2 + sigma;
   bool ind2short = ind2val1 < ind2val2 - sigma;

   Signal signal = CreateExitSignal(1, ind2long, ind2short, 552, 0, false);
   return (signal);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Signal GetEntrySignal_02()
  {

   int fromTime0  = 3*3600 + 0*60;
   int untilTime0 = 22*3600 + 59*60;

   MqlDateTime mqlTime0; TimeToStruct(Time(0), mqlTime0);
   int barMinutes0 = mqlTime0.hour*3600 + mqlTime0.min*60;

   bool isOnTime0 = fromTime0 < untilTime0
      ? barMinutes0 >= fromTime0 && barMinutes0 <= untilTime0
      : barMinutes0 >= fromTime0 || barMinutes0 <= untilTime0;

   bool ind0long  = isOnTime0;
   bool ind0short = isOnTime0;
   double ind1val1 = iADX(NULL,0,28,PRICE_CLOSE,1,1) - iADX(NULL,0,28,PRICE_CLOSE,2,1);
   double ind1val2 = iADX(NULL,0,28,PRICE_CLOSE,1,2) - iADX(NULL,0,28,PRICE_CLOSE,2,2);
   bool ind1long  = ind1val1 > 0 + sigma && ind1val2 < 0 - sigma;
   bool ind1short = ind1val1 < 0 - sigma && ind1val2 > 0 + sigma;
   double ind2val1 = iRVI(NULL,0,38,MODE_MAIN,1) - iRVI(NULL,0,38,MODE_SIGNAL,1);
   double ind2val2 = iRVI(NULL,0,38,MODE_MAIN,2) - iRVI(NULL,0,38,MODE_SIGNAL,2);
   bool ind2long  = ind2val1 > 0 + sigma && ind2val2 < 0 - sigma;
   bool ind2short = ind2val1 < 0 - sigma && ind2val2 > 0 + sigma;
   double ind3val1 = iMA(NULL,0,3,0,MODE_SMA,PRICE_CLOSE,1);
   double ind3val2 = iMA(NULL,0,3,0,MODE_SMA,PRICE_CLOSE,2);
   bool ind3long  = ind3val1 > ind3val2 + sigma;
   bool ind3short = ind3val1 < ind3val2 - sigma;

   Signal signal = CreateEntrySignal(2, ind0long && ind1long && ind2long && ind3long, ind0short && ind1short && ind2short && ind3short, 621, 0, false);
   return (signal);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Signal GetExitSignal_02()
  {
   double ind4upBand1 = iBands(NULL,0,27,2.12,0,PRICE_CLOSE,MODE_UPPER,1);
   double ind4dnBand1 = iBands(NULL,0,27,2.12,0,PRICE_CLOSE,MODE_LOWER,1);
   double ind4upBand2 = iBands(NULL,0,27,2.12,0,PRICE_CLOSE,MODE_UPPER,2);
   double ind4dnBand2 = iBands(NULL,0,27,2.12,0,PRICE_CLOSE,MODE_LOWER,2);
   bool ind4long  = Open(0) < ind4upBand1 - sigma && Open(1) > ind4upBand2 + sigma;
   bool ind4short = Open(0) > ind4dnBand1 + sigma && Open(1) < ind4dnBand2 - sigma;

   Signal signal = CreateExitSignal(2, ind4long, ind4short, 621, 0, false);
   return (signal);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Signal GetEntrySignal_03()
  {

   int fromTime0  = 3*3600 + 0*60;
   int untilTime0 = 22*3600 + 59*60;

   MqlDateTime mqlTime0; TimeToStruct(Time(0), mqlTime0);
   int barMinutes0 = mqlTime0.hour*3600 + mqlTime0.min*60;

   bool isOnTime0 = fromTime0 < untilTime0
      ? barMinutes0 >= fromTime0 && barMinutes0 <= untilTime0
      : barMinutes0 >= fromTime0 || barMinutes0 <= untilTime0;

   bool ind0long  = isOnTime0;
   bool ind0short = isOnTime0;
   double ind1val1 = iMFI(NULL,0,43,1);
   double ind1val2 = iMFI(NULL,0,43,2);
   bool ind1long  = ind1val1 > 33 + sigma && ind1val2 < 33 - sigma;
   bool ind1short = ind1val1 < 100 - 33 - sigma && ind1val2 > 100 - 33 + sigma;

   Signal signal = CreateEntrySignal(3, ind0long && ind1long, ind0short && ind1short, 510, 0, false);
   return (signal);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Signal GetExitSignal_03()
  {
   double ind2val1 = iRVI(NULL,0,33,MODE_MAIN,1);
   bool ind2long  = ind2val1 > 0.01 + sigma;
   bool ind2short = ind2val1 < -1*0.01 - sigma;

   Signal signal = CreateExitSignal(3, ind2long, ind2short, 510, 0, false);
   return (signal);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Signal GetEntrySignal_04()
  {

   int fromTime0  = 3*3600 + 0*60;
   int untilTime0 = 22*3600 + 59*60;

   MqlDateTime mqlTime0; TimeToStruct(Time(0), mqlTime0);
   int barMinutes0 = mqlTime0.hour*3600 + mqlTime0.min*60;

   bool isOnTime0 = fromTime0 < untilTime0
      ? barMinutes0 >= fromTime0 && barMinutes0 <= untilTime0
      : barMinutes0 >= fromTime0 || barMinutes0 <= untilTime0;

   bool ind0long  = isOnTime0;
   bool ind0short = isOnTime0;
   double ind1val1 = iRSI(NULL,0,4,PRICE_CLOSE,1);
   double ind1val2 = iRSI(NULL,0,4,PRICE_CLOSE,2);
   bool ind1long  = ind1val1 > 93 + sigma && ind1val2 < 93 - sigma;
   bool ind1short = ind1val1 < 100 - 93 - sigma && ind1val2 > 100 - 93 + sigma;

   Signal signal = CreateEntrySignal(4, ind0long && ind1long, ind0short && ind1short, 654, 0, false);
   return (signal);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Signal GetExitSignal_04()
  {
   double ind2val1 = iRSI(NULL,0,15,PRICE_CLOSE,1);
   double ind2val2 = iRSI(NULL,0,15,PRICE_CLOSE,2);
   bool ind2long  = ind2val1 < 62 - sigma && ind2val2 > 62 + sigma;
   bool ind2short = ind2val1 > 100 - 62 + sigma && ind2val2 < 100 - 62 - sigma;

   Signal signal = CreateExitSignal(4, ind2long, ind2short, 654, 0, false);
   return (signal);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Signal GetEntrySignal_05()
  {

   int fromTime0  = 3*3600 + 0*60;
   int untilTime0 = 22*3600 + 59*60;

   MqlDateTime mqlTime0; TimeToStruct(Time(0), mqlTime0);
   int barMinutes0 = mqlTime0.hour*3600 + mqlTime0.min*60;

   bool isOnTime0 = fromTime0 < untilTime0
      ? barMinutes0 >= fromTime0 && barMinutes0 <= untilTime0
      : barMinutes0 >= fromTime0 || barMinutes0 <= untilTime0;

   bool ind0long  = isOnTime0;
   bool ind0short = isOnTime0;
   double ind1val1 = iMFI(NULL,0,44,1);
   double ind1val2 = iMFI(NULL,0,44,2);
   bool ind1long  = ind1val1 > 35 + sigma && ind1val2 < 35 - sigma;
   bool ind1short = ind1val1 < 100 - 35 - sigma && ind1val2 > 100 - 35 + sigma;

   Signal signal = CreateEntrySignal(5, ind0long && ind1long, ind0short && ind1short, 562, 0, false);
   return (signal);
  }
//+------------------------------------------------------------------+
//|             
   Signal signal = CreateEntrySignal(8, ind0long && ind1long && ind2long && ind3long, ind0short && ind1short && ind2short && ind3short, 348, 0, false);
   return (signal);
  }
//+------------------------------------------------------------------+
//|                                                                  |

  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Signal GetExitSignal_09()
  {
   double ind2val1 = iADX(NULL,0,44,PRICE_CLOSE,1,1) - iADX(NULL,0,44,PRICE_CLOSE,2,1);
   bool ind2long  = ind2val1 > 0 + sigma;
   bool ind2short = ind2val1 < 0 - sigma;

   Signal signal = CreateExitSignal(9, ind2long, ind2short, 468, 0, false);
   return (signal);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Signal GetEntrySignal_010()
  {

   int fromTime0  = 3*3600 + 0*60;
   int untilTime0 = 22*3600 + 59*60;

   MqlDateTime mqlTime0; TimeToStruct(Time(0), mqlTime0);
   int barMinutes0 = mqlTime0.hour*3600 + mqlTime0.min*60;

   bool isOnTime0 = fromTime0 < untilTime0
      ? barMinutes0 >= fromTime0 && barMinutes0 <= untilTime0
      : barMinutes0 >= fromTime0 || barMinutes0 <= untilTime0;

   bool ind0long  = isOnTime0;
   bool ind0short = isOnTime0;
   double ind1val1 = iMFI(NULL,0,42,1);
   double ind1val2 = iMFI(NULL,0,42,2);
   bool ind1long  = ind1val1 > 36 + sigma && ind1val2 < 36 - sigma;
   bool ind1short = ind1val1 < 100 - 36 - sigma && ind1val2 > 100 - 36 + sigma;

   Signal signal = CreateEntrySignal(10, ind0long && ind1long, ind0short && ind1short, 450, 0, false);
   return (signal);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Signal GetExitSignal_010()
  {
   double ind2val1 = iADX(NULL,0,44,PRICE_CLOSE,1,1) - iADX(NULL,0,44,PRICE_CLOSE,2,1);
   bool ind2long  = ind2val1 > 0 + sigma;
   bool ind2short = ind2val1 < 0 - sigma;

   Signal signal = CreateExitSignal(10, ind2long, ind2short, 450, 0, false);
   return (signal);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Signal GetEntrySignal_011()
  {

   int fromTime0  = 3*3600 + 0*60;
   int untilTime0 = 22*3600 + 59*60;

   MqlDateTime mqlTime0; TimeToStruct(Time(0), mqlTime0);
   int barMinutes0 = mqlTime0.hour*3600 + mqlTime0.min*60;

   bool isOnTime0 = fromTime0 < untilTime0
      ? barMinutes0 >= fromTime0 && barMinutes0 <= untilTime0
      : barMinutes0 >= fromTime0 || barMinutes0 <= untilTime0;

   bool ind0long  = isOnTime0;
   bool ind0short = isOnTime0;
   double ind1val1 = iMFI(NULL,0,34,1);
   double ind1val2 = iMFI(NULL,0,34,2);
   bool ind1long  = ind1val1 > 38 + sigma && ind1val2 < 38 - sigma;
   bool ind1short = ind1val1 < 100 - 38 - sigma && ind1val2 > 100 - 38 + sigma;

   Signal signal = CreateEntrySignal(11, ind0long && ind1long, ind0short && ind1short, 564, 0, false);
   return (signal);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Signal GetExitSignal_011()
  {
   double ind2upBand1 = iBands(NULL,0,18,1.68,0,PRICE_CLOSE,MODE_UPPER,1);
   double ind2dnBand1 = iBands(NULL,0,18,1.68,0,PRICE_CLOSE,MODE_LOWER,1);
   double ind2upBand2 = iBands(NULL,0,18,1.68,0,PRICE_CLOSE,MODE_UPPER,2);
   double ind2dnBand2 = iBands(NULL,0,18,1.68,0,PRICE_CLOSE,MODE_LOWER,2);
   bool ind2long  = Open(0) > ind2upBand1 + sigma && Open(1) < ind2upBand2 - sigma;
   bool ind2short = Open(0) < ind2dnBand1 - sigma && Open(1) > ind2dnBand2 + sigma;

   Signal signal = CreateExitSignal(11, ind2long, ind2short, 564, 0, false);
   return (signal);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Signal GetEntrySignal_012()
  {

   int fromTime0  = 3*3600 + 0*60;
   int untilTime0 = 22*3600 + 59*60;

   MqlDateTime mqlTime0; TimeToStruct(Time(0), mqlTime0);
   int barMinutes0 = mqlTime0.hour*3600 + mqlTime0.min*60;

   bool isOnTime0 = fromTime0 < untilTime0
      ? barMinutes0 >= fromTime0 && barMinutes0 <= untilTime0
      : barMinutes0 >= fromTime0 || barMinutes0 <= untilTime0;

   bool ind0long  = isOnTime0;
   bool ind0short = isOnTime0;
   double ind1val1 = iMFI(NULL,0,6,1);
   bool ind1long  = ind1val1 > 65 + sigma;
   bool ind1short = ind1val1 < 100 - 65 - sigma;
   double ind2val1 = iMFI(NULL,0,24,1);
   double ind2val2 = iMFI(NULL,0,24,2);
   bool ind2long  = ind2val1 < 53 - sigma && ind2val2 > 53 + sigma;
   bool ind2short = ind2val1 > 100 - 53 + sigma && ind2val2 < 100 - 53 - sigma;
   double ind3val1 = iWPR(NULL,0,36,1);
   bool ind3long  = ind3val1 > -66 + sigma;
   bool ind3short = ind3val1 < -100 - -66 - sigma;

   Signal signal = CreateEntrySignal(12, ind0long && ind1long && ind2long && ind3long, ind0short && ind1short && ind2short && ind3short, 472, 0, false);
   return (signal);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Signal GetExitSignal_012()
  {
   double ind4val1 = iADX(NULL,0,31,PRICE_CLOSE,0,1);
   double ind4val2 = iADX(NULL,0,31,PRICE_CLOSE,0,2);
   double ind4val3 = iADX(NULL,0,31,PRICE_CLOSE,0,3);
   bool ind4long  = ind4val1 < ind4val2 - sigma && ind4val2 > ind4val3 + sigma;
   bool ind4short = ind4long;

   Signal signal = CreateExitSignal(12, ind4long, ind4short, 472, 0, false);
   return (signal);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Signal GetEntrySignal_013()
  {

   int fromTime0  = 3*3600 + 0*60;
   int untilTime0 = 22*3600 + 59*60;

   MqlDateTime mqlTime0; TimeToStruct(Time(0), mqlTime0);
   int barMinutes0 = mqlTime0.hour*3600 + mqlTime0.min*60;

   bool isOnTime0 = fromTime0 < untilTime0
      ? barMinutes0 >= fromTime0 && barMinutes0 <= untilTime0
      : barMinutes0 >= fromTime0 || barMinutes0 <= untilTime0;

   bool ind0long  = isOnTime0;
   bool ind0short = isOnTime0;
   double ind1val1 = iMFI(NULL,0,40,1);
   double ind1val2 = iMFI(NULL,0,40,2);
   bool ind1long  = ind1val1 > 37 + sigma && ind1val2 < 37 - sigma;
   bool ind1short = ind1val1 < 100 - 37 - sigma && ind1val2 > 100 - 37 + sigma;

   Signal signal = CreateEntrySignal(13, ind0long && ind1long, ind0short && ind1short, 677, 0, false);
   return (signal);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Signal GetExitSignal_013()
  {
   double ind2val1 = iADX(NULL,0,51,PRICE_CLOSE,1,1) - iADX(NULL,0,51,PRICE_CLOSE,2,1);
   bool ind2long  = ind2val1 > 0 + sigma;
   bool ind2short = ind2val1 < 0 - sigma;

   Signal signal = CreateExitSignal(13, ind2long, ind2short, 677, 0, false);
   return (signal);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Signal GetEntrySignal_014()
  {

   int fromTime0  = 3*3600 + 0*60;
   int untilTime0 = 22*3600 + 59*60;

   MqlDateTime mqlTime0; TimeToStruct(Time(0), mqlTime0);
   int barMinutes0 = mqlTime0.hour*3600 + mqlTime0.min*60;

   bool isOnTime0 = fromTime0 < untilTime0
      ? barMinutes0 >= fromTime0 && barMinutes0 <= untilTime0
      : barMinutes0 >= fromTime0 || barMinutes0 <= untilTime0;

   bool ind0long  = isOnTime0;
   bool ind0short = isOnTime0;
   double ind1val1 = iRSI(NULL,0,28,PRICE_CLOSE,1);
   double ind1val2 = iRSI(NULL,0,28,PRICE_CLOSE,2);
   bool ind1long  = ind1val1 > 40 + sigma && ind1val2 < 40 - sigma;
   bool ind1short = ind1val1 < 100 - 40 - sigma && ind1val2 > 100 - 40 + sigma;
   double ind2val1 = iADX(NULL,0,24,PRICE_CLOSE,0,1);
   double ind2val2 = iADX(NULL,0,24,PRICE_CLOSE,0,2);
   double ind2val3 = iADX(NULL,0,24,PRICE_CLOSE,0,3);
   bool ind2long  = ind2val1 < ind2val2 - sigma && ind2val2 > ind2val3 + sigma;
   bool ind2short = ind2long;

   Signal signal = CreateEntrySignal(14, ind0long && ind1long && ind2long, ind0short && ind1short && ind2short, 230, 0, false);
   return (signal);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Signal GetExitSignal_014()
  {
   double ind3upBand1 = iBands(NULL,0,60,1.15,0,PRICE_CLOSE,MODE_UPPER,1);
   double ind3dnBand1 = iBands(NULL,0,60,1.15,0,PRICE_CLOSE,MODE_LOWER,1);
   bool ind3long  = Open(0) > ind3upBand1 + sigma;
   bool ind3short = Open(0) < ind3dnBand1 - sigma;

   Signal signal = CreateExitSignal(14, ind3long, ind3short, 230, 0, false);
   return (signal);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Signal GetEntrySignal_015()
  {

   int fromTime0  = 3*3600 + 0*60;
   int untilTime0 = 22*3600 + 59*60;

   MqlDateTime mqlTime0; TimeToStruct(Time(0), mqlTime0);
   int barMinutes0 = mqlTime0.hour*3600 + mqlTime0.min*60;

   bool isOnTime0 = fromTime0 < untilTime0
      ? barMinutes0 >= fromTime0 && barMinutes0 <= untilTime0
      : barMinutes0 >= fromTime0 || barMinutes0 <= untilTime0;

   bool ind0long  = isOnTime0;
   bool ind0short = isOnTime0;
   double ind1val1 = iCCI(NULL,0,39,PRICE_TYPICAL,1);
   double ind1val2 = iCCI(NULL,0,39,PRICE_TYPICAL,2);
   bool ind1long  = ind1val1 < -92 - sigma && ind1val2 > -92 + sigma;
   bool ind1short = ind1val1 > -1*-92 + sigma && ind1val2 < -1*-92 - sigma;
   double ind2val1 = iMA(NULL,0,4,0,MODE_SMA,PRICE_CLOSE,1);
   double ind2val2 = iMA(NULL,0,20,0,MODE_SMA,PRICE_CLOSE,1);
   bool ind2long  = ind2val1 > ind2val2 + sigma;
   bool ind2short = ind2val1 < ind2val2 - sigma;

   Signal signal = CreateEntrySignal(15, ind0long && ind1long && ind2long, ind0short && ind1short && ind2short, 502, 0, false);
   return (signal);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Signal GetExitSignal_015()
  {
   double ind3val1 = iMA(NULL,0,29,2,MODE_SMA,PRICE_CLOSE,1);
   double ind3val2 = iMA(NULL,0,29,2,MODE_SMA,PRICE_CLOSE,2);
   bool ind3long  = ind3val1 > ind3val2 + sigma;
   bool ind3short = ind3val1 < ind3val2 - sigma;

   Signal signal = CreateExitSignal(15, ind3long, ind3short, 502, 0, false);
   return (signal);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Signal GetEntrySignal_016()
  {

   int fromTime0  = 3*3600 + 0*60;
   int untilTime0 = 22*3600 + 59*60;

   MqlDateTime mqlTime0; TimeToStruct(Time(0), mqlTime0);
   int barMinutes0 = mqlTime0.hour*3600 + mqlTime0.min*60;

   bool isOnTime0 = fromTime0 < untilTime0
      ? barMinutes0 >= fromTime0 && barMinutes0 <= untilTime0
      : barMinutes0 >= fromTime0 || barMinutes0 <= untilTime0;

   bool ind0long  = isOnTime0;
   bool ind0short = isOnTime0;
   double ind1val1 = iForce(NULL,0,32,MODE_SMA,PRICE_CLOSE,1);
   double ind1val2 = iForce(NULL,0,32,MODE_SMA,PRICE_CLOSE,2);
   double ind1val3 = iForce(NULL,0,32,MODE_SMA,PRICE_CLOSE,3);
   bool ind1long  = ind1val1 > ind1val2 + sigma && ind1val2 < ind1val3 - sigma;
   bool ind1short = ind1val1 < ind1val2 - sigma && ind1val2 > ind1val3 + sigma;
   double ind2val1 = iWPR(NULL,0,10,1);
   double ind2val2 = iWPR(NULL,0,10,2);
   bool ind2long  = ind2val1 < -56 - sigma && ind2val2 > -56 + sigma;
   bool ind2short = ind2val1 > -100 - -56 + sigma && ind2val2 < -100 - -56 - sigma;

   Signal signal = CreateEntrySignal(16, ind0long && ind1long && ind2long, ind0short && ind1short && ind2short, 312, 0, false);
   return (signal);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Signal GetExitSignal_016()
  {
   double ind3val1 = iMA(NULL,0,27,0,MODE_SMA,PRICE_CLOSE,1);
   double ind3val2 = iMA(NULL,0,16,0,MODE_SMA,PRICE_CLOSE,1);
   double ind3val3 = iMA(NULL,0,27,0,MODE_SMA,PRICE_CLOSE,2);
   double ind3val4 = iMA(NULL,0,16,0,MODE_SMA,PRICE_CLOSE,2);
   bool ind3long  = ind3val1 > ind3val2 + sigma && ind3val3 < ind3val4 - sigma;
   bool ind3short = ind3val1 < ind3val2 - sigma && ind3val3 > ind3val4 + sigma;

   Signal signal = CreateExitSignal(16, ind3long, ind3short, 312, 0, false);
   return (signal);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Signal GetEntrySignal_017()
  {

   int fromTime0  = 3*3600 + 0*60;
   int untilTime0 = 22*3600 + 59*60;

   MqlDateTime mqlTime0; TimeToStruct(Time(0), mqlTime0);
   int barMinutes0 = mqlTime0.hour*3600 + mqlTime0.min*60;

   bool isOnTime0 = fromTime0 < untilTime0
      ? barMinutes0 >= fromTime0 && barMinutes0 <= untilTime0
      : barMinutes0 >= fromTime0 || barMinutes0 <= untilTime0;

   bool ind0long  = isOnTime0;
   bool ind0short = isOnTime0;
   double ind1val1 = iMomentum(NULL,0,30,PRICE_CLOSE,1);
   double ind1val2 = iMomentum(NULL,0,30,PRICE_CLOSE,2);
   double ind1val3 = iMomentum(NULL,0,30,PRICE_CLOSE,3);
   bool ind1long  = ind1val1 < ind1val2 - sigma && ind1val2 > ind1val3 + sigma;
   bool ind1short = ind1val1 > ind1val2 + sigma && ind1val2 < ind1val3 - sigma;
   double ind2val1 = iStochastic(NULL,0,8,4,8,MODE_SMA,0,MODE_MAIN,1);
   double ind2val2 = iStochastic(NULL,0,8,4,8,MODE_SMA,0,MODE_SIGNAL,1);
   double ind2val3 = iStochastic(NULL,0,8,4,8,MODE_SMA,0,MODE_MAIN,2);
   double ind2val4 = iStochastic(NULL,0,8,4,8,MODE_SMA,0,MODE_SIGNAL,2);
   bool ind2long  = ind2val1 < ind2val2 - sigma && ind2val3 > ind2val4 + sigma;
   bool ind2short = ind2val1 > ind2val2 + sigma && ind2val3 < ind2val4 - sigma;
   double ind3val1 = iWPR(NULL,0,51,1);
   bool ind3long  = ind3val1 > -35 + sigma;
   bool ind3short = ind3val1 < -100 - -35 - sigma;

   Signal signal = CreateEntrySignal(17, ind0long && ind1long && ind2long && ind3long, ind0short && ind1short && ind2short && ind3short, 649, 0, false);
   return (signal);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Signal GetExitSignal_017()
  {
   double ind4upBand1 = iEnvelopes(NULL,0,9,MODE_SMA,0,PRICE_CLOSE,0.12,MODE_UPPER,1);
   double ind4dnBand1 = iEnvelopes(NULL,0,9,MODE_SMA,0,PRICE_CLOSE,0.12,MODE_LOWER,1);
   double ind4upBand2 = iEnvelopes(NULL,0,9,MODE_SMA,0,PRICE_CLOSE,0.12,MODE_UPPER,2);
   double ind4dnBand2 = iEnvelopes(NULL,0,9,MODE_SMA,0,PRICE_CLOSE,0.12,MODE_LOWER,2);
   bool ind4long  = Open(0) < ind4dnBand1 - sigma && Open(1) > ind4dnBand2 + sigma;
   bool ind4short = Open(0) > ind4upBand1 + sigma && Open(1) < ind4upBand2 - sigma;

   Signal signal = CreateExitSignal(17, ind4long, ind4short, 649, 0, false);
   return (signal);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Signal GetEntrySignal_018()
  {

   int fromTime0  = 3*3600 + 0*60;
   int untilTime0 = 22*3600 + 59*60;

   MqlDateTime mqlTime0; TimeToStruct(Time(0), mqlTime0);
   int barMinutes0 = mqlTime0.hour*3600 + mqlTime0.min*60;

   bool isOnTime0 = fromTime0 < untilTime0
      ? barMinutes0 >= fromTime0 && barMinutes0 <= untilTime0
      : barMinutes0 >= fromTime0 || barMinutes0 <= untilTime0;

   bool ind0long  = isOnTime0;
   bool ind0short = isOnTime0;
   double ind1val1 = iRVI(NULL,0,24,MODE_MAIN,1);
   double ind1val2 = iRVI(NULL,0,24,MODE_MAIN,2);
   bool ind1long  = ind1val1 > 0.00 + sigma && ind1val2 < 0.00 - sigma;
   bool ind1short = ind1val1 < -1*0.00 - sigma && ind1val2 > -1*0.00 + sigma;
   double ind2val1 = iWPR(NULL,0,29,1);
   double ind2val2 = iWPR(NULL,0,29,2);
   double ind2val3 = iWPR(NULL,0,29,3);
   bool ind2long  = ind2val1 > ind2val2 + sigma && ind2val2 < ind2val3 - sigma;
   bool ind2short = ind2val1 < ind2val2 - sigma && ind2val2 > ind2val3 + sigma;

   Signal signal = CreateEntrySignal(18, ind0long && ind1long && ind2long, ind0short && ind1short && ind2short, 596, 0, false);
   return (signal);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Signal GetExitSignal_018()
  {
   double ind3upBand1 = iBands(NULL,0,25,1.68,0,PRICE_CLOSE,MODE_UPPER,1);
   double ind3dnBand1 = iBands(NULL,0,25,1.68,0,PRICE_CLOSE,MODE_LOWER,1);
   bool ind3long  = Open(0) > ind3upBand1 + sigma;
   bool ind3short = Open(0) < ind3dnBand1 - sigma;

   Signal signal = CreateExitSignal(18, ind3long, ind3short, 596, 0, false);
   return (signal);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
ENUM_INIT_RETCODE ValidateInit()
  {
   return (INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
/*STRATEGY MARKET Pepperstone-Demo02; XAUUSD; M30 */

[/y]

Posts: 1

Pages 1

You must login or register to post a reply

Forex Forum → Expert Advisor Modifications → Portfolio Risk Per trade

Similar topics in this forum