Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 741

 
psyman:

For the next code, a story in pictures:


Disconnected the network, adding an indicator

Switched to the next chart


y2 changed value, I go back


y2 has returned its value, but the marker is counted by the "gone" value! I spin the mouse wheel.

The marker is back in its place!

When switching to the adjacent graph, all inactive windows are not expanded to full screen. That is, they are smaller than in the active state. Therefore, objects get smaller coordinates from the upper left corner of the graph. Then, when you activate the window, you need to wait for the chart to be refreshed or refresh it forcibly. This is done by scrolling the scroll wheel.

 
psyman:

For the next code, a story in pictures:


Disconnected the network, adding an indicator

I switch to the next chart


y2 changed value, I go back


y2 has returned its value, but the marker is counted by the "gone" value! I spin the mouse wheel.

The marker is back in its place!

you can discardChartTimePriceToXY
and
print plain text(OBJ_TEXT) + 1-3 bars into the future, it will always be where you need it)

 
Taras Slobodyanik:

you can discardChartTimePriceToXY
and
print plain text(OBJ_TEXT) + 1-3 bars into the future, it will always be where you want it)

Only if you disable bar shift to the right, the text will be outside the window.

The idea is correct, but apparently experience is very lacking.

 
Alexey Viktorov:

Only if you disable bar shift to the right, the text will be outside the window.

It's a good idea, but you're probably very inexperienced.

Well, if you want the marker to be right-side up, you can just take the rightmost bar on the chart and draw on it.

 

Good afternoon .
Can you suggest how to create global type variables in EA, that these data are not cleared when calling new functions?

Call the variable data through :

bool  GlobalVariableGet( string  "name", double "var"  ); // К примеру

Where then "var" can be inserted in operations.

And they are created with the function :

datetime  GlobalVariableSet( 
   string  name,      // имя 
   double  value      // устанавлимое значение 
   );

I'm just trying to understand everything. There are no examples and I am not quite sure how data will work if one isdatetime and the other isbool? No errors?

 
psyman:

For the next code, a story in pictures:

Disconnected the network, adding an indicator

Switched to the next chart

y2 changed value, I go back

y2 has returned its value, but the marker is counted by the "gone" value! I spin the mouse wheel.

The marker is back in its place!

//+------------------------------------------------------------------+
//|                                              !_clr_indicator.mq5 |
//|                        Copyright 2018, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window
#property indicator_plots 0

string objname="Bid";
input color Bid_color = clrCrimson;

//+------------------------------------------------------------------+
int OnInit()
  {
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
void OnDeinit(const int reason) 
   { 
   ObjectDelete(0,objname);
   } 
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
{
   SetTXT();
   return(rates_total);
}

//+------------------------------------------------------------------+
void OnChartEvent(const int id,const long &lparam,const double &dparam,const string &sparam) 
{ 
   if(id==CHARTEVENT_CHART_CHANGE) 
      SetTXT();
}

//+------------------------------------------------------------------+
void SetTXT() 
{
int      first_bar=(int)ChartGetInteger(0,CHART_FIRST_VISIBLE_BAR,0);
int      width_bar=(int)ChartGetInteger(0,CHART_WIDTH_IN_BARS,0);
double   label_price=iClose(_Symbol,_Period,0);
datetime label_time=0;

   if(width_bar>first_bar)
      label_time=iTime(_Symbol,_Period,1)+(width_bar-first_bar)*PeriodSeconds();
   else
      label_time=iTime(_Symbol,_Period,first_bar-width_bar+1);

   if(ObjectFind(0,objname)<0)
      {
      ObjectCreate(0, objname, OBJ_TEXT,0,0,0);
      ObjectSetInteger(0, objname, OBJPROP_FONTSIZE, 12);
      ObjectSetInteger(0, objname, OBJPROP_COLOR, Bid_color);
      ObjectSetString(0, objname, OBJPROP_FONT, "Verdana");
      ObjectSetInteger(0,objname,OBJPROP_ANCHOR,ANCHOR_RIGHT_UPPER);
      ObjectSetInteger(0,objname,OBJPROP_BACK,false);
      ObjectSetInteger(0,objname,OBJPROP_SELECTABLE,false);
      }
   
   ObjectSetString(0,objname,OBJPROP_TEXT,DoubleToString(label_price, _Digits-1)); 
   ObjectMove(0,objname,0,label_time,label_price);
   
   ChartRedraw();
}
 
Taras Slobodyanik:


Thank you very much, tomorrow I will think of a way to replace iTime and iClose, as I'm sitting on XP.

 
Good day to you all!
Question for programmers .
Please advise!
Some brokers do not allow me to open an order with a take profit price and stop loss price.

Just one function OrderSend().

Rather, the OrderSend() will open an order, but the stop and profit price will be absent in this order.

This order must be modified on subsequent lines of code using OrderModify() and add stop and profit to the order.


So the question is, who and how handles or insures a case in the function of buying or selling
when, for example, OrderSend() worked but OrderModify() didn't work for some reason and the
there is an open order without a stop or profit?

How would I insure against such an event and/or how would I handle it?
Please advise.
If you do not know how to use Astrakhan, please do not use Astrakhan's code.

time, but I can't find any information on it.

I believe the Breakeven function has a certain insurance, but only if the price has gone in the red.

If the price turned to the loss, but there is no stop loss?

I am very grateful for your reply!
 

Hi all!

Can you please tell me why I can't enter its properties when the EA is working? I used to, but now I can't open the properties. Once restarting the terminal helped, but the problem appeared again after a minute. Expert Advisor is fresh, terminal is also working recently. What is the problem with EA properties ?

Thank you !

 
demonRDV:

Hi all!

Can you please tell me why I can't enter its properties when the EA is working? I used to, but now I can't open the properties. Once restarting the terminal helped, but the problem appeared again after a minute. Expert Advisor is fresh, terminal is also working recently. What is the problem with EA properties ?

Thank you!

Press hotkey F7 :-)

clicking on the EA's icon is not always possible - the icon might be covered by other objects, the EA might overload the message queue and 100500 other reasons

Reason: