Help script tweak that would mean open a deal immediately, at the current market price. A chet, I'm already steamed up Distance from the fish in 5 pips is not satisfied, and so that would be at least with a deflection in the swap.
Index of the value received from the indicator buffer (shift relative to the current bar by the specified number of periods back).
In the Fractals indicator. If I think correctly - the indicator shows the extremum value among five bars with the condition that maxima of two previous and two following bars (in case of a fractal upwards) are smaller (though the "birdie" of a fractal is shown on the chart also when the extremum of the leftmost bar of those five = extremum ......, not smaller than it). So why shift then ? What will be shown if shift is not equal to 3 but equal to 2 or 5 ?
I made this code to enter the market after the first fractal break after MA break. But when tested, it does not open trades everywhere, although it seems to be supposed to do so. I cannot understand what is wrong? In real mode (when checking on M1 I cannot find the error).
externint Period_MA = 5, // Период расчётной МА
PERIOD=1, // Период текущего графика (таймфрейм)
MODE=3, // Метод усреднения из методов скользящего среднего
PRICE_TYPE=0, // Используемая цена из ценовых констант
Прибыль=10,
Ограничение=55;
double
upfractal,
dwfractal,
SL[10001]={0,,10000},
TP[10001]={0,,10000};
bool Двверх=false,
Дввниз=false,
Сделкавверх=false,
Сделкавниз=false;
int A, // Переменная массива вверх
B, // Переменная массива вниз
BarTime, // Время текущего бара
ticketup, // Ордер вверх
ticketdown, // Ордер вниз
Tвверх, // Время сделки вверх
Tвниз; // Время сделки вниз;color вверх = SpringGreen, // Цвет сделки вверх
вниз = Red; // Цвет сделки вниз int start()
{
string Symb=Symbol(); // Финанс. инструментdouble Lot=0.01; // Лотif(BarTime!=Time[0]) // Условие для того, чтобы программа считала только на начале бара, а не на каждом тике
{
double MA_1 = iMA(Symbol(),PERIOD,Period_MA,0,MODE, PRICE_TYPE, 1);
double MA_2 = iMA(Symbol(),PERIOD,Period_MA,0,MODE, PRICE_TYPE, 2);
double MA_3 = iMA(Symbol(),PERIOD,Period_MA,0,MODE, PRICE_TYPE, 3);
double MA_4 = iMA(Symbol(),PERIOD,Period_MA,0,MODE, PRICE_TYPE, 4);
double MA_5 = iMA(Symbol(),PERIOD,Period_MA,0,MODE, PRICE_TYPE, 5);
double MA_6 = iMA(Symbol(),PERIOD,Period_MA,0,MODE, PRICE_TYPE, 6);
double MA_7 = iMA(Symbol(),PERIOD,Period_MA,0,MODE, PRICE_TYPE, 7);
double MA_8 = iMA(Symbol(),PERIOD,Period_MA,0,MODE, PRICE_TYPE, 8);
//--------------------------------------------------------------------if(NormalizeDouble(MA_8,Digits)>NormalizeDouble(MA_2,Digits)
&& NormalizeDouble(MA_7,Digits)>=NormalizeDouble(MA_2,Digits)
&& NormalizeDouble(MA_6,Digits)>=NormalizeDouble(MA_2,Digits)
&& NormalizeDouble(MA_5,Digits)>=NormalizeDouble(MA_2,Digits)
&& NormalizeDouble(MA_3,Digits)>=NormalizeDouble(MA_2,Digits)
&& NormalizeDouble(MA_4,Digits)>=NormalizeDouble(MA_2,Digits)
&& NormalizeDouble(MA_2,Digits)<NormalizeDouble(MA_1,Digits)) // Перелом вверх
{
Двверх=true;
Alert("Двверх");
Дввниз=false;
Сделкавниз=false;
dwfractal=0;
upfractal=0;
}
if(Двверх==true)
{
upfractal=iFractals(Symbol(), PERIOD, MODE_UPPER, 3);
Alert("upfractal вначале = ",upfractal);
}
if(NormalizeDouble(MA_8,Digits)<NormalizeDouble(MA_2,Digits)
&& NormalizeDouble(MA_7,Digits)<=NormalizeDouble(MA_2,Digits)
&& NormalizeDouble(MA_6,Digits)<=NormalizeDouble(MA_2,Digits)
&& NormalizeDouble(MA_5,Digits)<=NormalizeDouble(MA_2,Digits)
&& NormalizeDouble(MA_3,Digits)<=NormalizeDouble(MA_2,Digits)
&& NormalizeDouble(MA_4,Digits)<=NormalizeDouble(MA_2,Digits)
&& NormalizeDouble(MA_2,Digits)>NormalizeDouble(MA_1,Digits)) // Перелом вниз
{
Дввниз=true;
Двверх=false;
Alert("Дввниз");
Сделкавверх=false;
upfractal=0;
dwfractal=0;
}
if(Дввниз==true)
{
dwfractal=iFractals(Symbol(),PERIOD, MODE_LOWER, 3);
Alert("dwfractal вначале = ",dwfractal);
}
BarTime=Time[0];
}else// На каждый тик
{
Alert("upfractal на тиках = ",upfractal,", Bid = ", Bid);
if (Двверх==true && upfractal !=0 && Bid > NormalizeDouble(upfractal+1*Point,Digits) && Tвверх!=Time[0] && Сделкавверх==false) // Открытие ордеров при пробитии последнего (свежайшего) фрактала }
{
Alert("upfractal = ",upfractal, ", Ask = ",Ask);
Tвверх=Time[0];
while(true) // Цикл открытия орд.
{
A++;
SL[A]=Bid-Ограничение*Point;
TP[A]=Bid+7*Point+Прибыль*Point;
ticketup=OrderSend(Symb, OP_BUY, Lot, Ask,0, SL[A], TP[A],NULL,A,0,вверх); // Ордер вверхint Error=GetLastError();
switch(Error) // Преодолимые ошибки
{
case6: Alert("Нет связи с торговым сервером. Пробуем ещё раз..");
RefreshRates(); // Обновим данныеSleep(1); // Задержка в цикле до нового тикаcontinue; // На след. итерацию
}
break; // Выход из цикла
}
Сделкавверх=true;
}
Alert("dwfractal на тиках = ",dwfractal,", Bid = ", Bid);
if (Дввниз==true && dwfractal !=0 && Bid < NormalizeDouble(dwfractal-1*Point,Digits) && Tвниз!=Time[0] && Сделкавниз==false) // Открытие ордеров при пробитии последнего (свежайшего) фрактала }
{
Alert("dwfractal = ",dwfractal, ", Bid = ",Bid);
Tвниз=Time[0];
while(true) // Цикл открытия орд.
{
B++;
SL[B]=Bid+Ограничение*Point;
TP[B]=Bid-4*Point-Прибыль*Point;
ticketdown=OrderSend(Symb, OP_SELL, Lot, Bid,0, SL[B], TP[B],NULL,B,0,вниз); // Ордер вниз
Error=GetLastError();
switch(Error) // Преодолимые ошибки
{
case6: Alert("Нет связи с торговым сервером. Пробуем ещё раз..");
RefreshRates(); // Обновим данныеSleep(1); // Задержка в цикле до нового тикаcontinue; // На след. итерацию
}
break; // Выход из цикла
}
Сделкавниз=true;
}
}
//----return(0);
}
//+------------------------------------------------------------------+
And until it works out in the tester, there's no sense in using it for optimization with an error. What's the error... ?
Leonid82, High[1] is the high price on the first candle. To get it, you just need to make this script. And this price is obtained not from the Expert Advisor, but from the terminal.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Congratulations to YOU !
Congratulations are in order. Although a shot in the air doesn't hurt anyone.
Congratulations are in order. Although a shot in the air doesn't hurt anyone.
Victor, is your Skype down or is your connection dying? What's the ZZ?
Yeah, I'm saying maybe I should make a special zapper. It's not my Skype that's dying. I got you in green.
There is no history or there are errors in the history
Good evening !
I can't seem to make sense of the
In the Fractals indicator. If I think correctly - the indicator shows the extremum value among five bars with the condition that maxima of two previous and two following bars (in case of a fractal upwards) are smaller (though the "birdie" of a fractal is shown on the chart also when the extremum of the leftmost bar of those five = extremum ......, not smaller than it). So why shift then ? What will be shown if shift is not equal to 3 but equal to 2 or 5 ?
I made this code to enter the market after the first fractal break after MA break. But when tested, it does not open trades everywhere, although it seems to be supposed to do so. I cannot understand what is wrong? In real mode (when checking on M1 I cannot find the error).
And until it works out in the tester, there's no sense in using it for optimization with an error. What's the error... ?Leonid82 24.01.2011 19:51
Hi, I have an Expert Advisor which works with EURUSD. How can I get High[1] on GBPUSD for example?
Thank you for your help.
Leonid82, High[1] is the high price on the first candle. To get it, you just need to make this script. And this price is obtained not from the Expert Advisor, but from the terminal.