Please use the SRC button to insert code snippets!!!! :(
Do the orderSelect before you do take my profit.
What is the error? Does this compile? :) (no disrespect here, but you didnt state the problem, except that you have a problem.
Hi thanks for response.
found the SRC button
think i found the problem from my log - stoploss should be - ie. wrong way from Buy & sell
StopLoss=(Bid - My_StopLoss * Point);
for (i1=1; i1 < MOT_index[0]+1; i1++) // MOT_index is a vector used to sort MOT { if (MOT[i1][6] == 0) // MOT[][6] = OrderType(); { take_my_profit = (Ask + My_TakeProfit * Point); write_to_log(1030); if (OrderSelect(MOT[i1][4], SELECT_BY_TICKET, MODE_TRADES)) // MOT[][4] = OrderTicket(); { StopLoss=(Ask + My_StopLoss * Point); OrderModify(OrderTicket(),OrderOpenPrice(),StopLoss,take_my_profit,0,Blue); error = GetLastError(); write_to_log(1040); } } }
- Or just make the code direction independent
double Direction(int op_xxx){ return( 1. - 2. * (op_xxx%2) ); } ... double DIR=Direction(OrderType()); StopLoss=(OrderClosePrice() -DIR* My_StopLoss * Point); // SL below OCP for Buy.
- EA's should adjust for 4/5 digit brokers. TP, SL, AND slippage
//++++ These are adjusted for 5 digit brokers. int pips2points; // slippage 3 pips 3=points 30=points double pips2dbl; // Stoploss 15 pips 0.0015 0.00150 int Digits.pips; // DoubleToStr(dbl/pips2dbl, Digits.pips) int init(){ if (Digits == 5 || Digits == 3){ // Adjust for five (5) digit brokers. pips2dbl = Point*10; pips2points = 10; Digits.pips = 1; } else { pips2dbl = Point; pips2points = 1; Digits.pips = 0; } // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Coding Problems. Can't figure what I am doing again!
MOT is a matrix of all current orders (I also have a MOT_index which is a single dimension vector - used to sort the array if required). Write to Log is as the name suggests a log file of events
for (i1=1; i1 < MOT_index[0]+1; i1++)
{ if (MOT[i1][6] == 0) // MOT[][6] = OrderType();
{ take_my_profit = (Ask + My_TakeProfit * Point);
write_to_log(1030);
if (OrderSelect(MOT[i1][4], SELECT_BY_TICKET, MODE_TRADES)) // MOT[][4] = OrderTicket();
{ StopLoss=(Ask + My_StopLoss * Point);
OrderModify(OrderTicket(),OrderOpenPrice(),StopLoss,take_my_profit,0,Blue);
write_to_log(1040);
}
}
}