Help with closing orders with same magic on a chart when profit is reached
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.
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: