Forex
Google
New signals service!

Go Back   Forex Trading > Discussion Areas > Metatrader 4


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

Reply
 
LinkBack Thread Tools Display Modes
  #11 (permalink)  
Old 01-15-2007, 01:20 AM
Nicholishen's Avatar
Senior Member
 
Join Date: Dec 2005
Posts: 531
Nicholishen is on a distinguished road
OK, I am successfully adding functions with pointers to libraries, and it works as long as I am passing an array. When I try to do it just referencing a single variable, I does not work in a library but works when the function is in the same source file as the start(). Can anyone advise as to why?
__________________
"Anyone who has never made a mistake has never tried anything new." -Albert Einstein
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12 (permalink)  
Old 01-15-2007, 11:11 PM
cockeyedcowboy's Avatar
Senior Member
 
Join Date: Nov 2005
Posts: 302
cockeyedcowboy is on a distinguished road
Quote:
Originally Posted by Nicholishen
OK, I am successfully adding functions with pointers to libraries, and it works as long as I am passing an array. When I try to do it just referencing a single variable, I does not work in a library but works when the function is in the same source file as the start(). Can anyone advise as to why?
Nick

not sure what you ment by the question just above this post.

I tryed to warn that labrary modules function calls work very differently. You can pass arrays by referance to a library function but not simple varibles they are past by value only. Now if the function is discribed with in an include file, that is the function is totally decleared in the include file not imported into the file it will work just like if it were writen in the main run module. When you use the import comand it changes the way you do things. also If you are useing default values on some of your parameters they will not be reconized accoss modules either.

Hope that helps

The CockeyedCowboy
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #13 (permalink)  
Old 10-07-2008, 02:43 AM
Junior Member
 
Join Date: Jun 2007
Posts: 4
leialex is on a distinguished road
Question on Array, please help!

Hi,

I am new to using array, I managed to properly setup two single dimension arrays, namely Profit[] and MagicNo[].

I will try to explain what I would like to achieve using the following example,

Array# Profit[] MagicNo[]
[1] 30 100
[2] 5 101
[3] 10 102
[4] 40 103
[5] 5 104

I am trying to incorporate into my EA to pick out the first possible combination from longest profit to smallest profit, and the operation will break as soon as the total profit reaches a pre-determined amount, for example 50. Hence, the result should have been Array[4]+Array[1], then the outcome of the operation will be the associated MagicNo, so that the EA can properly close the associated opened position(s) with selected MagicNo. In this case, the outcome should be MagicNo[4] and Magic[1], which then in turns become 103 and 100.

I am not sure, but I believe I may need a third array to temporary store information.

I hope I have explained myself clearly.

Please kindly help, any contribution will be appreciated.

Thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #14 (permalink)  
Old 10-07-2008, 10:11 AM
cockeyedcowboy's Avatar
Senior Member
 
Join Date: Nov 2005
Posts: 302
cockeyedcowboy is on a distinguished road
Quote:
Originally Posted by leialex View Post
Hi,

I am new to using array, I managed to properly setup two single dimension arrays, namely Profit[] and MagicNo[].

I will try to explain what I would like to achieve using the following example,

Array# Profit[] MagicNo[]
[1] 30 100
[2] 5 101
[3] 10 102
[4] 40 103
[5] 5 104

I am trying to incorporate into my EA to pick out the first possible combination from longest profit to smallest profit, and the operation will break as soon as the total profit reaches a pre-determined amount, for example 50. Hence, the result should have been Array[4]+Array[1], then the outcome of the operation will be the associated MagicNo, so that the EA can properly close the associated opened position(s) with selected MagicNo. In this case, the outcome should be MagicNo[4] and Magic[1], which then in turns become 103 and 100.

I am not sure, but I believe I may need a third array to temporary store information.

I hope I have explained myself clearly.

Please kindly help, any contribution will be appreciated.

Thanks.


leialex

Dont know were your going with this, but a two dimensional array would make the task a whole lot easier. as in;


int OrderKey [ 2, 5 ]; {Note:this may need to be of double type depending on your usage}


This array can combine both of your arrays into one;

so OrderKey [ 1, x ] contains your profit data and OrderKey [ 2, x ] contains the MagicNu of that profit data.

so when you find the profit data in the array its MN will be the next dinension. as in your example Array[4] + Array[1], would equate to OrderKey [ 1, 4 ] + OrderKey [ 1, 1 ] the corrisponding MN would be OrderKey [ 2, 4 ] and OrderKey [ 2, 1 ].


You can use the builtin function ArrayBsearch()

to search the first dimension of you new array for a value, in this case its your profits. OrderKey [ 1, x ] It returns the index number so the idem your looking for. let say that int Record = ArrayBsearch(); then the profits you are look for are stored in OrderKey [ 1, Record ] with its MN stored in OrderKey [ 2, Record ]. If you make two #define varibles named as in

#define profits 1
#define magic 2

OrderKey [ profits, Record ] ane OrderKey [ magic, Record ] would me more natural to read



You donot need to create a new array to sort your current array as the built in function ArraySort() will sort your array and save it in the sorted format requested to your current array. the sort is done with the first dimension element of the multi dimensional array in this case your profits. so if you sort your OrderKey array it will be sorted by the profit element either up or down as you request. but you donot need to sort an array to search it for a value.


Hope this answers your question

Keit

Edit: below is a code block that checks for open positions at the end of your trading session and closes them. This was supplied as an example of what can be done to give you some idears, It careate its own search patent without the use of any builtin search or sort functions by using two imbedded For Loops and cycling through the two dimensional array.


Code:
//«« LABEL 500 »» POSITION MANAGEMENT: »»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
    //«« <<<< Segment 510 >>>> »»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
        // Code to close open market orders and repeal any pending orders at trade closing time.
        if( BrokerTime >= BrokerQuitingTime ) {
            for( Session = One; Session <= Three; Session = Session + One ) {
                for( Position = One; Position <= Two; Position = Position + One ) {
                    Record  =  OrderKey[ Session, Position ];
                    if( Record == Empty ) continue;
                        OrderID  =  OrderKey[ Session, OrderPlacment ] + Position;
                        if( OrderSelect( Record, SELECT_BY_TICKET, MODE_TRADES )) {
                            if( OrderCloseTime() == Empty ) {
                                if( OrderMagicNumber() == OrderID ) {
                                    GetNewQuotes( TradedCurrency );
                                    switch( OrderType() ) {
                                        case LongOrder:
                                            CloseOpenPosition( LongOrder, BidPrice, OrderTicket() );
                                            break; 
                                        case ShortOrder:
                                            CloseOpenPosition( ShortOrder, AskPrice, OrderTicket() );
                                            break;
                                        default: // RD!{incase any pending are sill open}:
                                            DeletePendingOrder( OrderType(), OrderTicket() );
                                            break;
                                    } // End Switch Case, OrderType:
                                } // End If, OrderMagicNumber:
                            } // End If, OrderCloseTime:
                        } // End If, OrderSelect:
                } // End For Loop, Position:
            } // End For Loop, Session:
            SystemMode  =  SessionFinished;
        } // End If, BrokerTime:

Last edited by cockeyedcowboy; 10-07-2008 at 10:41 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #15 (permalink)  
Old 10-07-2008, 10:53 PM
Junior Member
 
Join Date: Jun 2007
Posts: 4
leialex is on a distinguished road
Thanks...

Many thanks cockeyedcowboy.

Initially, the reason why I had them setup as two arrays is because the profit array is a double type and the MagicNo array is a int type.

After looking at it, the MagicNo array has no reason that restrict it to be a double type. So I guess it is ok to apply a two dimensional array in double.

I am going to look into what you have suggested.

Thanks once again for boosting my learning curve ahead.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
iCustom function homicida Questions 56 07-28-2008 09:57 AM
Data in Array converted to btw 0 and 1 ( normalisation) ! icm63 Metatrader 4 4 01-22-2007 01:25 AM
Array search helper functions for your use... cubesteak Metatrader 4 3 09-04-2006 04:55 AM


All times are GMT. The time now is 07:36 AM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.