A very useful indicator - page 3

 
Vitalii Ananev:

Do you have anything like that for QuickBooks?

No, I only write experts for KVIC and that in Delphi

 
prostotrader:

No, I only write experts for KVIC and that in Delphi.

That's a pity. My broker has only quickie. I'm trying to get to grips with lua, but after MT I don't feel like lua. I have never tried to use it because it seems to be too complicated and confusing at first sight. And I can't find any normal examples with comments.

 
prostotrader:

What you're going to peddle sucks,

but the graphics are beautiful.)

I'd rather surf the web with this sucker than look at a chart, it's more useful.

 
Vitalii Ananev:

Pity. My broker only has quickie. I'm trying to get a handle on lua, but after MT I don't feel like lua. It's very confusing and complicated at first sight. And you won't find any good examples with comments.

The worst thing is not that, but that there is no normal debugger,

so you can't test anything big at all!

 
__zeus__:

I'd rather surf the web with this rubbish than bury myself in a chart, it's more useful.

I already told you, do what you like.

 
prostotrader:

The worst part isn't that, it's that there's no proper debugger,

so you can't test anything big at all!

That's scary too. I've seen there is a DDE data export. In settings it says to specify DDE server. Everywhere in the examples saw the use of excel. I do not understand if it is just a mistake in terminology or it is really so. Excel should be specified there asa DDE server, and I think it should be the other way round - Excel is a DDE client and Quick DDE server. The data is transferred from Quicksilver to Excel, not the other way around.

 

Here is a useful indicator.

And now this TS works (currencies are highly volatile), but

Unfortunately, only on demo.

Due to the fact that there are big delays in MT5, this TS (synthetic Eu)

will be unprofitable, although, by nature, it is 100% profitable

Eu(natural) = Si * ED

Who is interested, can "play"

Imagine, those who are now "sitting" on Plaza 2 (there are no delays)!

//+------------------------------------------------------------------+
//|                                                     Eu_ED_Si.mq5 |
//|                                          Copyright 2015, Mikalas |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015"
#property link      "http://www.mql5.com"
#property version   "1.01"
#define  on_call -1111
//
#property indicator_separate_window

#property indicator_buffers 2
#property indicator_plots   2

//--- plot Label1
#property indicator_label1  "Ask"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrRed
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1

//--- plot Label1
#property indicator_label2  "Bid"
#property indicator_type2   DRAW_LINE
#property indicator_color2  clrRoyalBlue
#property indicator_style2  STYLE_SOLID
#property indicator_width2  1
//--- Levels
#property indicator_level1 0
#property indicator_level2 0
#property indicator_level3 0
#property indicator_level4 0

//---
#property indicator_levelwidth 1
//---
#property indicator_levelstyle STYLE_DOT
//
string ed_symbol;
string si_symbol;
string symb_info;
string eu_b_name;
string si_b_name;
string ed_b_name;
//
input long   LevUp     = 100;   //Макс. уровень индикатора
input long   LevDown   = -100;  //Мин. уровень индикатора
input long   Comis     = 8;    //Комиссии (пункты)  
input long   LevelHigh = 15;   //Линия верхнего уровня (пункты)  
input long   LevelLow  = -15;  //Линия нижнего уровня (пункты)  
input long   EntHigh   = 20;   //Вхрод вверху (пункты)
input long   ExitHigh  = 5;    //Выход вверху (пункты)
input long   EntLow    = -20;  //Вход внизу (пункты)
input long   ExitLow   = -5;   //Выход внизу (пункты)

//--- indicator buffers
double AskBuffer[];
double BidBuffer[];
double eu_sell_price, eu_buy_price,
       ed_sell_price, ed_buy_price,
       si_sell_price, si_buy_price;
double max_value, min_value;   
double si_point, eu_point, ed_point;    
//
int event_cnt;
bool eu_book;
bool si_book;
bool ed_book;
//
enum EXP_STATE
{
  POS_NONE = 0,
  POS_HIGH = 1,
  POS_LOW  = 2
};
struct MEM_PRICES
{
  double eu_price;
  double ed_price;
  double si_price;
};

EXP_STATE exp_state;
MEM_PRICES mem_prices;
long profit;
//+------------------------------------------------------------------+
//| Indicator Set second Symbols function                            |
//+------------------------------------------------------------------+
void SetSecondSymbols( const string aSymbol, string &s_info )
{
  int str_size = StringLen( aSymbol );
    
  for( int i = 0; i < str_size; i++ )
  {
    ushort let_symbol = StringGetCharacter( aSymbol, i );
    if ( let_symbol == '-')
    {
      string hvost = StringSubstr( aSymbol, i, str_size - i );
      s_info = StringSubstr( aSymbol, 0, i );
      
      if ( s_info == "Eu" )
      {
        si_symbol = "Si" + hvost;
        ed_symbol = "ED" + hvost;
      }
      break;
    }
  }
}
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
  profit = 0;
  exp_state = POS_NONE;
  max_value = -DBL_MAX;
  min_value = DBL_MAX;
  eu_book = 0;
  si_book = 0;
  ed_book = 0;
  event_cnt = 0;
  SetSecondSymbols(Symbol(), symb_info);
  if(symb_info != "Eu")
  {
    Print("Индикатор должен быть только на символе 'Eu'!");
    return(INIT_FAILED);
  }
//---
  if(!SymbolSelect(ed_symbol, true))
  {
    Print("Нет сивола 'ED'!");
    return(INIT_FAILED);
  }
  if(!SymbolSelect(si_symbol, true))
  {
    Print("Нет сивола 'Si'!");
    return(INIT_FAILED);
  }  
//---
  eu_point = Point();
  ed_point = SymbolInfoDouble(ed_symbol, SYMBOL_POINT);
  si_point = SymbolInfoDouble(si_symbol, SYMBOL_POINT);  
//--- Add book
  eu_book = MarketBookAdd(Symbol());
  if(eu_book == false)
  {
    Print("Стакан символа " + Symbol() + " не добавден!");
    return(INIT_FAILED);
  }
  ed_book = MarketBookAdd(ed_symbol);
  if(ed_book == false)
  {
    Print("Стакан символа " + ed_symbol + " не добавден!");
    return(INIT_FAILED);
  }
  si_book = MarketBookAdd(si_symbol);
  if(si_book == false)
  {
    Print("Стакан символа " + si_symbol + " не добавден!");
    return(INIT_FAILED);
  }
//---  
  IndicatorSetInteger( INDICATOR_DIGITS, Digits() );
  IndicatorSetString( INDICATOR_SHORTNAME, "Eu_Ask_Bid" );
//---  
  SetIndexBuffer( 0, AskBuffer, INDICATOR_DATA );
  PlotIndexSetDouble( 0, PLOT_EMPTY_VALUE, EMPTY_VALUE );
  ArraySetAsSeries( AskBuffer, true );
//---
  SetIndexBuffer( 1, BidBuffer, INDICATOR_DATA );
  PlotIndexSetDouble( 1, PLOT_EMPTY_VALUE, EMPTY_VALUE );
  ArraySetAsSeries( BidBuffer, true );
//---
  IndicatorSetInteger(INDICATOR_LEVELCOLOR, 0, clrAqua);
  IndicatorSetInteger(INDICATOR_LEVELCOLOR, 1, clrAqua);
  IndicatorSetInteger(INDICATOR_LEVELCOLOR, 2, clrRed);
  IndicatorSetInteger(INDICATOR_LEVELCOLOR, 3, clrRoyalBlue); 
//---
  IndicatorSetDouble(INDICATOR_LEVELVALUE, 0, LevelHigh);
//  IndicatorSetDouble( INDICATOR_LEVELVALUE, 1, LevelExitHigh );
  IndicatorSetDouble(INDICATOR_LEVELVALUE, 1, LevelLow);

  IndicatorSetDouble(INDICATOR_MAXIMUM, LevUp);
  IndicatorSetDouble(INDICATOR_MINIMUM, LevDown);
//---
  //---Set objects
   int window=ChartWindowFind(ChartID(),"Eu_Ask_Bid");
   ObjectCreate(ChartID(),"Eu_label_1",OBJ_LABEL,window,0,0);
   ObjectSetInteger(ChartID(),"Eu_label_1",OBJPROP_YDISTANCE,20);
   ObjectSetInteger(ChartID(),"Eu_label_1",OBJPROP_XDISTANCE,0);
   ObjectSetInteger(ChartID(),"Eu_label_1",OBJPROP_COLOR,clrWhite);
   ObjectSetString(ChartID(),"Eu_label_1",OBJPROP_TEXT,"Position: " + EnumToString(exp_state));
   ObjectCreate(ChartID(),"Eu_label_2",OBJ_LABEL,window,0,0);
   ObjectSetInteger(ChartID(),"Eu_label_2",OBJPROP_YDISTANCE,40);
   ObjectSetInteger(ChartID(),"Eu_label_2",OBJPROP_XDISTANCE,0);
   ObjectSetInteger(ChartID(),"Eu_label_2",OBJPROP_COLOR,clrLime);
   ObjectSetString(ChartID(),"Eu_label_2",OBJPROP_TEXT,"Profit: " + string(profit) + " points");
//---
  ChartRedraw();
  return( INIT_SUCCEEDED );
}
//+------------------------------------------------------------------+
// Custom indicator DeInit function                                  |
//+------------------------------------------------------------------+
void OnDeinit( const int reason )
{
  ObjectDelete(ChartID(),"Eu_label_1");
  ObjectDelete(ChartID(),"Eu_label_2");
//---  
 if (eu_book == true) MarketBookRelease(Symbol());
 if (ed_book == true) MarketBookRelease(ed_symbol);
 if (si_book == true) MarketBookRelease(si_symbol);
//---  
  if(reason == REASON_INITFAILED)
  {
    Print("Индикатор удалён! Причина - ошибка инициализации.");
    string short_name = ChartIndicatorName( ChartID(), 1, 0);
    ChartIndicatorDelete(ChartID(), 1, short_name); 
  }
}
//+------------------------------------------------------------------+
// Custom indicator On book event function                           |
//+------------------------------------------------------------------+
void OnBookEvent( const string& a_symbol )
{
  if((a_symbol == Symbol()) || (a_symbol == ed_symbol) || (a_symbol == si_symbol))
  {
    eu_sell_price = SymbolInfoDouble(Symbol(), SYMBOL_ASK);
    eu_buy_price = SymbolInfoDouble(Symbol(), SYMBOL_BID);
    ed_sell_price = SymbolInfoDouble(ed_symbol, SYMBOL_ASK);
    ed_buy_price = SymbolInfoDouble(ed_symbol, SYMBOL_BID);
    si_sell_price = SymbolInfoDouble(si_symbol, SYMBOL_ASK);
    si_buy_price = SymbolInfoDouble(si_symbol, SYMBOL_BID);
//---
    double price[]; 
    OnCalculate( event_cnt, event_cnt, on_call, price ); 
  }
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate( const int rates_total,
                 const int prev_calculated,
                 const int begin,
                 const double &price[] )

{
  if(prev_calculated == 0)
  {
    ArrayInitialize(AskBuffer, EMPTY_VALUE);
    ArrayInitialize(BidBuffer, EMPTY_VALUE); 
  }
  else
  {
    if(begin == on_call)
    {
      for(int i = rates_total - 1; i > 0; i--)
      {
        AskBuffer[i] = AskBuffer[i - 1];
        BidBuffer[i] = BidBuffer[i - 1];
      }
    }
    if((ed_sell_price > 0) && (si_sell_price > 0) && (eu_sell_price > 0) &&
       (ed_buy_price > 0) && (si_buy_price > 0) && (eu_buy_price > 0))
    {
      AskBuffer[0] = ed_sell_price * si_sell_price - eu_buy_price;
      BidBuffer[0] = ed_buy_price * si_buy_price - eu_sell_price;
      if ( AskBuffer[0] < min_value ) min_value = AskBuffer[0];
      if ( BidBuffer[0] > max_value ) max_value = BidBuffer[0];
      IndicatorSetDouble(INDICATOR_LEVELVALUE, 2, min_value);
      IndicatorSetDouble(INDICATOR_LEVELVALUE, 3, max_value);
      switch (exp_state)
      {
        case POS_NONE:
          if(BidBuffer[0] >= (EntHigh * Point()))
          {
            mem_prices.eu_price = eu_sell_price;
            mem_prices.ed_price = ed_buy_price;
            mem_prices.si_price = si_buy_price;
            exp_state = POS_HIGH;
          }
          else
          if(AskBuffer[0] <= (EntLow * Point()))
          {
            mem_prices.eu_price = eu_buy_price;
            mem_prices.ed_price = ed_sell_price;
            mem_prices.si_price = si_sell_price;
            exp_state = POS_LOW;
          }
        break;
        case POS_HIGH:
          if(AskBuffer[0] <= (ExitHigh * Point()))
          {
            profit += long((eu_buy_price - mem_prices.eu_price)/eu_point + (ed_sell_price - mem_prices.ed_price)/ed_point + (si_sell_price - mem_prices.si_price)/si_point) - Comis;
            exp_state = POS_NONE;
          }
        break;
        case POS_LOW:
          if(BidBuffer[0] >= (ExitLow * Point()))
          {
            profit += long((mem_prices.eu_price - eu_buy_price)/eu_point + (mem_prices.ed_price - ed_sell_price)/ed_point + (mem_prices.si_price - si_sell_price)/si_point) - Comis;
            exp_state = POS_NONE;
          }
        break;
      }
    }
    else
    {
      AskBuffer[0] = AskBuffer[1];
      BidBuffer[0] = BidBuffer[1];
    }
  }
  ObjectSetString(ChartID(),"Eu_label_1",OBJPROP_TEXT,"Position: " + EnumToString(exp_state));
  ObjectSetString(ChartID(),"Eu_label_2",OBJPROP_TEXT,"Profit: " + string(profit) + " points");
//---
  ChartRedraw();
  event_cnt = rates_total; 
  return(rates_total);
}

//+------------------------------------------------------------------+
 
prostotrader:

Here is a useful indicator.

And now this TS works (currencies are highly volatile), but

Unfortunately, only on demo.

Due to the fact that there are big delays in MT5, this TS (synthetic Eu)

will be unprofitable, although, by nature, it is 100% profitable

Eu(natural) = Si * ED

Who is interested, can "play"

Imagine, those who are now "sitting" on Plaza 2 (there are no delays)!

Thank you ! Of course, what does it take to make it work ?
 
Alexsandr San:
I am not sure what I need to make it work, thank you!

Fast operation of MT5.

Well and write an Expert Advisor (although this indicator is an Expert Advisor, only without placing orders)

It works on a real account in simulation mode.

Как заказать торгового робота на MQL5 и MQL4
Как заказать торгового робота на MQL5 и MQL4
  • www.mql5.com
Главным преимуществом торговых терминалов MetaTrader является возможность создания автоматических торговых систем, способных совершать торговые операции без вмешательства трейдера, что позволяет исключить влияние психологии на результаты торговли. Для этого нужно сформулировать торговую стратегию и реализовать ее в виде программы на языке MQL...
 
prostotrader:

Fast operation of MT5.

Well and write an Expert Advisor (although this indicator is an Expert Advisor, only without placing orders)

It works on a real account in simulation mode.

Sorry! What is the symbol (the indicator should only be on the 'Eu' symbol!) ?

Photo by

Reason: