datetime TL_TimeLow2=(datetime)ObjectGet("TL_Support",OBJPROP_TIME2);// устанавливаем вторую координату времени линии поддержкиdatetime TL_TimeLow1=(datetime)ObjectGet("TL_Support",OBJPROP_TIME1); // устанавливаем первую координату времени линии поддержкиdatetime TL_Time1=(datetime)ObjectGet("TL_Buy",OBJPROP_TIME1); // устанавливаем первую координату времени линии Buydatetime TL_Time2=(datetime)ObjectGet("TL_Buy",OBJPROP_TIME2); // устанавливаем вторую координату времени линии Buy
Yes, thanks, I have already figured it out myself, but my Expert Advisor still does not open orders when Line_Buy and Line_Sell are crossed. I have already checked everything, but orders are opened and closed not at the moment of crossing, maybe someone will tell me
//+------------------------------------------------------------------+//| фрактал.mq4 |//| Copyright 2014, MetaQuotes Software Corp. |//| http://www.mql5.com |//+------------------------------------------------------------------+#property copyright"Copyright 2014, MetaQuotes Software Corp."#property link"http://www.mql5.com"#property version"1.00"#property strictinputcolor Resistance_Color=Red;
inputENUM_LINE_STYLE Resistance_Style;
inputint Resistance_Width=1;
inputcolor Support_Color=Red;
inputENUM_LINE_STYLE Support_Style;
inputint Support_Width=1;
externdouble Lots = 0.1;
externint TakeProfit = 50;
externint StopLoss = 50;
externint ProfitSeriya = 5;
externint Profit = 5;
//extern int Step = 50;externint filtr =4;
externint slippage = 5;
double TP,price,lastlot,Pr,SL;
int ticket,Magic=123,op;
string TL_Support;
//+------------------------------------------------------------------+//| Expert initialization function |//+------------------------------------------------------------------+intOnInit()
{
//---return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+//| Expert deinitialization function |//+------------------------------------------------------------------+voidOnDeinit(constint reason)
{
ObjectDelete(0,"TL_Resistance"); //удаляем линию сопротевления на текущем графикеObjectDelete(0,"TL_Support"); //удаляем линию поддержки на текущем графикеObjectDelete(0,"TL_Buy"); //удаляем линию поддержки на текущем графикеObjectDelete(0,"TL_Sell"); //удаляем линию поддержки на текущем графике
}
//+------------------------------------------------------------------+//| Expert tick function |//+------------------------------------------------------------------+voidOnTick()
{
//---объявление переменныхint n,UpperFractal_1=0,UpperFractal_2=0,LowerFractal_1=0,LowerFractal_2=0;
double UpperPrice_1=0,UpperPrice_2=0,LowerPrice_1=0,LowerPrice_2=0,low_1,high_1 ,Line_Buy=0,Line_Sell=0;
low_1=iLow(Symbol(),PERIOD_CURRENT,1);
high_1=iHigh(Symbol(),PERIOD_CURRENT,1);
//--- находим индекс бара первого ближайшего верхнего фракталаfor(n=0; n<(Bars-1);n++)
{
if(iFractals(Symbol(),PERIOD_CURRENT,MODE_UPPER,n)!=NULL)
break;
UpperFractal_1=n+1;
UpperPrice_1=iHigh(Symbol(),PERIOD_CURRENT,UpperFractal_1);
}
//--- находим индекс бара второго ближайшего верхнего фракталаfor(n=UpperFractal_1+1; n<(Bars-1);n++)
{
if(iFractals(Symbol(),PERIOD_CURRENT,MODE_UPPER,n)!=NULL)
break;
UpperFractal_2=n+1;
UpperPrice_2=iHigh(Symbol(),PERIOD_CURRENT,UpperFractal_2);
}
//--- находим индекс бара первого ближайшего нижнего фракталаfor(n=0; n<(Bars-1);n++)
{
if(iFractals(Symbol(),PERIOD_CURRENT,MODE_LOWER,n)!=NULL)
break;
LowerFractal_1=n+1;
LowerPrice_1=iLow(Symbol(),PERIOD_CURRENT,LowerFractal_1);
}
//--- находим индекс бара второго ближайшего нижнего фракталаfor(n=LowerFractal_1+1; n<(Bars-1);n++)
{
if(iFractals(Symbol(),PERIOD_CURRENT,MODE_LOWER,n)!=NULL)
break;
LowerFractal_2=n+1;
LowerPrice_2=iLow(Symbol(),PERIOD_CURRENT,LowerFractal_2);
}
//-- Этап 1. Определение временного значения экстремума на таймфрейме: //--- определение времени фракталовdatetime UpFractalTime_1=iTime(Symbol(),PERIOD_CURRENT,UpperFractal_1);
datetime UpFractalTime_2=iTime(Symbol(),PERIOD_CURRENT,UpperFractal_2);
datetime LowFractalTime_1=iTime(Symbol(),PERIOD_CURRENT,LowerFractal_1);
datetime LowFractalTime_2=iTime(Symbol(),PERIOD_CURRENT,LowerFractal_2);
datetime time=iTime(Symbol(),PERIOD_CURRENT,0);
datetime time_1=iTime(Symbol(),PERIOD_CURRENT,1);
datetime time_2=iTime(Symbol(),PERIOD_CURRENT,2);
//--- создание линии поддержки// ObjectCreate(0,"TL_Support",OBJ_TREND,0,LowFractalTime_2,LowerPrice_2,// LowFractalTime_1,LowerPrice_1);ObjectCreate(0,"TL_Buy",OBJ_TREND,0,LowFractalTime_2,LowerPrice_2,
time_1,high_1);
//--- цвета линии поддержки
ObjectSet("TL_Buy",OBJPROP_COLOR,clrYellow);
ObjectSet("TL_Support",OBJPROP_COLOR,Support_Color);
// ObjectSet("TL_Support",OBJPROP_STYLE,Support_Style);// ObjectSet("TL_Support",OBJPROP_WIDTH,Support_Width);//--- создание линии сопротивления// ObjectCreate(0,"TL_Resistance",OBJ_TREND,0,UpFractalTime_2,UpperPrice_2,// UpFractalTime_1,UpperPrice_1);ObjectCreate(0,"TL_Sell",OBJ_TREND,0,UpFractalTime_2,UpperPrice_2,
time_1,low_1);
//--- цвета линии сопротивления
ObjectSet("TL_Sell",OBJPROP_COLOR,clrYellow);
ObjectSet("TL_Resistance",OBJPROP_COLOR,Resistance_Color);
// ObjectSet("TL_Resistance",OBJPROP_STYLE,Resistance_Style);// ObjectSet("TL_Resistance",OBJPROP_WIDTH,Resistance_Width);//--- перерисовка линии поддержки//--- записываем значения временных координат линии поддержки в переменные// string TL_Suppor=(string)TL_Support;datetime TL_TimeLow2=(datetime)ObjectGet("TL_Support",OBJPROP_TIME2);// устанавливаем вторую координату времени линии поддержкиdatetime TL_TimeLow1=(datetime)ObjectGet("TL_Support",OBJPROP_TIME1); // устанавливаем первую координату времени линии поддержкиdatetime TL_Time1=(datetime)ObjectGet("TL_Buy",OBJPROP_TIME1); // устанавливаем первую координату времени линии Buydatetime TL_Time2=(datetime)ObjectGet("TL_Buy",OBJPROP_TIME2); // устанавливаем вторую координату времени линии Buy //---если координаты линии не совпадают с текущимиif(TL_TimeLow2!=LowFractalTime_1 && TL_TimeLow1!=LowFractalTime_2)
/*вторую координату времени линии поддержки не равно второму времени N-точки привязки
и первая координату времени линии поддержки не равно первому времени N-точки привязки*/
{
//---удаляем линиюObjectDelete(0,"TL_Support");
}
if( TL_Time2!=time_1 )
/*вторую координату времени линии поддержки не равно второму времени N-точки привязки*/
{
//---удаляем линиюObjectDelete(0,"TL_Buy");
}
//--- перерисовка линии сопротивления//--- записываем значения временных координат линии сопротивления в переменныеdatetime TL_TimeUp2=(datetime)ObjectGet("TL_Resistance",OBJPROP_TIME2);
datetime TL_TimeUp1=(datetime)ObjectGet("TL_Resistance",OBJPROP_TIME1);
datetime TL_TimeS1=(datetime)ObjectGet("TL_Sell",OBJPROP_TIME1);
datetime TL_TimeS2=(datetime)ObjectGet("TL_Sell",OBJPROP_TIME2);
//--- если координаты линии не совпадают с текущимиif(TL_TimeUp2!=UpFractalTime_1 && TL_TimeUp1!=UpFractalTime_2)
{
//--- удаляем линиюObjectDelete(0,"TL_Resistance");
}
if(TL_TimeS2!=time_1 )
{
//--- удаляем линиюObjectDelete(0,"TL_Sell");
}
//--- контроль загруженности баров в истории//--- если на M15 не найден хотя бы один барif(UpperFractal_1==-1 || UpperFractal_2==-1
|| LowerFractal_1==-1 || LowerFractal_2==-1)
{
Alert("Для корректной работы недостаточно загружена история!");
}
Line_Sell=NormalizeDouble(ObjectGetValueByShift("TL_Sell",0),5);
Line_Buy=NormalizeDouble(ObjectGetValueByShift("TL_Buy",0),5);
Print( "Line_Buy: " + DoubleToStr( Line_Buy,5) + " , Line_Sel: " + DoubleToStr( Line_Sell,5) );
//поверить есть ли открытые ордера Buy. если нет открываем ордер когда цена будет выше линии Buyif(CountBuy()==0 && Line_Buy<Ask)
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,slippage,0,0,"",Magic,0,Blue);
//поверить есть ли открытые ордера Buy. если есть закрываем ордер когда цена будет ниже линии Sell if(CountBuy()==1&& Line_Sell>Bid )
{
for(int i=OrdersTotal()-1; i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS))
{
if(OrderMagicNumber()==Magic && OrderType()==OP_BUY)
bool a=OrderClose(OrderTicket(),OrderLots(),Bid,slippage,Black);
}
}
}
if(CountSell()==0&& Line_Sell>Bid )
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,slippage,0,0,"",Magic,0,Red);
if(CountSell()==1&& Line_Buy<Ask)
{
for(int i=OrdersTotal()-1; i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS))
{
if(OrderMagicNumber()==Magic && OrderType()==OP_SELL)
bool x=OrderClose(OrderTicket(),OrderLots(),Bid,slippage,Black);
}
}
}
}
//+------------------------------------------------------------------+int CountBuy()
{
int count=0;
for(int i= OrdersTotal()-1; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if(OrderType()==OP_BUY)
count++;
}
}
}
return(count);
}
//+------------------------------------------------------------------+//+------------------------------------------------------------------+int CountSell()
{
int count=0;
for(int i= OrdersTotal()-1; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if(OrderType()==OP_SELL)
count++;
}
}
}
return(count);
}
//+------------------------------------------------------------------+
Last night I had an interesting malfunction. On the terminal screen the bars do not coincide with the grid lines.
If I use candlesticks instead of bars, the same thing happens. I am using all timeframes. I uninstalled the terminal, downloaded a new one from my personal cabinet.
- same thing. I called our Alpari consultants, got the terminal already installed, started it - same thing.
same thing. Kaspersky says everything is fine, "no threats". There are 5 periods of bars for 4 grid periods, i.e.
the period of bars equals 0.75 of the grid period. How can this be fixed?
Last night I had an interesting malfunction. On the terminal screen the bars do not coincide with the grid lines.
If I use candlesticks instead of bars, the same thing happens. I am using all timeframes. I uninstalled the terminal, downloaded a new one from my personal cabinet.
- same thing. I called our Alpari consultants, got the terminal already installed, started it - same thing.
same thing. Kaspersky says everything is fine, "no threats". There are 5 periods of bars for 4 grid periods, i.e.
the period of bars equals 0.75 of the grid period. How can this be fixed?
What build of terminal do you have, what OS, bit rate ?
On which symbol and on which server is it playing?
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.
a warning does not indicate an error.
This error is due to a data type mismatch
ObjectGet returns double
and YOU assign a value to
datetime
try this
Dear MQL4 developers!
Last night I had an interesting malfunction. On the terminal screen the bars do not coincide with the grid lines.
If I use candlesticks instead of bars, the same thing happens. I am using all timeframes. I uninstalled the terminal, downloaded a new one from my personal cabinet.
- same thing. I called our Alpari consultants, got the terminal already installed, started it - same thing.
same thing. Kaspersky says everything is fine, "no threats". There are 5 periods of bars for 4 grid periods, i.e.
the period of bars equals 0.75 of the grid period. How can this be fixed?
Dear MQL4 developers!
Last night I had an interesting malfunction. On the terminal screen the bars do not coincide with the grid lines.
If I use candlesticks instead of bars, the same thing happens. I am using all timeframes. I uninstalled the terminal, downloaded a new one from my personal cabinet.
- same thing. I called our Alpari consultants, got the terminal already installed, started it - same thing.
same thing. Kaspersky says everything is fine, "no threats". There are 5 periods of bars for 4 grid periods, i.e.
the period of bars equals 0.75 of the grid period. How can this be fixed?
What build of terminal do you have, what OS, bit rate ?
On which symbol and on which server is it playing?
What are your monitor settings ?
Did you change thegraphics settings?
On linux systems on virtual machines mt4 requires proxy settings, I don't know what to enter there, everything works and is connected via NAT
All other programs work without proxy and go online without problems... What to do ? How to install mt4 ...
On linux systems on virtual machines mt4 requires proxy settings, I don't know what to enter there, everything works and is connected via NAT
All other programs work without proxy and go online without problems... What to do ? How to install mt4 ...
How do you make it possible to insert email (skype) in
#property link
(if just email, the link is inactive when clicked)
How do you make it possible to insert email (skype) in
#property link
(if just mail, the link is inactive when clicked)
Now I've taken it and tried it:
It works ;)
Is bridged available for the network adapter in the virtual machine settings?