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
Hi Guys,
I know from some other posts that I may not get the solution for free.
I'm trying to create an EA that will stop trading when it reaches a profit target.
I have managed to get it to switch autotrading off but it keeps repeating. I've only just started learning so any guidance is helpful.
Here is what I have.
extern bool CloseOrder=true; //Close All Order
bool CExpert::CloseAll(double lot);
bool PositionCloseBy(
const ulong ticket, // position ticket
const ulong ticket_by // opposite position ticket
);
extern bool disableexpert=true; //Disable Expert Advisor
extern double EquityTarget=3700; //Equity Take Profit (USD)
extern double EquityStop=0; //Equity Stop Loss (USD)
void OnTick()
{
double equity=AccountInfoDouble(ACCOUNT_EQUITY);
double accbalance=AccountInfoDouble(ACCOUNT_BALANCE);
double profit=AccountInfoDouble(ACCOUNT_PROFIT);
int total=OrdersTotal();
if(AccountInfoInteger(ACCOUNT_TRADE_EXPERT))
{
if(equity>=EquityTarget)
{
if(total!=0 && CloseOrder==true)
{
CloseAllTrade();
}
if(disableexpert)
{
DisableEA();
}
Print("reached equity Target level");
}
}
}
//disable autotrading
void DisableEA()
}
keybd_event(17,0,0,0);
keybd_event(69,0,0,0);
keybd_event(69,0,2,0);
keybd_event(17,0,2,0);
}
I realise that it might be totally wrong.
Thanks in advance!