Some help needed - page 3

 
Jimdandy:

I think with that #property strict you will have to initialize that i,j,k to a value...


PipPip...Jimdandy

Your arrows are cute
 
 
int init() 
{
   int i=0,j=0,k=0;//initialize the variables to zero (now required with #property strict line that is at top of file.
   string ls;      //strings are initialized implicitly by compiler.
   while (true) {  //this loop will run until it breaks out of it at the break;.
        j=StringFind(LotsProgression,";",i);
        //Look in the LotsProgression string for a semicolon (LotsProgression="0.1;0.2;0.3")
        //Start looking from position i (which we initialized to 0 above)and 0 is the first position of the string. 
        //So it starts at the beginning of the string looking for ; and as you can see in the string above position 0=0,.=1,1=2,;=3... semicolon at position 3
        // now j=3; 
	if (j>0) {    //true.. j is 3 now.
        ls=StringSubstr(LotsProgression,i,j-i);//Get the piece of the string from i(which is 0)to j-1(3-1) which is 2. 0-2position string is "0.1"
        //ls is now "0.1"
        i=j+1;//now i changes from 0 to 4.
        k++;//k gets incremented up from 0 to 1.
        ArrayResize(lots,k);// lots[] array gets made to the size of k which is 1.
        lots[k-1]=StrToDouble(ls);//the lots[]array is of the double type(remember arrays start at index 0)
	Here we are inserting "0.1" string but using StrToDouble() to make it a double (floating decimal number)into index [0].
	//now lots[0]=0.1;
        } else {    //otherwise if j was not greater than zero..until we can not find any more semicolons in the string
                    //the following lines will not run and it will never break out of the while loop. So let's say it jumps to the top again.
		    //now remember i=4,j=3 and k=1 now. So it starts looking in the string at position 4(i)for a semicolon and finds one at position 7
		    //ls now become the string from i to j-1 or from 4 to 6 which is again "0.2". now j=7,i=8,k = 2.
		    //lots array gets re-sized to 2 so now it can hold index 0 and 1. and then index position k-1(2-1)=1 gets
		    //populated with the substring "0.2" turned into a double 0.2 lots[1]=0.2;
      		    //Now on the third search of the string it finds no more semicolons and the else statement kicks in.. 	
		    //Now i=8,j=7 and k is 2
        ls=StringSubstr(LotsProgression,i);//it starts at i (position 8 and reads to the end. getting "0.3"
        k++;//k is now 3
        ArrayResize(lots,k);//array now holds 3 indexes(indices)
        lots[k-1]=StrToDouble(ls);lots[2]=0.3.
        break;we are done with this while loop and our lots array is populated like we want!
	//the question is ... why not just declare an array double lots[] = {0.1,0.2,0.3};
        }
   }
   plen=ArraySize(lots);//in this case plen is now 3..which is not used.
}
I can make arrows.. and yet I don't know how to make a smiley face..... :-(......or a tongue sticker outer face.... :-%
PipPip....Jimdandy...
 
Jimdandy: I think with that #property strict you will have to initialize that i,j,k to a value..
  1. Please don't post images of code or the documentation. For code use the SRC. For the documentation use the links button.
  2. int init()
    {
       int i,j, k;
       string ls;
       while (true) {
          j=stringFind(LotsProgression,";",i);
          if (j>0) {
             ls=StrngSubstr(..._
             i=j+1;
             k++;
       :
    
    I and j are initialized before use. K wrongfully assumes an initial value of zero and must be initialized properly.
 
WHRoeder:
  1. Please don't post images of code or the documentation. For code use the SRC. For the documentation use the links button.
  2. I and j are initialized before use. K wrongfully assumes an initial value of zero and must be initialized properly.

Excuse me while I jump up on this soapbox...I apologize in advance....

1. My apologies I certainly did not intend to break one of your posting rules.
I was thinking more about how to help someone understand mql4 better.
I spend hours sometimes deciding the best way to reply to someone's problem.
I choose the best way that I know of to get the point across. In that process I
may indeed not do it in the way that is the best way that you think is the best way
to do it on this site. However, I do think that people do learn from what I am able
to stumble around and put on here. You have to realize that not everyone knows
how to use this site like you do.

2. Suggestion:
How about you make a video about how to properly use the features on this site
and how to properly use this editor when leaving a post? Or at least give me
a link to that video.

3. If I want to share a sentence or paragraph out of the documentation with someone, I am not
simply going to paste a link to a whole page of documentation and make people search through that
page and try to figure out which part I want them to read.

4. A Line like....
"2. I and j are initialized before use. K wrongfully assumes an initial value of zero and must be initialized properly."

5. Is a classic example of someone who seems incredibly intelligent and talented and a master of the code yet, does not
grasp the fact that they are talking to the uneducated masses. Either that or you do presume that you are
talking to those intellectually inferior to you and you enjoy showing them how smart you are.
Programmers that know what they are doing are NOT reading your posts. They already know any thing that
you may have to share. It is the unknowing that are reading this and trying to better themselves.

6. I don't know which the case is with you. Whether you are genuinely concerned that somehow this site is going
to start looking like a facebook page and that you genuinely do want to promote a better understanding of mql4,
and help others while keeping the site arranged,or, you are on some kind of a ego trip running around all over
the site like a policemen watching for someone to put an arrow in the wrong place. I certainly hope it is not the latter.

7. What I do know from emails and feedback from traders and programmers alike is that many people have stopped
coming here to ask or answer or contribute their knowledge to this site due to the rude and obnoxious way they
themselves or others are treated when asking or answering a question. They are harassed for not posting in the
proper format regardless of the legitimacy of their question or the value of there teaching contribution.
Only those truly desperate stay.

8. There are examples on this site of people asking a simple question that could be answered in less time
than is spent condemning them for not searching the site or posting in the right place or including the wrong image.
You can actually here the fear in their questions as they ask them. Fear of doing something to upset the mql4 GODS.

9. Instead they are made to feel unwelcome and have their question ignored. Why not suggest the proper way to post
AND answer their question? It's an absolute shame. Nobody wins. Everybody loses. The student remains lost, those
with the ability to help remain silent, and mql4.com becomes a less and less desirable place to visit.

10. "There is more happiness in giving than there is in receiving." we are told.
It brings me joy to help others here at Mql4.com but that joy is fading fast.
If we've got to constantly worry about getting our hand slapped away for reaching out to someone in need, there is no
more joy, only dread.

11. Is there any one else out there that feels this way or am I way off base here? Can I get an Amen?
Ok I'm down off of my soapbox..
And I still like your avatar....
PipPip...Jimdandy

 
That's great you all have done a great job. I really thankful to all of you that you share this content here with us. It is really appreciable and would like to say thanks to you that you share this post here with us.
 
Jimdandy:

7. What I do know from emails and feedback from traders and programmers alike is that many people have stopped
coming here to ask or answer or contribute their knowledge to this site due to the rude and obnoxious way they
themselves or others are treated when asking or answering a question. They are harassed for not posting in the
proper format regardless of the legitimacy of their question or the value of there teaching contribution.
Only those truly desperate stay.


PipPip...Jimdandy


TBH I have decided to lessen my involvement here on these forums because I find it generally negative. There seems to be an assumption that no one knows what they are talking about except for a select few. Certain individuals clearly don't respect opinion of most others whilst freely voicing their own opinions elsewhere, and have a turn of phrase which I find so consistently and unnecessary rude, I often wonder how they interact with people in real life. Like you, I suspect they discourage others from even bothering. When they are right (which they often are) they are very vocal, and when they are wrong - silence.

One of my very first posts on this forum (highlighting a previously unreported bug) was not even acknowledged as a helpful heads up to other developers, was but repeatedly dismissed out of hand, and only when I stood my ground, the bug was acknowledge (by more reasonable minds), but there was little in the way of thanks! That should have been my first warning shot! That pretty much sets the tone here, with a similar scenario playing out soon afterwards. A recent comment by myself, which for some reason prompted IMO, an unecessarily strong response, pretty much sealed the deal for me.


I'll contribute to the MQL community, and codebase (now that MQL4 makes code reuse a bit more practical) and might post here occasionally when I have specific answers for specific questions, that are of particular interest to me, but for general queries, most people are well served by the main contributors, from a technical perspective anyway.

I think some here, have taken the noble concept of 'teach a man to fish' and use it as an excuse to be rude more often than not. Its a bit like going to a restaurant here in London's Chinatown called Wong Kei, great food and value but dont go if you want a nice atmosphere, the staff are deliberately rude, and god forbid you have a legitimate complaint! but it still has plenty of customers though!

PS This thread is not really the best illustration of what is being discussed, and is arguably quite reasonable, plenty of 'better' examples can be found!

Oh and 'Amen' BTW!

 
qjol:

what's confusing can u explain ur problem


I think that's called loop function, which confused me. but thanks to Jimdandy for explaining in detail.

What i want? When i execute EA on chart, i want to define two things in its settings. number of trades and size of each trade. like below...

input string=LotsProgression "0.1;0.1;0.2;0.3;0.4;0.6;0.8;1.1;1.5;2.0;2.7;3.6;4.7;6.2;8.0;10.2;13.0;16.5;20.8;26.3;33.1" //Change able values.
and i am trying to write code for this. which i think is "complicated?"
 
qgmql:

[...]which i think is "complicated?"


good luck
 
Jimdandy:
//the question is ... why not just declare an array double lots[] = {0.1,0.2,0.3};
I saw this thing in https://www.mql5.com/en/forum/129933 but its disabled there and a different code for calculation is used....
//double aLots[]={1,3,6,12,24,48,96,192,384,768}; declared, but i think its not used.

//--- or maybe someone has changed it with below code.

if(MaxLots==0) llots=Lots; else       //in paulo costa hedge
if(MaxLots==Lots) llots=3*Lots; else  //llots=3+Lots also works
llots=MaxLots*2;                      //llots=MaxLots+2 also works

If i apply your suggestion. then can a user change values of lots in GUI settings while placing EA on chart?

PS: I saw your 2ma cross EA. which opens trade on crosses (but only one trade at a time) is it possible that EA should only opens trades on each cross but should not close at reverse?

 
qgmql:


I think that's called loop function, which confused me. but thanks to Jimdandy for explaining in detail.

What i want? When i execute EA on chart, i want to define two things in its settings. number of trades and size of each trade. like below...

and i am trying to write code for this. which i think is "complicated?"

Loop over array created using new MQL4++ function StringSplit ? calling StringToDouble inside the loop. (see example on that page to start with),