[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 390

 
chief2000 >>:

Я экспортировал CSV-файл (1 мин с 1999 года) из МТ одного брокера. Попытался импортировать в МТ другого брокера - 1 минутки получил

без проблем, с 1999. Но вот что-то не пойму как во 2-м МТ получить 5, 15-мин и т.д. графики? - Т.е. после импортирования 1 минуток переключился на

5 минутный график и похоже МТ пытается докачать их из интернета, вместо конвертирования их из уже имеющихся 1-минуток.

Перегружал МТ - не помогло.

- Есть какое-нибудь нормальное решение для конвертирования 1 МИН в более высокие таймфреймы?

Well of course there will be downloading, so why should there be any conversion from the minutes.

You can take the original CSV and run a self-written program to get all the standard timeframes in the output files and import them.

 

Hi all!

There is no way I can implement a simple algorithm:

After a buy/sell an order closes after 2 bars.

I can't think of anything better than a timer, but the timer is linked to a timeframe and I need it after n bars.

 

Hello again and again a question that I cannot answer myself.

I am writing an Expert Advisor to practice placing orders when a condition appears. The task is simple: to trade only one position. If the price is above МА10, I will buy; if it is below, I will sell. I want to test the possibility of using magicians of orders so that the Expert Advisor would close exactly those orders that it placed itself. There is also the second variant of buy and sell conditions (I have not added them yet). And it should determine by itself what condition the order belongs to - the magic number is set in the function that triggers opening of a position. In the same way, according to the conditions, at the very beginning it should determine whether there is a position or not and then either search for Buy or Sell conditions.


Here is the code:


// Мувинг и цена
double MA10;
double Price;
// Есть или нет позиция и ее номер
int Pos;
int Magic;
double Lot=0.1;
double SL;
double TP;
int Slippage=3;

//--------------------------------------------------------------------

void start()
{
MA10 = iMA(NULL,0,10,0,0,0,0);
Price = Bid;

CheckPos();
}

//--------------------------------------------------------------------

void CheckPos()
{
if(Pos==0)
CheckBuy();
CheckSell();
}

//--------------------------------------------------------------------
// Поиск условий для покупки и продажи
//--------------------------------------------------------------------

void CheckBuy()
{
if (NormalizeDouble(Price,Digits) > NormalizeDouble(MA10,Digits))
Magic=10;
Buy();
return;
}

//--------------------------------------------------------------------

void CheckSell()
{
if (NormalizeDouble(Price,Digits) < NormalizeDouble(MA10,Digits))
Sell();
return;
}

//--------------------------------------------------------------------
// Выставление ордеров
//--------------------------------------------------------------------

void Buy()
{
string Symb=Symbol();
Pos=1;

OrderSend(Symb, OP_BUY, Lot, Ask, Slippage, SL, TP, NULL, Magic);
return;
}
//--------------------------------------------------------------------

void Sell()
{
Pos=0;
OrderClose(Magic, Lot, Bid, Slippage);
return;
}


And this code, despite the fact that it should trade only one position (yes, we should look for sell conditions, no, we should look for buy conditions), it opens a large number of positions and then does not close them. My head is already broken. Can you tell me what's wrong?

 
sigma7i >>:

Всем привет!

Простой алгоритм никак не могу реализовать:

После покупки/продажи закрытие ордера через 2 бара.

Кроме таймера ничего лучше придумать не могу, но у таймера есть привязка к тайм фрейму, а мне необходимо через n баров.


Go through the open orders, see when they were opened and compare with the current time, two bars have passed and close them.
 
splxgf >>:

Ну естественно будет происходить докачка, с чего вдруг она должна происходить конвертация из минуток.

Можно взять исходный CSV и прогнать самописной прогой для получения на выходе в файлах всех стандартных таймфремов и импортировать их.

I seem to have confused it with MT5 - it seems that higher timeframes are generated from 1-minute periods, whereas in MT4 it's the same old-fashioned way.

 
Vinin >>:

Скрипт в CodeBase лежит, так и называется период конвертор

Thank you!

 

Period converter is good for graphs, but you can't feed it to a tester.

Oops, looked at how it works, it does write a recoded history file. https://www.mql5.com/ru/code/8560

 

И вот он, зараза, несмотря на то, что должен торговать только одной позицией (есть - ищем условия на продажу, нет - ищем условия на покупку), открывает большое количество позиций, и потом их не закрывает. Я уже голову поломал. Подскажите, что не так?

in CheckBuy add an if opener order greater than zero, then out.

 
splxgf >>:

в CheckBuy добавь иф опен ордерс больше нуля, то выходим.

Yeah, I'll get right on that. Thank you. (chuckles)

But still, why does he buy a lot of positions in the first place? After all, in the beginning he is immediately told that if there is a position - you do not go here, you go there? By idea, he should not even get into this piece of code. Or maybe I don't understand it?

 
Jahspear >>:

Ага, щас добавлю. Спасибо.

Но всё-таки - почему он вообще покупает мого позиций? Ведь вначале ему сразу говорится, что если позиция есть - ты сюда не ходи, ты туда ходи? Он, по задумке, в этот кусок кода даже попадать не должен. Или я что не понимаю?


Although I looked at the code more closely now, it's hard to understand it without a half a litre, I'll send you my email and try to explain what I've done there.
Reason: