I don't which section to post this in. Hopefully this is the right one.
I am busy coding an EA (with my limited knowledge
)
Here is one issue I can't seem to solve, obviously it works perfectly with the EA running on only 1 currency pair, but as soon as I drop it on another pair, I run into the following problems, I know it's just a stupid coding mistake on my side:
-------------------
I have set the maximum trades to 1, so it doesn't open
more than 1 buy or 1 sell.
This works fine, but if I drop the EA on a 2nd pair, it doesn't take trades, unless I change the 2nd MagicNumber to something different.
This is not a real issue, as I can just assign a new magic number to every currency pair. It would just be nice if I don't need 5 different magic numbers for the same EA on 5 pairs
The big issue I have is partial take profit.
It works fine on 1 pair, closes perfectly, BUT if I drop on pair number 2, it uses the 1st next tick to calculate the value the 2nd pair's value, and obviously it uses the wrong pair's value to partly close the other pair.
// add your notes here ...
if ( ( Use_Partial_TP == true ))
{
SellPTP=OrderOpenPrice()-(Partial_TP* Point);
if ( ( OrderLots() == Lots ) || ( OrderLots() == _MMLots ))
{
if ( ( Ask <= SellPTP ))
{
for( int pos6030=0;pos6030<OrdersTotal();pos6030++)
{
if(OrderSelect(pos6030,SELECT_BY_POS)==false) continue;
if( ( OrderTicket() == _OrderTicketEA) )
{
double price6198=0;
price6198 = MarketInfo(OrderSymbol(), MODE_ASK);
_fnCloseSellPTP = OrderClose( OrderTicket(), (OrderLots()/2), price6198, Slippage, White );
if( _fnCloseSellPTP == false )
Print("OrderClose error=", GetLastError());
Coding for buy is basically the same except Add to the open price, and close price is Bid, etc etc.
And it does this besides the fact that the same EA runs on both pairs, but different magic numbers, which is why I am totally stumped, I was under the impression if I assign different magics, it will solve this problem too.
Thanks for the help again.
Francois
Linkback: https://www.forex.zone/ea-modifications/17/ea-code/332/