Spread trading in Meta Trader - page 61

 

Here's a little rework of Igor Kim's script.

Tested it! Works like clockwork!

The script buys the first (specified in the parameters) instrument. And immediately sells the second!

Attention! - Start the script should be strictly on the chart of the first (specified in the PROPERTIES) instrument!

specified by the PROPERTIES ! -I haven't done MarketInfo for it!

Do not forget to put a tick in the box to allow the ADVISOR to trade

External parameters :

#property link      "http://www.kimiv.ru"
#property show_inputs
//------- Внешние параметры скрипта -------------------------------------------+
extern  int    MagicNumber = 12;           // Идентификатор позиции
extern bool   MarketWatch = True;       // Рыночное исполнение
extern string  Symbol_1   = "BRNH0";
extern string  Symbol_2   = "CLH0";

extern double Lots_1        = 0.1;         // Размер лота 1-го инстр.
extern double Lots_2        = 0.1;         // Размер лота 2-го инстр.
extern int    StopLoss    = 0;           // Размер стопа в пунктах
extern int    TakeProfit  = 0;           // Размер тейка в пунктах
int    Slippage    = 3;           // Проскальзывание цены
int    NumberOfTry = 5;           // Количество торговых попыток

//------- Глобальные переменные скрипта ---------------------------------------+
bool   gbDisabled    = False;          // Блокировка
bool   UseSound      = True;           // Использовать звуковой сигнал
string NameFileSound = "expert.wav";   // Наименование звукового файла
color  clOpenBuy     = LightBlue;      // Цвет значка открытия Buy
color  clOpenSell    = LightCoral;     // Цвет значка открытия Sell
 

Whoever downloaded it, please delete it. - delete it. Found a mistake! Fixed it!

Here - the corrected version is in the download.

void start() {
  double sl=0, tp=0, sl_=0, tp_=0;
  
  if ( StopLoss  >0) sl=Ask- StopLoss*Point;   else sl=0;
  if ( TakeProfit>0) tp=Ask+ TakeProfit*Point; else tp=0;  
  OpenPosition( Symbol_1, OP_BUY, Lots_1, sl, tp, MagicNumber);
  
 if ( NumberOfPositions( Symbol_1, OP_BUY, MagicNumber) ==1){ 
 if ( StopLoss  >0) sl_=MarketInfo( Symbol_2,MODE_BID)+
            StopLoss*MarketInfo( Symbol_2,MODE_POINT);   else sl_=0;
 if ( TakeProfit>0) tp_=MarketInfo( Symbol_2,MODE_BID)-
            TakeProfit*MarketInfo( Symbol_2,MODE_POINT); else tp_=0;
  OpenPosition( Symbol_2, OP_SELL, Lots_2, sl_, tp_, MagicNumber);
                                                          }
}
//------ далее идут польз. ф-и И.Кима --------------
Files:
 
rid писал(а) >>

Whoever downloaded it, please delete it. - delete it. Found a mistake! Fixed it!

Here's the corrected version in the download.

Thanks, it works fine!

 

I don't understand something. For some reason, - on demo B account. - on CL oil, I'm missing quotes on tf=N1 for Jan 26-27.

Everything is normal on the rest of the timeframe. But here (on Н1) - it is missing.

Is it just me? Or is it the same for all of them?


 
I'm on Demo B. Everything is in order. All days in order 25-26-27-28
 
vldim >>:
У меня на демо Б. Все в порядке. Все дни по порядку 25-26-27-28

The performance on the B demo is completely different than on the real one. It's a fairy tale on the demo, not the same on the real. Keep that in mind and don't count on the same results on the real.

 

I have discovered (by surfing the Internet on the "fundamental" topic) several more instruments where the stated tactics have good prospects! Yes, not bad, - very attractive prospects - for daily entries!

Gold+silver - here they "rest" ("nervously smoking in the corridor ...")!

I'll try some experiments and will show them at the weekend!

 
rid >>:

Обнаружил (полистав странички инета в "фундаментальную" тему) ещё несколько инструментов, на которых заявленная тактика имеет неплохие перспективы! Да, что там неплохие, - оч. даже привлекательные перспективы - для ежедневных входов! Золото+серебро, - тут "отдыхают"( - "нервно курят в коридоре..")!

Поэкспериментирую и в выходные выложу на обозрение!


most likely related to the rts or russian giants' stocks

 

Wrong! In mt4 B. shorts on rossaqs are forbidden.

 
neoclassic >>:
Скрипт, рассчитывающий равновесный лот по инструментам. Просьба сравнить со своими рассчетами


This script is also available - p. 54. 54.

It works very well!

But here in PROPERTIES we need to enter coefficients (at least one coefficient) for instruments with different dimensions.

.