[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 298

 
The archive contains two indicators and Expert Advisor I'm working on (test-cifr), indicators are working by themselves, but I can't paste them into Expert Advisor (the only purpose of Expert Advisor is outputting values), please help me understand why they are not and how to paste them.
 
Thank you and good luck to you artmedia70
 
palomnik:
Thank you and good luck to you artmedia70
Right... Health: it's a non-renewable resource. Thank you :)
 
ed3sss:

Hello.

How can I display on the chart the inscription on the current instrument Profit/loss of open orders.

It is difficult to check in the Expert Advisor whether it has opened positions or not (terminal on/off) and to pick up the last lot volume before closing the terminal.

Thank you.


Hello, no one in the know?
 

If I've made any past trades, then use the orderprofit function and then summarise the entire history of the trades.

I wonder if anyone has any answers to my question.

 
artmedia70:

There is one flaw in that code. Here, taken out of context:


The whole point is that the expression

Therefore, the lot value will be rounded to one decimal place.


Read on, it may help.



I certainly hope so. Thank you. I will read through the above thread to reinforce this point. Don't want to leave any gaps.
 
ed3sss:

Hello, is there anyone knowledgeable?


Well, as I understand it all is elementary. All you need is elementary knowledge.

1. You do an overshoot of the orders.

2. Check the order is open, i.e. the order closing time relative to zero.

3. If the order is open, display its data needed, profit, type, etc..

 
palomnik:

If I've made any past trades, then use the orderprofit function and then sum up all the history of the trades.

I wonder if anyone has answers to my question.

Copy the entire code into your Expert Advisor

like this

//+------------------------------------------------------------------+
//|                                                        Xrust.mq4 |
//|                        Copyright 2013, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"


extern int    TimeFrame=0;//Если=0, то текуший
extern string FrApNam="Ap";//Имя линии соотв.Фракталу вверх
extern string FrDnNam="Dn";//Имя линии соотв.Фракталу вниз
extern color  ClAp=Blue;//Цвет линии соотв.Фракталу вверх
extern color  ClDn=Red;//Цвет линии соотв.Фракталу вниз
//-----------------------------------------------------------------------------+
double FrApPrise,FrDnPrise;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
  if(TimeFrame==0){TimeFrame=Period();}
  IndicatorShortName("Factal_Level_Xrust"+TimeFrame);
  FrApNam=StringConcatenate(FrApNam,TimeFrame);
  FrDnNam=StringConcatenate(FrDnNam,TimeFrame); 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
  ObjectDelete(FrDnNam);
  ObjectDelete(FrApNam);
  Comment(" ");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
   LineAp();
   LineDn();
   
   int diap=MathRound((FrApPrise-FrDnPrise)/Point);
   
   Comment("\n"," LineDn  = ",FrDnPrise,
           "\n", " LineAp  = ",FrApPrise,
           "\n"," diap  = ",diap );

//----
   return(0);
  }
//+------------------------------------------------------------------+
//-----------------------------------------------------------------------------+
// Ищет горизонтальную линию по имени перерисовывает если изменилась цена      |   
//-----------------------------------------------------------------------------+
   void  LineDn(){
   FrDnPrise=0;
   double  FrPrise=NormalizeDouble(FindNearFractal(0,TimeFrame,MODE_LOWER),MarketInfo(Symbol(),MODE_DIGITS));
   FrPrise=NormalizeDouble(FrPrise,MarketInfo(Symbol(),MODE_DIGITS));
   //Comment(FrPrise);
   if(ObjectFind(FrDnNam)==0){
     if(ObjectGet(FrDnNam,OBJPROP_PRICE1)==FrPrise){return;}}
   FrDnPrise=FrPrise;  
   ObjectDelete(FrDnNam);
   SetHLine(ClDn,FrDnNam,FrDnPrise,0,1);
   WindowRedraw();
   return;} 
//-----------------------------------------------------------------------------+
// Ищет горизонтальную линию по имени перерисовывает если изменилась цена      | 
//-----------------------------------------------------------------------------+
   void  LineAp(){
   FrApPrise=0;
   double FrPrise=NormalizeDouble(FindNearFractal(0,TimeFrame,MODE_UPPER),MarketInfo(Symbol(),MODE_DIGITS));
   FrPrise=NormalizeDouble(FrPrise,MarketInfo(Symbol(),MODE_DIGITS));
   if(ObjectFind(FrApNam)==0){
     if(ObjectGet(FrApNam,OBJPROP_PRICE1)==FrPrise){return;}}
   FrApPrise=FrPrise; 
   ObjectDelete(FrApNam); 
   SetHLine(ClAp,FrApNam,FrApPrise,0,1);
   WindowRedraw();
   return;}
//-----------------------------------------------------------------------------+   
//   Киму Респект и уважуха !!!                                                |       
//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 07.10.2006                                                     |
//|  Описание : Поиск ближайшего фрактала. Возвращает ценовой уровень.         |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    sy   - наименование инструмента      ("" или NULL - текущий символ)     |
//|    tf   - таймфрейм                     (    0       - текущий ТФ)         |
//|    mode - тип фрактала                  (MODE_LOWER|MODE_UPPER)            |
//+----------------------------------------------------------------------------+
double FindNearFractal(string sy="0", int tf=0, int mode=MODE_LOWER) {
  if (sy=="" || sy=="0") sy=Symbol();
  double f=0;
  int    d=MarketInfo(sy, MODE_DIGITS), s;
  if (d==0) if (StringFind(sy, "JPY")<0) d=4; else d=2;

  for (s=2; s<100; s++) {
    f=iFractals(sy, tf, mode, s);
    if (f!=0) return(NormalizeDouble(f, d));
  }
  Print("FindNearFractal(): Фрактал не найден");
  return(0);
}
//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 30.03.2008                                                     |
//|  Описание : Установка объекта OBJ_HLINE горизонтальная линия               |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    cl - цвет линии                                                         |
//|    nm - наименование               ("" - время открытия текущего бара)     |
//|    p1 - ценовой уровень            (0  - Bid)                              |
//|    st - стиль линии                (0  - простая линия)                    |
//|    wd - ширина линии               (0  - по умолчанию)                     |
//+----------------------------------------------------------------------------+
void SetHLine(color cl, string nm="", double p1=0, int st=0, int wd=1) {
  if (nm=="") nm=DoubleToStr(Time[0], 0);
  if (p1<=0) p1=Bid;
  if (ObjectFind(nm)<0) ObjectCreate(nm, OBJ_HLINE, 0, 0,0);
  ObjectSet(nm, OBJPROP_PRICE1, p1);
  ObjectSet(nm, OBJPROP_COLOR , cl);
  ObjectSet(nm, OBJPROP_STYLE , st);
  ObjectSet(nm, OBJPROP_WIDTH , wd);
}

or

or use functions

int ObjectFind( string name) //Поиск объекта с указанным именем

double ObjectGet( string name, int prop_id) //Функция возвращает значение указанного свойства объекта

to look for an object. There is no other way.
 
No, it's inserted, but the value is completely off the charts.
 
palomnik:
No, it works, but the value comes out absolutely from the ceiling


Try to remove indicator settings in the EA code. Then the settings will be taken from the code prescribed in the indicator.

I also got left values, I removed the settings from the code and it's OK.

Reason: