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

 
Artyom Trishkin:

Before OrderModify(), print the values of the opening price and the new stop price.

And keep your disrespectful "no?" to yourself if you want help. However, I have posted a fully working template for any trawl right in this thread - you can look it up.

disrespectful "didn't?" - sorry, didn't put anything into it.

 
        if((fMarketOrderss(OP_SELL)>=1)) { 
       if( ((Bid-Opens)/ma+Times/1440) > SELL ) {
if(OrderSend(Symbol(),OP_SELL,0.01,Bid,3,0,0,NULL,321,0,1)>0){} }}

Please advise! What function should be added to replace SELL with numbers that go in order. If there is an open deal then put 1. As soon as this deal is opened it will give 2 and so on. If there are no deals then this number will be reset.

 
Artyom Trishkin:

Before OrderModify(), print the values of the opening price and the new stop price.

It prints the same values. Why does it check for != then, can you tell me?

 
Andrey Sokolov:

Writes the same values. Why does it check for != then, can you tell me?

Read about comparing real numbers.

 
Artyom Trishkin:

Read about comparing real numbers.

Off to read. Thanks
 
Andrey Sokolov:
I'm off to read. Thanks

Don't just compare, but check for "isn't it time to move?", i.e. isn't it less than necessary "n>=p"

 
Vitaly Muzichenko:

Don't just compare, but check for "isn't it time to move?", i.e. isn't "n>=p" less than necessary

Thanks
 
Hello, I have a Color levels indicator, I have a problem when I try to apply 2 parts of this indicator to one chart, namely the window of the 1st indicator disappears and only the window of the 2nd indicator is displayed, and when I click to create an object - rectangle, 2 objects are created, one from one indicator and another from another one. Please advise how to fix it, so that several parts of this indicator can be used in the chart, and objects can be created correctly? Can I change something in the code or vice versa?Example
Files:
 

Assembled the indicator as best I could
Need help to highlight bars, for example a rectangle, when indexes are in +/- 0.4% zone
Or at least the code itself
My indicator code

//+------------------------------------------------------------------+
//|                           Copyright © 2018, forex-time@mail.ru   |
//|                        Copyright © 2018, mr.aliaksei@yandex.ru   |
//|                                         % Алексея Королькова.mq4 |
//+------------------------------------------------------------------+
#property copyright   "Copyright © 2018, forex-time@mail.ru"
#property copyright   "Copyright © 2018, mr.aliaksei@yandex.ru"
#property link        "http://axe44.opentraders.ru/bio/"
#property version     "1.10"
#property strict 
//+------------------------------------------------------------------+
//--- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 3
#property  indicator_color1  LimeGreen
#property  indicator_color2  Red
#property  indicator_color3  Blue
#property  indicator_width1  2
#property  indicator_width2  2
#property  indicator_width3  2
#property  indicator_level1  0.0
#property  indicator_levelcolor DarkGray
//--- indicator parameters
input int InpFastEMA=14;   // Fast EMA Period
input int Metod     =1;   // Metod EMA Period 0-3
input string Pereferics="";// Переферикс после названия основной пары. Например EURUSD.m где переферикс .m
//--- indicator buffers
double Buffer1[];
double Buffer2[];
double Buffer3[];
//--- right input parameters flag
bool   ExtParameters=false;
string IndName= "% A.K ("+IntegerToString(InpFastEMA)+")";
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
  {
   IndicatorDigits(Digits+1);
//--- drawing settings
   SetIndexBuffer(0,Buffer1);SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(1,Buffer2);SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(2,Buffer3);SetIndexStyle(2,DRAW_LINE);

//--- name for DataWindow and indicator subwindow label
   IndicatorShortName(IndName);
//--- check for input parameters
   if(InpFastEMA<=1  )
     {
      Print("Wrong input parameters");
      ExtParameters=false;
      return(INIT_FAILED);
     }
   else
      ExtParameters=true;
//--- initialization done
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Moving Averages Convergence/Divergence                           |
//+------------------------------------------------------------------+
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[])
  {
    int i = rates_total-prev_calculated-1;

    while(i >= 0)  
      {
      double eurusd=(((iMA("EURUSD"+Pereferics,0,InpFastEMA,0,Metod,0,i)+1)/(iMA("EURUSD"+Pereferics,0,InpFastEMA,0,Metod,1,i)+1))-1)*10000;
      double eurjpy=(((iMA("EURJPY"+Pereferics,0,InpFastEMA,0,Metod,0,i)+1)/(iMA("EURJPY"+Pereferics,0,InpFastEMA,0,Metod,1,i)+1))-1)*10000;
      double usdjpy=(((iMA("USDJPY"+Pereferics,0,InpFastEMA,0,Metod,0,i)+1)/(iMA("USDJPY"+Pereferics,0,InpFastEMA,0,Metod,1,i)+1))-1)*10000;
      double eur=(eurusd+eurjpy)/2;
      double usd=(-eurusd+usdjpy)/2;
      double jpy=-(usdjpy+eurjpy)/2;
      Buffer1[i]=ND(eur,1);
      Buffer2[i]=ND(usd,1);
      Buffer3[i]=ND(jpy,1);

      Pair(IndName+"EUR","EUR",54,indicator_color1);
      Pair(IndName+"USD","USD",28,indicator_color2);
      Pair(IndName+"JPY","JPY",5,Blue);
                  
      i--;}
return(rates_total);}
//+------------------------------------------------------------------+
//|ND - нормализация числа                                           |
//-------------------------------------------------------------------+
double ND(double value, int digits) {  
      return(NormalizeDouble(value, digits));}  
//+------------------------------------------------------------------+
void Pair(string name,string txt, int shift, color col){
      int window=WindowFind(IndName);
      //если окно не найдено - "текстовые метки" будут созданы в окне графика
      if(window<0) window=0;
       ObjectCreate(name,OBJ_LABEL,window,0,0,0,0,0,0);
          ObjectSet(name,OBJPROP_CORNER,0);
          ObjectSet(name,OBJPROP_XDISTANCE,shift);
          ObjectSet(name,OBJPROP_YDISTANCE,2);
          ObjectSet(name,OBJPROP_CORNER,CORNER_RIGHT_UPPER);
      ObjectSetText(name,txt,8,"Arial",col);}
//+------------------------------------------------------------------+

The code was recommended to me, but I don't know how to attach it:

ObjectCreate(VLINE, OBJ_VLINE, 0, 0, 0);
ObjectSet(VLINE, OBJPROP_COLOR, VLINE_COLOR);
ObjectSet(VLINE, OBJPROP_STYLE, VLINE_STYLE);

ObjectDelete(VLINE);

if(Bf<0.4 && Bf>(-0.4))
ObjectSet(VLINE, VLINE, VLINE);

Thank you in advance.

 
Is it possible instead of
High/Low>1.02 do
High>Low*1.02
Which option is better for the indicator
Reason: