Errors, bugs, questions - page 1418

 
Hi all!
I've recently started programming and I've encountered such a problem, the StopLoss is not set. Can you advise where the error is?
int start()
{
if(CountTrades()==0)
{
double ima=iMA(Symbol(),PERIOD_H1,14,0,MODE_SMA,PRICE_CLOSE,1);
if(Ask>ima)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,",Magic,0,Blue);
if(ticket>0)
{
TP=NormalizeDouble(Ask+TakeProfit*Point,Digits);
bool modify1=OrderModify(ticket,OrderOpenPrice(),0,TP,0)
{
SL=NormalizeDouble(Ask-StopLoss*Point,Digits);
bool modify=OrderModify(ticket,OrderOpenPrice(),SL,0,0);
}
}
}
else if(Bid<ima)
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,0,0,",Magic,0,Red);
if(ticket>0)
{
TP=NormalizeDouble(Bid-TakeProfit*Point,Digits);
bool modify1=OrderModify(ticket,OrderOpenPrice(),0,TP,0)
{
SL=NormalizeDouble(Bid+StopLoss*Point,Digits);
bool modify=OrderModify(ticket,OrderOpenPrice(),SL,0,0);
}
}
}
else
{
int order_type=FindLastOrderType();
if(order_type==OP_BUY)
{
price=FindLastPrice(OP_BUY);
if(Ask<=price-Step*Point)
{
lastlot = FindLastLots(OP_BUY);
lastlot = NormalizeDouble(lastlot * Multiplier, 2);
ticket=OrderSend(Symbol(),OP_BUY,lastlot,Ask,Slippage,0,0,",Magic,0,Blue);
if(ticket>0)
ModifyOrders(OP_BUY);
}
}
else if(order_type==OP_SELL)
{
price=FindLastPrice(OP_SELL);
if(Bid<=price+Step*Point)
{
lastlot=FindLastLots(OP_SELL);
}
lastlot=NormalizeDouble(lastlot*Multiplier,2);
ticket=OrderSend(Symbol(),OP_SELL,lastlot,Bid,Slippage,0,0,",Magic,0,Red);
if(ticket>0)
ModifyOrders(OP_SELL);
}
}
}
return(0);
}
Thank you in advance)))
 
Сергей Верещак:
if(Ask>ima)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,",Magic,0,Blue);
if(ticket>0)
{
TP=NormalizeDouble(Ask+TakeProfit*Point,Digits);
bool modify1=OrderModify(ticket,OrderOpenPrice(),0,TP,0); set Take Profit and Stop Loss with 0
{
SL=NormalizeDouble(Ask-StopLoss*Point,Digits);
bool modify=OrderModify(ticket,OrderOpenPrice(),SL,0,0); set Stop Loss and Take Profit to zero, i.e. delete the one set earlier
}
}
}

Thanks in advance)))
Dig in, tip given ...
 
Vladimir Pastushak:
Dig in, I gave you a tip ...
Thanks Volodya. I'll dig, I'll figure it out sooner)))
 
Vladimir Pastushak:
Dig in, I gave you a tip ...

Then let's bring it to the standard of the "new" MQL4 and MQL5.

//TP=NormalizeDouble(Ask+TakeProfit*Point,Digits);
TP=NormalizeDouble(Ask+TakeProfit*_Point,_Digits);
 
Alexey Volchanskiy:

Then let's bring it to the standard of the "new" MQL4 and MQL5.

//TP=NormalizeDouble(Ask+TakeProfit*Point,Digits);
TP=NormalizeDouble(Ask+TakeProfit*_Point,_Digits);

On May 15 this year there is a post by Renat Fatkhullin with the following text:

Underscores to show their deprecated status. You can't use such simple variables declared globally, but look like regular local variables.

To keep the language and code clean, we should switch to Symbol(), Period(). It's just the thoughtfulness and getting rid of the legacy of the old one.

If necessary, you can search the post with the quoted point. This was Renat's answer to one of the questions of one of the Community members, which started as follows:

In MT4 the variables Point, Digits... In MT5 these same variables start with an underscore...


P./S.: Accordingly, based on the fact that underscores are deprecated (deprecated or disapproved or not recommended for use in the future), then the use of Point() and Digits() without underscores. /* In MQL4 such using of Point() and Digits() with parentheses after their names, like in MQL5, does not produce errors at operation and no errors or warnings at compilation.

 

Hello, I have a very interesting question, I have 3 MT4 platforms on my computer, platform 1 is the main one, where I opened a real account. No. 2 and 3 - auxiliary, for testing EAs, there are opened demo accounts. When I try to copy a signal from https://www.mql5.com (I select a signal, press start copying, then a window pops up saying to launch MetaTrader4 and subscribe to a platform, I press this window) platform number 3 opens instead of platform number 1. How can I correct it? How to make platform number 1 open?

 
Mihail Kuzmin:

Hello, I have a very interesting question, I have 3 MT4 platforms on my computer, ¹1 is the main one, where I opened a real account. No. 2 and 3 - auxiliary, for testing EAs, there are opened demo accounts. When I try to copy a signal from https://www.mql5.com (I select a signal, press start copying, then a window pops up saying to launch MetaTrader4 and subscribe to a platform) I open platform number 3 instead of platform number 1. How can I correct it? How can I open platform number 1?

If you have a "zoo" of several terminals, you should search the signal directly from the terminal you want to copy.
 
Karputov Vladimir:
If you have a "zoo" of several terminals, you must search for the signal directly from the terminal to which you want to copy.
The terminal does not work, but gives an error...
 
Mihail Kuzmin:
The terminal does not work and gives an error...
What kind of error? What do you do, in what order?
 
Karputov Vladimir:
What kind of error? What are you doing, in what order?

I have been using the site for a month now, I have been subscribing through the site, and this time, for some reason it opens a completely different platform.

I had just signed up for a signal a month ago through the website, and it opened the platform I needed No. 1.

Reason: