0
Пока такая формула: www.opentraders.ru/downloads/1387/

if(Lot==0) lots=AccountEquity()/(Count*2*10000);




avatar

AM2

  • 10 ноября 2016, 08:54
0
Почти все сделано, только для п.3 укажите формулу по которой вести расчет лота.
avatar

AM2

  • 10 ноября 2016, 08:29
+2
Обращайтесь отдельным топиком, добавлю. Здесь ветка автора.
avatar

AM2

  • 10 ноября 2016, 07:29
+1
Сделал раз на свечке:

//+------------------------------------------------------------------+
//|                                                        Poker.mq5 |
//|                                              Copyright 2016, AM2 | 
//|                                     https://www.forexsystems.biz | 
//+------------------------------------------------------------------+ 
#property copyright "Copyright 2016, AM2" 
#property link "https://www.forexsystems.biz" 
#property version   "1.00"

#include <Trade\Trade.mqh>             // Use CTrade Class

input double   Lot        = 1;         // Лот
input int      TakeProfit = 333;       // Тейкпрофит
input int      StopLoss   = 333;       // Стоплосс
input int      Points     = 50;        // Размер свечи
input int      Slip       = 50;        // Проскальзывание
input bool     Mail       = true;      // Шлем на почту
input bool     CloseSig   = true;      // Закрытие по сигналу

int AOHandle=0,MAHandle=0;
double ma[1],ao1[1],ao2[1],op[1],cl[1],opa[1],open;
CTrade trade;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---

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

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   double Ask=SymbolInfoDouble(_Symbol,SYMBOL_ASK);
   double Bid=SymbolInfoDouble(_Symbol,SYMBOL_BID);

   AOHandle=iAO(NULL,0);
   MAHandle=iMA(NULL,0,8,0,1,0);

   CopyBuffer(AOHandle,0,0,1,ao1);
   CopyBuffer(AOHandle,0,1,1,ao2);
   CopyBuffer(MAHandle,0,1,1,ma);

   CopyOpen(NULL,0,1,1,op);
   CopyOpen(NULL,0,0,1,opa);
   CopyClose(NULL,0,1,1,cl);

   if(open!=opa[0])
     {
      if(PositionsTotal()<1)
        {
         if(MathAbs((op[0]-cl[0])/_Point>Points))
           {
            if(Ask>ma[0] && ao1[0]>ao2[0])
              {
               trade.PositionOpen(_Symbol,0,Lot,Ask,Ask-StopLoss*_Point,Ask+TakeProfit*_Point);
               if(Mail) SendMail("Position Open","Open Buy");
              }

            if(Bid<ma[0] && ao1[0]<ao2[0])
              {
               trade.PositionOpen(_Symbol,1,Lot,Bid,Bid+StopLoss*_Point,Bid-TakeProfit*_Point);
               if(Mail) SendMail("Position Open","Open Sell");
              }
           }
        }
      open=opa[0];
      
      if(PositionsTotal()>0 && open!=opa[0])
        {
         if(MathAbs((op[0]-cl[0])/_Point>Points) && CloseSig)
           {
            if(Ask>ma[0] && ao1[0]>ao2[0] && PositionGetInteger(POSITION_TYPE)==1) trade.PositionClose(_Symbol);
            if(Bid<ma[0] && ao1[0]<ao2[0] && PositionGetInteger(POSITION_TYPE)==0) trade.PositionClose(_Symbol);
           }
        }
      open=opa[0];
     }
  }
//+------------------------------------------------------------------+
avatar

AM2

  • 9 ноября 2016, 20:31
0
Открывает закрывает по МА и АО. Раз на свечке добавлю вечером.
avatar

AM2

  • 9 ноября 2016, 13:34
0
Поправил: www.opentraders.ru/downloads/1376/




//+------------------------------------------------------------------+
//|                                                      Nedelka.mq4 |
//|                                              Copyright 2016, AM2 |
//|                                      http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, AM2"
#property link      "http://www.forexsystems.biz"
#property version   "1.00"
#property strict

//--- Inputs
extern double Lots       = 0.1;      // лот
extern int StopLoss      = 2000;     // лось
extern int TakeProfit    = 3000;     // язь
extern int Spread        = 20;       // спред
extern int Delta         = 300;      // дельта
extern int BuySell       = 0;        // 0-buy 1-sell
extern int StartHour     = 0;        // час начала торговли
extern int StartMin      = 30;       // минута начала торговли
extern int EndHour       = 23;       // час окончания торговли
extern int EndMin        = 30;       // минута окончания торговли
extern int Slip          = 30;       // реквот
extern int Magic         = 123;      // магик

datetime t=0;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   Comment("");
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   Comment("");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void PutOrder(int type,double price)
  {
   int r=0;
   color clr=Green;
   double sl=0,tp=0;

   if(type==1 || type==3 || type==5)
     {
      clr=Red;
      if(StopLoss>0) sl=NormalizeDouble(price+StopLoss*Point,Digits);
      if(TakeProfit>0) tp=NormalizeDouble(price-TakeProfit*Point,Digits);
     }

   if(type==0 || type==2 || type==4)
     {
      clr=Blue;
      if(StopLoss>0) sl=NormalizeDouble(price-StopLoss*Point,Digits);
      if(TakeProfit>0) tp=NormalizeDouble(price+TakeProfit*Point,Digits);
     }

   r=OrderSend(NULL,type,Lots,NormalizeDouble(price,Digits),Slip,sl,tp,"",Magic,0,clr);
   return;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int CountTrades()
  {
   int count=0;
   for(int i=OrdersTotal()-1;i>=0;i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
           {
            if(OrderType()<2) count++;
           }
        }
     }
   return(count);
  }
//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 30.04.2009                                                     |
//|  Описание : Возвращает флаг разрешения торговли по времени.                |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    hb - часы времени начала торговли                                       |
//|    mb - минуты времени начала торговли                                     |
//|    he - часы времени окончания торговли                                    |
//|    me - минуты времени окончания торговли                                  |
//+----------------------------------------------------------------------------+
bool isTradeTimeInt(int hb=0,int mb=0,int he=0,int me=0)
  {
   datetime db, de;           // Время начала и окончания работы
   int      hc;               // Часы текущего времени торгового сервера

   db=StrToTime(TimeToStr(TimeCurrent(), TIME_DATE)+" "+(string)hb+":"+(string)mb);
   de=StrToTime(TimeToStr(TimeCurrent(), TIME_DATE)+" "+(string)he+":"+(string)me);
   hc=TimeHour(TimeCurrent());

   if(db>=de)
     {
      if(hc>=he) de+=24*60*60; else db-=24*60*60;
     }

   if(TimeCurrent()>=db && TimeCurrent()<=de) return(True);
   else return(False);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   datetime Weak=iTime(NULL,PERIOD_W1,0);
   double OpenPrice=iOpen(NULL,PERIOD_W1,1);
   double spread=MarketInfo(NULL,MODE_SPREAD);

   if(t!=Weak)
     {
      if(isTradeTimeInt(StartHour,StartMin,EndHour,EndMin))
        {
         if(CountTrades()<1 && spread<Spread)
           {
            if(BuySell==0 && Ask<OpenPrice+Delta*Point)
              {
               PutOrder(0,Ask);
              }

            if(BuySell==1 && Bid>OpenPrice-Delta*Point)
              {
               PutOrder(1,Bid);
              }
            t=Weak;
           }
        }
     }

   Comment("\n Spread: ",spread,"\n OpenPrice: ",OpenPrice);
  }
//+------------------------------------------------------------------+

avatar

AM2

  • 9 ноября 2016, 06:58
0
Текущий тф любой может быть.
avatar

AM2

  • 8 ноября 2016, 20:56
0
Нет предмета для разговора. Ни настроек ни скринов ни логов.
avatar

AM2

  • 8 ноября 2016, 20:20
0
Готово: www.opentraders.ru/downloads/1386/




//+------------------------------------------------------------------+
//|                                                       2MaSig.mq4 |
//|                                              Copyright 2016, AM2 |
//|                                      http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, AM2"
#property link      "http://www.forexsystems.biz"
#property version   "1.00"
#property strict

//--- Inputs
extern double Lots       = 0.1;      // лот
extern int StopLoss      = 2000;     // лось
extern int TakeProfit    = 3000;     // язь
extern int BULevel       = 0;        // уровень БУ
extern int BUPoint       = 30;       // пункты БУ
extern int TrailingStop  = 0;        // трал
extern int Slip          = 30;       // реквот
extern int Count         = 3;        // число ордеров
extern int Shift         = 1;        // на каком баре сигнал индикатора
extern int Magic         = 123;      // магик

extern string IndName         = "MA2_Signal";
extern int    ExtPeriodFastMA = 5;
extern int    ExtPeriodSlowMA = 7;
extern int    ExtModeFastMA   = 1; // 0 = SMA, 1 = EMA, 2 = SMMA, 3 = LWMA
extern int    ExtModeSlowMA   = 1; // 0 = SMA, 1 = EMA, 2 = SMMA, 3 = LWMA
extern int    ExtPriceFastMA  = 0; // 0 = Close, 1 = Open, 2 = High, 3 = Low, 4 = HL/2, 5 = HLC/3, 6 = HLCC/4
extern int    ExtPriceSlowMA  = 1; // 0 = Close, 1 = Open, 2 = High, 3 = Low, 4 = HL/2, 5 = HLC/3, 6 = HLCC/4

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   Comment("");
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   Comment("");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void PutOrder(int type,double price)
  {
   int r=0;
   color clr=Green;
   double sl=0,tp=0;

   if(type==1 || type==3 || type==5)
     {
      clr=Red;
      if(StopLoss>0) sl=NormalizeDouble(price+StopLoss*Point,Digits);
      if(TakeProfit>0) tp=NormalizeDouble(price-TakeProfit*Point,Digits);
     }

   if(type==0 || type==2 || type==4)
     {
      clr=Blue;
      if(StopLoss>0) sl=NormalizeDouble(price-StopLoss*Point,Digits);
      if(TakeProfit>0) tp=NormalizeDouble(price+TakeProfit*Point,Digits);
     }

   r=OrderSend(NULL,type,Lots,NormalizeDouble(price,Digits),Slip,sl,tp,"",Magic,0,clr);
   return;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int CountTrades()
  {
   int count=0;
   for(int i=OrdersTotal()-1;i>=0;i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
           {
            if(OrderType()<2) count++;
           }
        }
     }
   return(count);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Trailing()
  {
   bool mod;
   for(int i=OrdersTotal()-1;i>=0;i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
           {
            if(OrderType()==OP_BUY)
              {
               if(Bid-OrderOpenPrice()>TrailingStop*Point)
                 {
                  if(OrderStopLoss()<Bid-TrailingStop*Point)
                    {
                     mod=OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*Point,OrderTakeProfit(),0,Yellow);
                     return;
                    }
                 }
              }

            if(OrderType()==OP_SELL)
              {
               if((OrderOpenPrice()-Ask)>TrailingStop*Point)
                 {
                  if((OrderStopLoss()>(Ask+TrailingStop*Point)) || (OrderStopLoss()==0))
                    {
                     mod=OrderModify(OrderTicket(),OrderOpenPrice(),Ask+TrailingStop*Point,OrderTakeProfit(),0,Yellow);
                     return;
                    }
                 }
              }
           }
        }
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void BU()
  {
   bool m;
   for(int i=OrdersTotal()-1;i>=0;i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
           {
            if(OrderType()==OP_BUY)
              {
               if(OrderOpenPrice()<=(Bid-(BULevel+BUPoint)*Point) && OrderOpenPrice()>OrderStopLoss())
                 {
                  m=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+BUPoint*Point,OrderTakeProfit(),0,Yellow);
                  return;
                 }
              }

            if(OrderType()==OP_SELL)
              {
               if(OrderOpenPrice()>=(Ask+(BULevel+BUPoint)*Point) && (OrderOpenPrice()<OrderStopLoss() || OrderStopLoss()==0))
                 {
                  m=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-BUPoint*Point,OrderTakeProfit(),0,Yellow);
                  return;
                 }
              }
           }
        }
     }
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   double blue = iCustom(NULL,0,IndName,ExtPeriodFastMA,ExtPeriodSlowMA,ExtModeFastMA,ExtModeSlowMA,ExtPriceFastMA,ExtPriceSlowMA,2,Shift);
   double red  = iCustom(NULL,0,IndName,ExtPeriodFastMA,ExtPeriodSlowMA,ExtModeFastMA,ExtModeSlowMA,ExtPriceFastMA,ExtPriceSlowMA,3,Shift);

   if(CountTrades()<1)
     {
      if(blue<1000)
        {
         for(int i=0;i<Count;i++) PutOrder(0,Ask);
        }

      if(red<1000)
        {
         for(int i=0;i<Count;i++) PutOrder(1,Bid);
        }
     }

   if(BULevel>0) BU();
   if(TrailingStop>0) Trailing();

   Comment("\n blue: ",blue,
           "\n red: ",red);
  }
//+------------------------------------------------------------------+



avatar

AM2

  • 8 ноября 2016, 20:18
0
А не проще использовать стандартный индикатор
avatar

AM2

  • 8 ноября 2016, 12:45
0
Править чужой код не возьмусь, ТЗ рассмотрю.
avatar

AM2

  • 7 ноября 2016, 15:30
0
Cделал музыку и алерт на смене сигнала: www.opentraders.ru/downloads/1380/

avatar

AM2

  • 6 ноября 2016, 17:39
0
Когда сигналить должен?
avatar

AM2

  • 6 ноября 2016, 17:18
0
Если будет свободное время добавлю.
avatar

AM2

  • 6 ноября 2016, 12:47