You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Anyone who likes my solution, write to me in person. I will refine it and give it away.
Good luck to everyone.
A symbol cycle, checking for a new bar opening when a quote arrives and so on can easily be added to my solution. And what does OOP have to do with it?
You have chosen a wrong example. Think about something else at your leisure.
And you do it. Given that characters can change - after all, it is true when reading characters.
Do it. Given that characters can change - because when you read the characters is true.
Well, what if I do? What do you say then? I'll tell you a secret: for me, this kind of task is a total child's play. Do you really think I can't do it? That's just naive...
Well, what if I do? What do you say then? I'll tell you a secret: for me, this kind of task is a total child's play. Do you really think I can't do it? That's just naive...
Well, do it already.
Artyom didn't answer the question, but the question is this: write in procedural style, so that it works correctly
No question. Hedge to save comparison of string operations, well, if customer is a maniac and will trade on all symbols simultaneously.
But it seems there is nowhere else to save operations and memory - everything is minimal
void OnTimer(){
Alert(Fn_new_bar("EURUSD", PERIOD_D1)); }
//+------------------------------------------------------------------+
uint Sp_Adler32(string line){
ulong s1 = 1;
ulong s2 = 0;
uint buflength=StringLen(line);
uchar char_array[];
ArrayResize(char_array, buflength,0);
StringToCharArray(line, char_array, 0, -1, CP_ACP);
for (uint n=0; n<buflength; n++){
s1 = (s1 + char_array[n]) % 65521;
s2 = (s2 + s1) % 65521;}
return ((s2 << 16) + s1);}
//+------------------------------------------------------------------+
bool Fn_new_bar(string symb, ENUM_TIMEFRAMES tf){
static datetime st_time[];
static uint st_id[];
//---- set
datetime new_time = iTime(symb, tf, 0); if(new_time==0) return(false);
uint new_id = Sp_Adler32(StringConcatenate(symb,EnumToString(tf)));
datetime old_time = 0;
uint old_id = 0;
//---- find
int size = ArraySize(st_time);
for(int i=0; i<size; i++){
if(st_id[i]!=new_id) continue;
old_id = st_id [i];
old_time = st_time[i];
break;}
//----add new element
if(old_time==0){
ArrayResize(st_time, size+1); st_time[size]=new_time;
ArrayResize(st_id, size+1); st_id [size]=new_id; }
//----
return(old_time>0 && old_time<new_time);}
I apologise for the slight delay.
Here is the first version of the function. You can refine and develop it further. If you notice an error, please give your comments.
The point is not in OOP but in the fact that your code is linear, though you will probably never learn it...
No problem. Hedge to save comparison of string operations, well, if the customer is a maniac and will trade on all characters simultaneously.
But it seems there is nowhere else to save operations and memory - everything is minimum.
Forum on trading, automated trading systems and strategy testing
Mt4 End Support.
Artyom Trishkin, 2017.09.10 23:21
I had a goal for the end result of his procedural style code to work in such a loop:
Named wrong out of habit -bool Fn_new_bar(string symb, ENUM_TIMEFRAMES tf) is the right function.
Well, do it now.
OK. Your solution only works on ticks. Mine is on a timer. Do you think my method of timing with bar appearances has a drawback. Okay. Let it be like this. I will add a check for the arrival of a quote before setting a new bar flag. I will add another parameter to the function - a symbol. The user will choose the symbol by which they want to receive the new bar event and send it to the function. The function will check the time of the last quote of this symbol. Then we will compare the time of the bar formal appearance and the time of quotation and set the event flag.
I have only just started to study this subject, but I do not see any difficulties.
It's not about OOP, it's about your code being linear, although you may never know...