Okay, I expect I could probably figure this out on my own (eventually) but, since I see no point in banging my head against the wall, I figured I'd give it a try. What I'm trying to do is modify a preexisting order based upon the order count.
Here is the code I'm using that determines the total orders, beginning with the earliest order I believe, and counts up incrementally.
Basically what I've done is create the first "counter" to determine the number of orders or current count (both OP_BUY and OP_SELL) and duplicated it (by adding a "2' at the end of each variable) to create a second counter for determining the second order preceding the current one, which was just placed. This is the order I'm attempting to modify and change the Take Profit value.
I haven't attempted to do this before (although I know the first counter works), so I'm only guessing this is how it should be done. And, although it complies okay, and the initial orders are processed okay, it won't come back and modify them.
Anybody got any ideas?
Thanks!
Here is the code I'm using that determines the total orders, beginning with the earliest order I believe, and counts up incrementally.
PHP Code
//---- Check for Open Orders
int total=OrdersTotal(),cmd,TBS_cnt=0;
for(int cnt=0; cnt<=total; cnt++)
{
if(OrderSelect(cnt,SELECT_BY_POS)==true)
{
cmd=OrderType();
if(cmd==OP_BUY||cmd==OP_SELL){ TBS_cnt+=1; }
}
}
PHP Code
//---- Modify Selected Orders
int totalZ=OrdersTotal(),cmdZ,TBS_cntZ=0;
for(int cntZ=0; cntZ<=totalZ; cntZ++)
{
if(OrderSelect(cntZ,SELECT_BY_POS)==true)
{
cmdZ=OrderType();
if(cmdZ==OP_BUY||cmdZ==OP_SELL){TBS_cntZ+=1; }
if(TBS_cnt>2&&TBS_cntZ==TBS_cnt-2)
{
OrderModify(TBS_cntZ,0,0,OrderTakeProfit()-Point*TP1,0,Blue);
}
}
}
Anybody got any ideas?
Thanks!