There is an interesting trading idea. Help me find errors in the code (mql4). - page 16

 
Sergey Gritsay:
Fixed bugs in the MT5 version

Thanks for the update... mt5 did a decent job this week... If you count from 1000 more than 10%... Here is a picture... had more than 100 today... I will watch this update now, i also thought of combining mt4 with cmilliona grid6https://www.mql5.com/ru/code/12971 to see how it will work together...))

Chart CHFJPY, H1, 2016.03.18 12:21 UTC, MetaQuotes Software Corp.

Мультивалютный сеточник GRID 6 SYMBOLS
Мультивалютный сеточник GRID 6 SYMBOLS
  • votes: 19
  • 2015.05.11
  • Vladimir Khlystov
  • www.mql5.com
Советник выставляет сети стоп-ордеров по нескольким инструментам, далее закрывает все при достижении указанной прибыли.
 
The latest version - works clearly - you can pips - when closing hands opens in the same direction, you should have some kind of delay... Started to trawl a bit more than zero... 2-4 pips, if it goes straight back... duty to think - arrows have been standing for a long time, but no position... And also, has given out more signals compared to previous ones - well, this is just a rough estimate... Well, it's still the best option ... Thanks again ... something else is silent - aou-au who else has found something ... Or do not want to jinx it ...))
 
Сергей Криушин:
The latest version - works clearly - you can pips - when closing hands opens in the same direction, you should have some kind of delay... Started to trawl a bit more than zero... 2-4 pips, if it goes straight back... duty to think - arrows have been standing for a long time, but no position... And also, has given out more signals compared to previous ones - well, this is just a rough estimate... Well, it's still the best option ... Thanks again ... something else is silent - aou-au who else has found something ... or don't want to jinx it...))
If you have a lot of characters, it slows down until it calculates them all. The main idea is that it should not open until a new bar has appeared, that is, it should make one transaction on one bar.
 

Glued the signals of this strategy together with my martin advisor, this is the result from January 2015 to today

EURUSD:

USDCHF:

 
Sergey Gritsay:

Glued the signals of this strategy together with my martin advisor, this is the result from January 2015 to today

EURUSD:

USDCHF:

Mt5 also has a nice Martin fromhttps://www.mql5.com/ru/code/13315 - multiplies the last losing trade... but there are often 2 of these losing trades...
//+------------------------------------------------------------------+
//| Виртуальный стоп                                                 |
//+------------------------------------------------------------------+
void PutLable(const string name="",datetime time=0,double price=0,const color clr=clrGreen)
  {
//--- сбросим значение ошибки
   ResetLastError();
//--- Создаем метку
   if(!ObjectCreate(0,name,OBJ_ARROW_LEFT_PRICE,0,time,price))
     {
      Print(__FUNCTION__,
            ": не удалось создать левую ценовую метку! Код ошибки = ",GetLastError());
      return;
      //--- установим цвет метки
      ObjectSetInteger(0,name,OBJPROP_COLOR,clr);
      //--- установим стиль окаймляющей линии
      ObjectSetInteger(0,name,OBJPROP_STYLE,STYLE_SOLID);
      //--- установим размер метки
      ObjectSetInteger(0,name,OBJPROP_WIDTH,2);
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool isNewBar(string symbol,ENUM_TIMEFRAMES timeframe)
  {
//---- получим время появления текущего бара
   datetime TNew=datetime(SeriesInfoInteger(symbol,timeframe,SERIES_LASTBAR_DATE));
   datetime m_TOld=0;
//--- проверка на появление нового бара
   if(TNew!=m_TOld && TNew)
     {
      m_TOld=TNew;
      //--- появился новый бар!
      return(true);
      Print("Новый бар!");
     }
//--- новых баров пока нет!
   return(false);
  }
//+------------------------------------------------------------------+
//| Возвращает true, если появился новый бар для пары символ/период  |
//+------------------------------------------------------------------+
bool IsNewBar()
  {
//--- в статической переменной будем помнить время открытия последнего бара
   static datetime last_time=0;
//--- текущее время
   datetime lastbar_time=SeriesInfoInteger(Symbol(),Period(),SERIES_LASTBAR_DATE);

//--- если это первый вызов функции
   if(last_time==0)
     {
      //--- установим время и выйдем 
      last_time=lastbar_time;
      return(false);
     }

//--- если время отличается
   if(last_time!=lastbar_time)
     {
      //--- запомним время и вернем true
      last_time=lastbar_time;
      return(true);
     }
//--- дошли до этого места - значит бар не новый, вернем false
   return(false);
  }  
//+------------------------------------------------------------------+
//| Считаем лот в зависимости от полученного профита                 |
//+------------------------------------------------------------------+
double Volume(void)
  {
   double lot=Lots;
//--- Получим доступ к истории
   HistorySelect(0,TimeCurrent());
//--- Сделки в истории
   int orders=HistoryDealsTotal();
//--- Тикет последней сделки  
   ulong ticket=HistoryDealGetTicket(orders-1);
   if(ticket==0)
     {
      Print("Нет сделок в истории! ");
      lot=Lots;
     }
//--- Профит сделки
   double profit=HistoryDealGetDouble(ticket,DEAL_PROFIT);
//--- Лот сделки
   double lastlot=HistoryDealGetDouble(ticket,DEAL_VOLUME);
//--- Профит отрицательный
   if(profit<0.0)
     {
      //--- Увеличиваем следующий лот
      lot=lastlot*KLot;
      Print(" Cделка закрыта по стопу! ");
     }
//--- Приводим лот к минимальному
   double maxvol=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MIN);
   if(lot<maxvol)
      lot=maxvol;
//--- Если лот больше максимального то начальный лот
   if(lot>MaxLot)
      lot=Lots;
//--- Возвращаем торговый объем
   return(lot);
  }
//+------------------------------------------------------------------+
//| Смотрим тип последней закрытой сделки                            |
//+------------------------------------------------------------------+
int LastDealType(void)
  {
   int type=0;
//--- Получим доступ к истории
   HistorySelect(0,TimeCurrent());
//--- Сделки в истории
   int orders=HistoryDealsTotal();
//--- Тикет последней сделки  
   ulong ticket=HistoryDealGetTicket(orders-1);
//--- Нет сделок в истории
   if(ticket==0)
     {
      Print("Нет сделок в истории! ");
      type=0;
     }
   if(ticket>0)
     {
      //--- Последняя сделка BUY 
      if(HistoryDealGetInteger(ticket,DEAL_TYPE)==DEAL_TYPE_BUY)
        {
         type=2;
        }
      //--- Последняя сделка SELL
      if(HistoryDealGetInteger(ticket,DEAL_TYPE)==DEAL_TYPE_SELL)
        {
         type=1;
        }
     }
//---
   return(type);
  }
Well Martin
Well Martin
  • votes: 19
  • 2015.06.25
  • Andrew Kornishkin
  • www.mql5.com
Советник Well Martin на основе двух индикаторов: Bollinger Bands и ADX.
 
Tried to translate for RSI indicator - didn't work... probably doesn't match the library...
//+------------------------------------------------------------------+
ENUM_ORDER_TYPE Get_Signal(string symbol,int index)
  {
   double rsi_s[3];
   double rsi_f[3];
   double thv[1];
   ArrayInitialize(rsi_s,0);
   ArrayInitialize(rsi_f,0);
   ArrayInitialize(thv,0);

   if(Bars(symbol,TF_ATR)<Period_ATR+1)return(WRONG_VALUE);
   if(Bars(symbol,PERIOD_CURRENT)<period_RSI_F+1)return(WRONG_VALUE);

   if(IndicatorTrend==RSI)
     {
      if(Bars(symbol,PERIOD_CURRENT)<period_RSI_S+1)return(WRONG_VALUE);
      if(m_rsi_s[index]==INVALID_HANDLE || m_rsi_s[index]==0){m_rsi_s[index]=iRSI(symbol,PERIOD_CURRENT,period_RSI_S,PRICE_CLOSE);return(WRONG_VALUE);}
      int i=0;
      do
        {
         if(i>Bars(symbol,PERIOD_CURRENT))break;

         if(rsi_s[1]>100.0)trend[index]=ORDER_TYPE_BUY;
         if(rsi_s[1]<-100.0)trend[index]=ORDER_TYPE_SELL;
         if(rsi_s[1]>100.0  &&  rsi_s[0]<100.0)trend[index]=ORDER_TYPE_BUY;
         if(rsi_s[1]<-100.0 && rsi_s[0]>-100.0)trend[index]=ORDER_TYPE_SELL;
         i++;
        }
      while(trend[index]==WRONG_VALUE && !IsStopped());
     }
   if(IndicatorTrend==THV4)
     {
      if(m_thv[index]==INVALID_HANDLE || m_thv[index]==0){m_thv[index]=iCustom(symbol,PERIOD_CURRENT,"::Indicators\\THV4");return(WRONG_VALUE);}
      if(CopyBuffer(m_thv[index],1,1,1,thv)<1) return(WRONG_VALUE);
      if(thv[0]==1.0)trend[index]=ORDER_TYPE_BUY;
      if(thv[0]==0.0)trend[index]=ORDER_TYPE_SELL;
     }

   if(m_rsi_f[index]==INVALID_HANDLE || m_rsi_f[index]==0){m_rsi_f[index]=iRSI(symbol,PERIOD_CURRENT,period_RSI_F,PRICE_CLOSE);return(WRONG_VALUE);}
   if(CopyBuffer(m_rsi_f[index],0,0,3,rsi_f)<3) return(WRONG_VALUE);

      
     
   while(trend[index]==WRONG_VALUE && !IsStopped());

   if(CopyBuffer(m_rsi_f[index],0,0,3,rsi_f)<3) return(WRONG_VALUE);

   if(trend[index]==ORDER_TYPE_BUY)
     {
      if(signal_01 && rsi_f[1]<-100.0)return(ORDER_TYPE_BUY);
      if(signal_02 && rsi_f[1]<-100.0 && rsi_f[0]>-110.0)return(ORDER_TYPE_BUY);
      if(signal_03 && rsi_f[1]>-100.0 && rsi_f[0]<-110.0)return(ORDER_TYPE_BUY);
      if(signal_04 && rsi_f[1]>100.0 && rsi_f[0]<110.0)return(ORDER_TYPE_BUY);
      if(signal_05 && rsi_f[1]>100.0)return(ORDER_TYPE_BUY);
     
     }
   if(trend[index]==ORDER_TYPE_SELL)
     {
      if(signal_01 && rsi_f[1]>100)return(ORDER_TYPE_SELL);
      if(signal_02 && rsi_f[1]>100 && rsi_f[0]<110)return(ORDER_TYPE_SELL);
      if(signal_03 && rsi_f[1]<100 && rsi_f[0]>110)return(ORDER_TYPE_SELL);
      if(signal_04 && rsi_f[1]<-100 && rsi_f[0]>-110)return(ORDER_TYPE_SELL);
      if(signal_05 && rsi_f[1]<-100)return(ORDER_TYPE_SELL);
     
     }

   return(WRONG_VALUE);
  }
 
Сергей Криушин:
Tried to translate for RSI indicator - didn't work... apparently it doesn't match the library...
And whereCopyBuffer is lost in the trend definition block, and RSI has 70 and 30 levels as standard.
 
Sergey Gritsay:
And whereCopyBuffer lost in the trend definition block, and RSI has 70 and 30 standard levels.
yeah i got something mixed up... i had a hundred in my head too... yeah thought it was so easy and simple...)))
 

Please advise where to write or who can help me to correct 2 errors in advisor '}' - unexpected end of program '{' - unbalanced parentheses TMA.mq4

extern int   TakeProfit       =100;
extern int   StopLoss         =50;
extern double Lots            = 0.01;
extern int    Slippage        =5;
extern string comment         ="Продажа";
extern int    Megic           = 123;
extern string Indi            = "данные индикатора";
extern string TimeFrame       = "current time frame";//текущее время кадра
extern int    HalfLength      = 56;
extern int    Price           = PRICE_CLOSE;
extern double ATRMultiplier   = 2.0;
extern int    ATRPeriod       = 100;
extern bool   Interpolate     = true;

double PriceHigh, PriceLow, SL, TP;
int ticket;

int init()
{
     if(Digits==3|| Digits==5)
{    
     
  
 TakeProfit*=10;
    StopLoss*=10;
     Slippage*=10;
     
     
}   
   
    return(0);
    
}

int start()

{
      PriceHigh= iCustom(Symbol(),0,"TMA with Distancer",TimeFrame,HalfLength,Price, ATRMultiplier,ATRPeriod, Interpolate,1,0);
      PriceLow= iCustom(Symbol(),0,"TMA with Distancer",TimeFrame,HalfLength,Price, ATRMultiplier,ATRPeriod, Interpolate,2,0);
    
      if(Bid>=(PriceHigh);
     {
      SL=NormalizeDouble(Bid+StopLoss*Point,Digits);
      TP=NormalizeDouble(Bid-TakeProfit*Point,Digits);
      
     
     ticket=OrderSend(Simbol(),OP_SELL,Lots,Bid,Slippage,0,0,comment,123,0,Maroon);
     
     
 
    
     if(ticket>0);
     
{ 
   if  (OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)==true);
      
      OrderModify(ticket,OrderOpenPrice,ST,TP,0);
      
     }
}
      

   if(Ask<0);
{
   ST=NormalizeDouble(Ask-StopLoss*Point,Digits);
   TP=NormalizeDouble(Ask+TakeProfit*Point,Digits);
  
     ticket=OrderSend(Simbol(),OP_BUY,Lots,Ask,Slippage,0,0,comment,123,0,clrDarkBlue);
     

    
     if(ticket>0);
     
{ 
   if  (OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)==true);
       
      OrderModify(ticket,OrderOpenPrice,ST,TP,0);
     
     }
     return(0);
     
 }

  int CountSell()
  {
   int count=0;
   for(int trede=OrdersTotal()-1;tred>=0;tread--)
   {
    OrderSelect(trade,SELECT_BY_POS,MODE_TRADES);
    if(OrderSymbol()==Symbol()&&OrderMagicNumber()==Megic)
    {
    if (OrderType()==OP_SELL)count==;
    }
    }
    return(count);
    }
    
        
 int CountBuy()
  {
   int count=0;
   for(int trede=OrdersTotal()-1;tred>=0;tread--)
   {
    OrderSelect(trade,SELECT_BY_POS,MODE_TRADES);
    if(OrderSymbol()==Symbol()&&OrderMagicNumber()==Megic)
    {
    if (OrderType()==OP_BUY)count==;
    }
    }
    return(count);
    }


 
vladislavch19:

Please advise where to write or who can help me to correct 2 errors in advisor '}' - unexpected end of program '{' - unbalanced parentheses TMA.mq4



Please insert code correctly:Insert code correctly on forum(I corrected your message).

Added: I also strongly recommend to use code styler - it will help to detect errors(Work with source code: Styler - Program Development).