if(OrderType()==OP_BUY && OrderMagicNumber()==Magic && OrderSymbol()==Symbol()) OrderClose(OrderTicket(),OrderLots(),Bid,3,Blue); RefreshRates(); if(OrderType()==OP_SELL && OrderMagicNumber()==Magic && OrderSymbol()==Symbol()) OrderClose(OrderTicket(),OrderLots(),Bid,3,Blue);
You do close sells at Bid, close at Ask
Why not just
if(OrderMagicNumber()==Magic && OrderSymbol()==Symbol()) OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,Blue);
You need to check whether the order close was succesful or not. If not print details in the log and it will help you find any errors.

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
Hello everyone. I am struggling to understand where I am going wrong with this code. My goal is to every tick to have the EA totaling profit for all orders on a chart/symbol with the same magic number and when the profit target is reached, the EA should close all the orders under that same magic on that chart and continue to look for the next signal. However the profit total will go well beyond the total I has set up without closing the orders. Could someone help me understand where I might be going wrong? I really appreciate any help. :) here is my code: