Hi,
I have an array with 6 coloumns and 50 rows.
The coloumns are:
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:
When EA starts,all open trades should be written to the Array. Every tick is checked if there are new open trades. If yes,they should be added to the array.
Problem: The EA does not work. The alert "new trade" comes at every tick
for every open position.
I defined "string trade_arr[50][6];" as global variable,but it seems that the array is deleted after every tick.
Would be nice if there is somebody out there to check that...
Thanks,
Swen
Code:
I have an array with 6 coloumns and 50 rows.
The coloumns are:
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:
When EA starts,all open trades should be written to the Array. Every tick is checked if there are new open trades. If yes,they should be added to the array.
Problem: The EA does not work. The alert "new trade" comes at every tick
for every open position.
I defined "string trade_arr[50][6];" as global variable,but it seems that the array is deleted after every tick.
Would be nice if there is somebody out there to check that...
Thanks,
Swen
Code:
QuoteDisliked
string trade_arr[50][6];
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
int trade_nr;
int total=OrdersTotal();
bool trade_exist=false;
for(int pos=0;pos<total;pos++)
{
if(OrderSelect(pos,SELECT_BY_POS)==true)
{
int trade_ticket=OrderTicket();
for(int c=0 ; c<= 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 trade ");
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);
}
//+------------------------------------------------------------------+