Two Dimensional Array vs One Dimensional Array
Page 1 of 502 1 2 LastLast
Results 1 to 10 of 13

Thread: Two Dimensional Array vs One Dimensional Array

  1. #1

    Two Dimensional Array vs One Dimensional Array

    Can anybody describe how you would go about implementing it and to? I understand a one dimensional array has a max of 50 components and would seem like so: my_array that is double[50] . But if I were to bring a second dimension, does it turn into a multiplier of the first that, if it too contained a max of 50 components, does this mean it now has a max of 2500 (50 x 50) components? What I need is also a one dimensional array by itself and a array with at least 250 components I'm afraid won't work. I guess this may be correct, so I guess all I must do is attempt to implement it.

    This is precisely what I mean to perform. Does it seem right?

    PHP Code: <code><span style=”color: #000000”> <span style=”color: #0000BB”></span><span style=”color: #007700”>for(</span><span style=”color: #0000BB”>inti</span><span style=”color: #007700”>=</span><span style=”color: #0000BB”>0</span><span style=”color: #007700”>;</span><span style=”color: #0000BB”>I</span><span style=”color: #007700”>lt;=</span><span style=”color: #0000BB”>49</span><span style=”color: #007700”>;</span><span style=”color: #0000BB”>I</span><span style=”color: #007700”> )

    for(</span><span style=”color: #0000BB”>intii</span><span style=”color: #007700”>=</span><span style=”color: #0000BB”>0</span><span style=”color: #007700”>;</span><span style=”color: #0000BB”>ii</span><span style=”color: #007700”>lt;=</span><span style=”color: #0000BB”>49</span><span style=”color: #007700”>;</span><span style=”color: #0000BB”>ii</span><span style=”color: #007700”> )

    if(</span><span style=”color: #0000BB”>Ask</span><span style=”color: #007700”>=</span><span style=”color: #0000BB”>Targ</span><span style=”color: #007700”>Number91;</span><span style=”color: #0000BB”>I</span><span style=”color: #007700”>Number93;#91;</span><span style=”color: #0000BB”>ii</span><span style=”color: #007700”>#93;-RRB-

    </span><span style=”color: #0000BB”>Tk_1</span><span style=”color: #007700”>#91;</span><span style=”color: #0000BB”>I</span><span style=”color: #007700”>#93;#91;</span><span style=”color: #0000BB”>ii</span><span style=”color: #007700”>#93;=</span><span style=”color: #0000BB”>OrderSend</span><span style=”color: #007700”>(</span><span style=”color: #0000BB”>Symbol1</span><span style=”color: #007700”>,</span><span style=”color: #0000BB”>OP_BUY</span><span style=”color: #007700”>,</span><span style=”color: #0000BB”>Lots1</span><span style=”color: #007700”>,</span><span style=”color: #0000BB”>Ask</span><span style=”color: #007700”>,</span><span style=”color: #0000BB”>Slip1</span><span style=”color: #007700”>,</span><span style=”color: #0000BB”>0</span><span style=”color: #007700”>,</span><span style=”color: #0000BB”>0</span><span style=”color: #007700”>,</span><span style=”color: #DD0000”>''''</span><span style=”color: #007700”>,</span><span style=”color: #0000BB”>0</span><span style=”color: #007700”>,</span><span style=”color: #0000BB”>0</span><span style=”color: #007700”>,</span><span style=”color: #0000BB”>Lime</span><span style=”color: #007700”>);
    </span><span style=”color: #0000BB”>Gate1</span><span style=”color: #007700”>Number91;</span><span style=”color: #0000BB”>I</span><span style=”color: #007700”>#93;#91;</span><span style=”color: #0000BB”>ii</span><span style=”color: #007700”>#93;=</span><span style=”color: #0000BB”>1</span><span style=”color: #007700”>;</span><span style=”color: #0000BB”>Gate0</span><span style=”color: #007700”>#91;</span><span style=”color: #0000BB”>I</span><span style=”color: #007700”>#93;#91;</span><span style=”color: #0000BB”>ii</span><span style=”color: #007700”>#93;=</span><span style=”color: #0000BB”>1</span><span style=”color: #007700”>;



    </span><span style=”color: #0000BB”></span> </span> </code> Thank you in advance.

  2. #2
    Of course this doesn't tell anything. I guess that would help.

  3. #3
    Hello ec.... Not certain how your coming at a maximum of 50.... Also not sure what your trying to accomplish.... But here are a few thoughts....

    Single arrays could be thought of as 1 liners.... Like Close[], Open[] and these....

    Dual arrays could be thought of as a checker board....

    Int board[8][8]; here the number of components is put....

    So if a said board[3,6] , you ought to be aware of exactly which square he was talking of.... And when he explained board[3,9], you would know he'd know clue as to what he was talkin about....

    Three deminsional arrays could be thought of as a rubicks cube....

    Int cube[3][3][3];

    so if a person said cube[2,0,1] you can, know exactly the destination/address/data....

    //------

    all that aside, a single array can hold many components.... It could most likely manage your task...h

  4. #4
    Quote Originally Posted by ;
    hey ec.... Not sure how your arriving at a maximum of 50.... Also not sure what your trying to achieve.... But here are a few ideas....

    Single arrays could be considered as 1 liners....
    Wow! Yeah I see what you are saying. I was basically correct when saying when I had a two dimensional range group at 50 in each measurement, it would return 2500 (i.e., 50 x 50) elements. Or, even if it had been a 3 dimensional array, it would return 125,000.

    As far as the highest amount of elements is concerned, apparently I must have misunderstood when studying about it awhile back.

    This was the only place I could find it referenced at the MQL4 Reference below Array purposes:

    Quote Originally Posted by ;
    A group of functions to work with arrays.

    Arrays are permitted to be maximum four-dimensional. Each measurement is indexed from 0. In a specific instance of a one-dimensional array of 50 elements, calling of the first element will appear as array[0], of the one - as selection[49].
    So yes, it looks like they are only giving this as an illuion, rather than specifying a maximum. So this is a good idea to know!

    Hey, Thanks!

  5. #5
    Hello ec.... Yes, this is my view also...h

  6. #6
    Okay, having said that, I generated a new one dimensional array using 250 elements and plotted them 8 point intervals on the grid, and I am still having the same problem. It's bypassing every 5th period rather than plotting it on the grid. Which would be understandable (or at least give me some idea why) when I had been creating 5 arrays and stacking them like I earlier but, now I am not. So I looked at the code and made sure there was no longer any references to the number 5 (I used it as a multiplier two before) imagining it was somehow related to the cause, but nope, it does the specific same thing. Weird!

  7. #7

  8. #8
    I am attempting to plot a grid system, which places a trade every so many points (currently it's place at 8). However, it's missing or not putting a trade at every interval, like I said. And it doesn't seem to matter how I go about doing it, whether it's 5 separate arrays, which are piled and contain 50 elements or, while it's a array.

  9. #9
    Hello ec.... If your goal is to simply place trades, might be simplier only to employ a loop.... This is done with a script, not an ea.... But it may be carried out in a true ea....

    are you familar with loops.... Such as under....

    Highly imply scripts only.... Might be errors in my code, didn't test it...h

    Inserted Code #property show_inputs extern bool Trade = false; int ProfitTarget = 100; int Stoploss = 100; int Slippage = 3; int grid = 10; int buylimit; dual buylimitgrid; //-- int trades = 5; int orders; // ------------------------------------------------------------------ // ------------------------------------------------------------------ int begin() //-- orders = trades - 1; //-- if(Trade OrdersTotal() lt; orders) for(int I=trades;igt;=0;I--) while(true) buylimit = OrderSend(Symbol(),OP_BUYLIMIT,0.01,Ask-(buylimitgrid*Stage),Slippage,Ask-((Stoploss buylimitgrid)*Stage),Ask-((buylimitgrid-ProfitTarget)*Stage),0,0,0,Red); buylimitgrid = buylimitgrid grid if(buylimitlt;=0) Print(Error = ,GetLastError()); else Print(mistake); break; Sleep(3000); return(0);

  10. #10
    Aside from plotting trades, there are. But, unless I will plot the trades it will not work. And yes, I am using a loop, actually 2, one for setting up the grid, and one for obtaining it (see first 3 articles).

    So, what's the deal with the script? Is it jut a 1 shot deal, where it sets the grid up areas trades daily? Or can you program performance to it than that? Because I am attempting to have it to change lot size, modify and delete orders but, only at particular thresholds, and things like this. Could this be programmed into a script? Because thus far, I have just worked with EA's, I don't know.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners. Read more.