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
The close condition uses a reverse signal, but it does not work yOur trades are only closed at stop or takei. What is your reason?
Wrong.
Your condition should be at the start and the close function behind the start.
int i;
//
void Start(){
if ((FMA1<GrossMA1 && FMA2>GrossMA2 && Bid<FMA1-Distanse*GetPoint()) // тут так надо бы Bid<NormalizeDouble(FMA1-Distanse*GetPoint(),Digits)
|| (FRMA1>GrossMA1 && FRMA2<GrossMA2 && Ask>FRMA1+Distanse*GetPoint())){
for(i=OrdersTotal()-1;i>=0;i--) if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && OrderSymbol()==Symbol() && OrderMagicNumber()==magic) {
if (OrderType()==OP_BUY || OrderType()==OP_SELL) CloseOpBuySell(); // тут закроются все ордера и бай и селл
}
}
}// end start
void CloseOpBuySell()
{
for(i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic ) //свой магик
{
if(OrderType()==OP_BUY)
{
if(OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Bid,Digits),3,LawnGreen); {continue;}
}
if(OrderType()==OP_SELL)
{
if(OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Ask,Digits),3,LawnGreen); {continue;}
}
}
}
}
return;
}
Wrong.
If you need to close by individual conditions and not all at once, then the closing function should be different.You should have the condition at the start and the closing function at the start.
Right, but I've already done it and sent it to him, so he won't say anything.
{
//закрытие по МА-шкам
if (FMA1<GrossMA1 && FMA2>GrossMA2 && Bid<FMA1-Distanse*GetPoint()) CloseOpBuySell("BUY");
if (FRMA1>GrossMA1 && FRMA2<GrossMA2 && Ask>FRMA1+Distanse*GetPoint()) CloseOpBuySell("SELL");
return(0);
}
//----
//-----------------------------------+
void CloseOpBuySell(string TypeClose)
{
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==mn )
{
if(TypeClose=="BUY")
{
if(OrderType()==OP_BUY)OrderClose(OrderTicket(),OrderLots(),Bid,3,LawnGreen);
}
if(TypeClose=="SELL")
{
if(OrderType()==OP_SELL)OrderClose(OrderTicket(),OrderLots(),Ask,3,LawnGreen);
}
}
}
}
}
It is better to count based on available funds rather than the balance. Otherwise, you risk getting a lot more than you can afford at the time of opening a trade.
You also need to work out the dependency of the lot step, and then check if the lot is within the maximum and minimum lots allowed in the account.
double lots,lotstep,free,margin, lotmin, lotmax;
lotmax=MarketInfo(Symbol(), MODE_MAXLOT);
lotmin=MarketInfo(Symbol(), MODE_MINLOT);
lotstep = MarketInfo(Symbol(), MODE_LOTSTEP);
reqmargin = MarketInfo(Symbol(), MODE_MARGINREQUIRED);
free=AccountFreeMargin();
lots = NormalizeDouble(lotstep*MathRound((free*MaximumRisk*0.01/reqmargin)/lotstep),2);
if (lots < lotmin) lots = lotmin;
if (lots > lotmax) lots = lotmax;
It is better to count based on available funds rather than the balance. Otherwise, you risk getting a lot more than you can afford at the time of opening a trade.
You also need to work out the dependency of the lot step, and then check if the lot is within the maximum and minimum lots allowed in the account.
double lots,lotstep,free,margin, lotmin, lotmax;
lotmax=MarketInfo(Symbol(), MODE_MAXLOT);
lotmin=MarketInfo(Symbol(), MODE_MINLOT);
lotstep = MarketInfo(Symbol(), MODE_LOTSTEP);
reqmargin = MarketInfo(Symbol(), MODE_MARGINREQUIRED);
free=AccountFreeMargin();
lots = NormalizeDouble(lotstep*MathRound((free*MaximumRisk*0.01/reqmargin)/lotstep),2);
if (lots < lotmin) lots = lotmin;
if (lots > lotmax) lots = lotmax;
Postponed:
Gevorg Hakobyan, 2016.12.08 15:26
Hello. How can I get a list of all existing currency pairs in Meta Trader 4? And how can I keep abreast of any changes in the list?Postponed:
Gevorg Hakobyan, 2016.12.08 15:26
Hello. How can I get the list of all currency pairs existing in Meta Trader 4? And how to be aware of any changes in the list?SymbolsTotal
Returns the number of available (selected in MarketWatch or all) symbols.
intSymbolsTotal(
bool selected// true - only symbols in MarketWatch
);
Parameters
selected
[in] Request mode. Can take values true or false.
Returned value
If selected is true, the number of characters selected in MarketWatch is returned. If false, it returns the total number of all symbols.
Postponed:
Gevorg Hakobyan, 2016.12.08 15:26
Hello. How can I get a list of all existing currency pairs in Meta Trader 4? And how can I keep abreast of any changes in the list?