Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 908

 
sashasonik:

Got it! That's it. Thanks.

int bar1=iBarShift(Symbol(),PERIOD_M1,iTime(Symbol(),PERIOD_D1,0));//Print(bar1); //first bar
int MaxVol=0;
int i=0, n=0;
for (i=bar1; i>0; i--)
{
//if (i<bar);
//if (TimeMinute(Time[i])!=Minute()) break;
if (iVolume(Symbol(),0,i)>MaxVol)
{
MaxVol=iVolume(Symbol(),0,i);
n=i;
}
//Print(MaxVol," MaxVol ", n, " n");
}
datetime MaxVolT = iTime(NULL, PERIOD_M1, n);

Well, here we have it.

Now you can think about reducing and simplifying the code.

Here you have found the first bar. This means that we will have to copy so many bars into the array. This reduces the code to three strings.

1. Find the first bar.

2. copy the volumes of the first example into the array

int  CopyTickVolume(
   string           symbol_name,      // имя символа
   ENUM_TIMEFRAMES  timeframe,        // период
   int              start_pos,        // откуда начнем (с нулевого или первого)
   int              count,            // сколько копируем(первым пунктом определили)
   long             volume_array[]    // массив для копирования тиковых объемов(предварительно объявляем массив глобального уровня или локального)
   );

3. ArrayMaximum(from this array)


It's not clear why you're using the n variable

 

Downloaded the archive of quotes. Here is an example of one entry:
4071656556,D,EUR/USD,2015-05-31 17:00:02.803000000,1.098020,1.098120
The field headings are as follows: lTid,cDealable,CurrencyPair,RateDateTime,RateBid,RateAsk
What do the first 2 fields mean?

 
PostoronnimV:

Downloaded the archive of quotes. Here is an example of one entry:
4071656556,D,EUR/USD,2015-05-31 17:00:02.803000000,1.098020,1.098120
The field headings are as follows: lTid,cDealable,CurrencyPair,RateDateTime,RateBid,RateAsk
What do the first 2 fields mean?

The first three columns can be safely discarded, they have no practical application for creating quotes for MT4.
 

Hello!

I use many blocks in Expert Advisor, each block has the same indicator. Can I declare this indicator once in OnTick() and then in each block I don't have to declare it again?

 
abeiks:

Hello!

I use many blocks in Expert Advisor, each block has the same indicator. Can I declare this indicator once in OnTick() and then in each block I don't have to declare it again?

You can do it
 
How? Please show me an example.
void OnTick()
{
double MA_High = iMA(NULL, 0, 9, 1, MODE_EMA, PRICE_LOW, cnt);
}

int exampl()
{
a = MA_High;
}

int exampl1()
{
a = MA_High;
}
 
abeiks:
How? Please show me an example.
Read the manual about the visibility of variables declared at different code levels.
double MA_High=0; 
void OnTick()
{
double  MA_High = iMA(NULL, 0, 9, 1, MODE_EMA, PRICE_LOW, cnt);
}

int exampl()
{
a = MA_High;
}

int exampl1()
{
a = MA_High;
}
 
evillive:
Read the manual about the visibility of variables declared at different code levels.
Thank you!
 

Hello,

Could you please tell me why there are warnings - implicit conversion from 'string' to 'number' and implicit conversion from 'number' to 'string' in variable locations (after int command and then after message). It must be one and the same warning? I am not good at programming.

Also, tell me more, if the code works but there are warnings only, is it bad?

And one more question, how do I get local time in the message? I write message= TimeLocal()+..... and nothing happens...


Code snippet:

if(last_sell_1_price==0 || TimeCurrent()-last_sell_1_price>alarm_limit_notification*60)
                 {
                  Print("");
                  if(Session_Check())
                    {
            
//сооб sell

                     int sell1 = DoubleToStr( (Bid - Price_Line)/Point,0);
                     int sell2=DoubleToStr( (Bid - Price_Line2)/Point,0);
                     int rsi=DoubleToStr(ExtRSIBuffer[0] - Price_RSI_Line, 2);
                                  
                     message=
                     TimeCurrent()+"  (Level)"+"   \n"+
                     "\n"+
                     Symbol()+"  TF:"+TF_in_String()+"   \n"+
                     "Price: "+DoubleToStr(Bid,4)+"   \n"+
                     "sell_1: "+(sell1>0?"+":"")+sell1+"   \n"+
                     "sell_2: "+(sell2>0?"+":"")+sell2+"   \n"+
                     "RSI:  "+(rsi>0?"+":"")+rsi;
  
                     SendNotification(message);
                     Print(message);
                     if(mail_message==on)
                     SendMail(Symbol(),message);

                    }
                  last_sell_1_price=TimeCurrent();
                 }
              }
 
halk2009:

Hello,

Could you please tell me why there appear warnings - implicit conversion from 'string' to 'number' and implicit conversion from 'number' to 'string' in variable locations (after the int command and then after the message). It must be one and the same warning? I am poorly versed in programming.

And tell me more, is it bad if the code works but there are only warnings?


Code fragment:

And read the difference between a string and an interleaver. You should probably declare the variables as string type if they are to be output.

string  sell1 = DoubleToStr( (Bid - Price_Line)/Point,0);
string  sell2=DoubleToStr( (Bid - Price_Line2)/Point,0);
string  rsi=DoubleToStr(ExtRSIBuffer[0] - Price_RSI_Line, 2);