Features of the mql5 language, subtleties and tricks - page 230

 
IuriiPrugov #:

today for some reason if begDayTime=2023.01.26 00:00:00 returns -1though there are such bars and they are not the last ones

Provide all data for playback.
 
fxsaber #:
Provide all data for playback.

begDayTime=iTime(Symbol(),Inp_period,bar);begDayBar=iBarShift(_Symbol,_Period,begDayTime,false)-1;

Inp_period = M15

2023.02.19 13:02:42.517 !indDAY_WSOWROhLine (EURRUB_TOM,M15) bar=14 begDayTime=2023.01.30 00:00:00 endDayTime=2023.01.31 00:00:00 begDayBar=-2 endDayBar=673 indATR=0 Q5days=0
if you insert

if (begDayBar<0) { k=0; do {k++;} while(begDayTime<time[k] && !IsStopped()); begDayBar=k; }

then everything is OK (i.e. fix iBarShift when it fails)

 
IuriiPrugov #:

It's not data.

 
fxsaber #:

It's not data.

what other data? Inp_period = D1 is searched for 15 days in a cycle! begDayTime= bar= bar =14

begDayTime=iTime(Symbol(),Inp_period,bar); _Symbol= EURRUB_TOM; _Period= M15; after that

iBarShift(_Symbol,_Period,begDayTime,false) can produce a normal bar or -1 or it does not have time to count bars or something.

in general, it works unstably if you switch the indicator (just press another period on the "chart period" panel), for example, on M30 it may produce a normal bar or -1.

same thing on another instrument if not inserted if (begDayBar<0) { k=0; do {k++;} while(begDayTime<time[k] && !IsStopped()); begDayBar=k; } then an error will pop up

2023.02.20 07:58:01.698 !indDAY_WSOWROhLine (CNYRUB_TOM,M15) array out of range in '!indDAY_WSOWROhLine.mq5' (202,148)

and so on after one or two times. You can try it yourself.

Insert this piece into the simplest indicator and switch to a different period on the "chart period" panel.

 
IuriiPrugov #:

and what other data?

Full source code and environment data for reproduction. I.e. anyone could reproduce the problem in one minute after reading it.
 

ok

new to MQL4 and now MQL5.

just trying to get my mind around things.  I used to be a programmer in Visual C/C++ so know HOW to code.

but i'm unfamilar with the libraries and such here.  well the language .  

my first question is if i load a template and it produces a chart in Oanda, how do i set up to code and such?

I want to use my paper trading account and develop code to test out some trading strategies.

now i don't want to re-invent the wheel, so, if i can get a few snippets of code that does "standard" stuff like

-get the account and server/database connections

-set up a project

-run maybe a pre-existing code first then practice making mods and "compiling" it if that is how it works or run a build of my project

I plan to be active in this community once i get my bearings so so glad to find this.  i'm tired of trying to manually trade

oh can i use this to trade crypto?

apologies if i did not prepare better - just did this comment after looking around a little - just joined today.

thx!

RayRay

RR

 
@rrb1002 #: new to MQL4 and now MQL5.... 

You have Articles which describe how to do things in more detail.

You have the CodeBase with examples of code written by users ranging from absolute beginners to highly skilled developers.

And you have the online version of the Documentation (also available in MetaEditor).

rrb1002 #: oh can i use this to trade crypto?

You can trade whatever it is that your broker offers, and that includes cryptos.

 
ok i'm confused here.  i'm new.  I thought it as MQL4 language.  Is the newer upcoming language MQL5?  Will MQL4 be upward compatible to MQL5 and hopefully and just extend the MQL4 language?
 
@rrb1002 #: ok i'm confused here.  i'm new.  I thought it as MQL4 language.  Is the newer upcoming language MQL5?  Will MQL4 be upward compatible to MQL5 and hopefully and just extend the MQL4 language?

MQL5 has been around for more than a decade. It is not "new". It is mature.

MetaTrader 4 and MQL4 has not been further developed for several years now (probably 6-8 years, I think) . Only critical updates are carried out sporadically.

The languages are very similar and a lot of the functionality is somewhat compatible, but the trading functionality is completely different and not at all compatible.

 

sorry for the beginner questions ... so, which one should i focus on to develop code? 4 or 5?  maybe not understanding - should i just pick 5 for the trading functionality?  is it better than MQL4s?

Reason: