problem with array (two-dimensional)
Results 1 to 4 of 4

Thread: problem with array (two-dimensional)

  1. #1
    Hi,

    I've an array with 6 coloumns and 50 rows.
    The coloumns include:

    trade_arr[x][0]=OrderTicket();
    trade_arr[x][1]=OrderStopLoss();
    trade_arr[x][2]=OrderTakeProfit();
    trade_arr[x][3]=OrderSymbol();
    trade_arr[x][4]=OrderOpenPrice();

    Now I wanna do this:
    If EA starts,all available trades should be written to the Array. Every tick is checked if there are new available trades. They should be added to the array, if yes.
    Problem: The EA does not work. The alert new commerce comes at each tick
    for each open position.
    I described string trade_arr[50][6]; as global variable,but it seems that the array is deleted after each tick.

    Could be nice if There's somebody out there to check that...

    Thanks,
    Swen


    Code:
    Quote Originally Posted by ;

    string trade_arr[50][6];

    // ------------------------------------------------------------------
    //| expert initialization function |
    // ------------------------------------------------------------------
    int init()

    //--


    //--
    return(0);

    // ------------------------------------------------------------------
    //| expert start work |
    // ------------------------------------------------------------------
    int start()


    int trade_nr;
    int total=OrdersTotal();
    bool trade_exist=false;

    for(int pos=0;poslt;total;pos )

    if(OrderSelect(pos,SELECT_BY_POS)==true)

    int trade_ticket=OrderTicket();

    for(int c=0 ; clt;= 49;c )


    int trade_arr_int=StrToInteger(trade_arr[c][0]);

    if (trade_ticket==trade_arr_int)

    Alert(Trade exist);
    trade_exist=true;


    if (trade_arr[c][0]==0)
    int next_nr=c;
    Alert(next c ),next_nr);




    if (trade_exist==false)


    Alert(New transaction);

    trade_arr[next_nr][0]=OrderTicket();
    trade_arr[next_nr][1]=OrderStopLoss();
    trade_arr[next_nr][2]=OrderTakeProfit();
    trade_arr[next_nr][3]=OrderSymbol();
    trade_arr[next_nr][4]=OrderOpenPrice();


    trade_exist=false;




    return(0);

    // ------------------------------------------------------------------

  2. #2
    Hey swen.... As it's coded , there is not anything between start() and the job .... So yes, it will do the job on every tick....

    A frequent method is to count something, on your case here you could count the total orders.... If the count has changed since the last tick,

    -- Now do the job....

    Else

    -- Now do nothing....

    //--

    When EA starts,all open transactions should be composed to the Array

    this has me curious.... All of this information is stored/written currently .... Is there something special your doing with the array.... I can not tell from your code...h

  3. #3
    I declared the array with Beginning() and now it works like That I need it...

    Swen

  4. #4
    If an alarm is issued by its different than the value, I would check the ticket.

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 more information