As i said in my previous post, that i started last January to program. Some functions
were easy & simple, some were complex & difficult to understand. I know as i made this post i was at fault & i learn from it.
Thank You
I started last 2018 December 1 month before you. mql4 was my first ever language.
Create Boolean Functions ExistBuyPos() and ExistSellPos() inside those functions write codes to check for the existance of buy and sell trade respectively....then call them in the OnTick() function....as
Void OnTick()
{
if (ExistBuyPos()==false)
{
trade.Buy(); //write your buy code here
}
elseif ( ExistSellPos()==false)
{
trade.sell(); //write your sell trade code here
}
//this code will Allow only one Pos direction
}
//---
bool ExistBuyPos() {
for (int i=0; i<PositionsTotal(); i++) {
if (PositionSelect(Symbol())) {
if (PositionGetString(POSITION_SYMBOL)==Symbol() && PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY ) {
return(true);
}
}
}
return(false);
}
//---
bool ExistSellPos() {
for (int i=0; i<PositionsTotal(); i++) {
if (PositionSelect(Symbol())) {
if (PositionGetString(POSITION_SYMBOL)==Symbol() && PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_SELL ) {
return(true);
}
}
}
return(false);
}
//---
first if price go up place order with 20 points profit an only one order will be placed if take profit will place another one for stop loos in case 30 points loos
opposite if price go down will place a sell order the same take profit at 20 points and stop loos at 30 points also will place only one sell order
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Thanks for advice /tip i appreciate it a lot.
As i said in my previous post, that i started last January to program. Some functions were easy & simple, some were complex & difficult to understand. I know as i made this post i was at fault & i learn from it.
Thank You
I started last 2018 December 1 month before you.
mql4 was my first ever language.
Create Boolean Functions ExistBuyPos() and ExistSellPos() inside those functions write codes to check for the existance of buy and sell trade respectively....then call them in the OnTick() function....as
hi all
please want help on this ea i want
first if price go up place order with 20 points profit an only one order will be placed if take profit will place another one for stop loos in case 30 points loos
opposite if price go down will place a sell order the same take profit at 20 points and stop loos at 30 points also will place only one sell order
second all this should be in loop functions
thanks to all in advance
thanks
Khalid Amin