forextrader-radioman wrote:hmmm, thank you for your thoughts ...
for my need it is ok to replace just the actual closed trade. EA has to monitor constantly and if any TP is given: replace that trade as a pending order. Thats all ... after that it is standing by until a new "TP event" is given ... would that be possible with the code?
(damn, we have winter again here in Hamburg/Germany ... 15cm new snow over the last night ... 3 days before we had spring temperatures and sunshine)
, Dietmar
Here is a portion of the atual code to determine last closed trade and whether the trade was loss, profit or BE and how long ago it closed.
There is not a problem with running it on EachTick. If you are concerend then run it only once per bar.
Code: Select all
for(pos=OrdersHistoryTotal(); pos >= 0; pos--){
if(OrderSelect(pos, SELECT_BY_POS, MODE_HISTORY) && OrderMagicNumber()==MagicNumber && OrderSymbol()== Symbol()){
if(OrderType()==OP_SELL){
OP=OrderProfit();
lastord="S";
BarsSinceLastClose=iBarShift(NULL,0,OrderCloseTime());
if(OrderProfit()<=0){
lastlossbarsS = (Time[0]-OrderCloseTime())/TimeDivisor;
lastS="loss";
}
else if(OrderProfit()>0){
lastlossbarsS = (Time[0]-OrderCloseTime())/TimeDivisor;
lastS="profit";
}
else{
lastS="BE";
lastlossbarsS = (Time[0]-OrderCloseTime())/TimeDivisor;
}
break;
}