Questions from Beginners MQL4 MT4 MetaTrader 4 - page 49

 
Alexander Antoshkin:

For a cake and a cup of coffee, a warning should be tweaked ( from the new builds of mt4)

)

Well, the pie can be mailed... Where do you get the coffee?

Files:
 
Alexey Viktorov:

Well, you can mail a pie... Where do you get the coffee?

Thank you.)))

corrected code returned to the article thread.................................................

 
I am trying to install MetaTrader4 from original installation file mt4setup.exe but MT5 is installed to me brazenly. Windows7 x64 system. Is this how the developer is trying to get me to like the new platform? How can I install what I want (MT4) and not what is being forced on me?
 
Andrej Akimov:
I am trying to install MetaTrader4 from original installation file mt4setup.exe but MT5 is installed to me brazenly. Windows7 x64 system. Is this how the developer is trying to get me to like the new platform? How can I install what I want (MT4) and not what is foisted on me?
There are already a bunch of threads on the forum with solutions to this problem. Why not use the search engine?
 
Show by example how to write a string to a file and read it.The file must be stored in the root of the C drive.This must be anexpert.
 

I am trying to implement the stop loss and take profit in this way:

spread = Ask-Bid;

double StopLoss_B = NormalizeDouble(Low[1]- spread,Digits);//NormalizeDouble(Low[1]- spread,Digits)

double TakeProfit_B = NormalizeDouble(Ask+((Ask-StopLoss_B)* RiskRewart),Digits) ;

double StopLoss_S = NormalizeDouble(High[1]+ spread,Digits);//NormalizeDouble(High[1]+ spread,Digits)

double TakeProfit_S = NormalizeDouble(Bid-((StopLoss_S-Bid)* RiskRewart),Digits) ;

....

OrderSend(Symbol(),OP_BUY,Lots,Ask,3,StopLoss_B,TakeProfit_B, "PBar",Magik,0,Blue);

....

OrderSend(Symbol(),OP_SELL,Lots,Bid,3,StopLoss_S,TakeProfit_S, "PBar",Magik,0,Red);

The tester shows error 130 - something wrong with TP and SL. I cannot understand what exactly, especially since sometimes it runs fine, and sometimes I get an error.

In general, please help.

 
RichLux:

I am trying to implement the stop loss and take profit in this way:

spread = Ask-Bid;

double StopLoss_B = NormalizeDouble(Low[1]- spread,Digits);//NormalizeDouble(Low[1]- spread,Digits)

double TakeProfit_B = NormalizeDouble(Ask+((Ask-StopLoss_B)* RiskRewart),Digits) ;

double StopLoss_S = NormalizeDouble(High[1]+ spread,Digits);//NormalizeDouble(High[1]+ spread,Digits)

double TakeProfit_S = NormalizeDouble(Bid-((StopLoss_S-Bid)* RiskRewart),Digits) ;

....

OrderSend(Symbol(),OP_BUY,Lots,Ask,3,StopLoss_B,TakeProfit_B, "PBar",Magik,0,Blue);

....

OrderSend(Symbol(),OP_SELL,Lots,Bid,3,StopLoss_S,TakeProfit_S, "PBar",Magik,0,Red);

The tester shows error 130 - something wrong with TP and SL. I cannot understand what exactly, especially since sometimes it runs fine, and sometimes I get an error.

In general, please help.

Maybe sometimes you set too close to the current price, see what the function returns

double stop_level=(double)SymbolInfoInteger(_Symbol,SYMBOL_TRADE_STOPS_LEVEL);

...

 

Forum on Trading, Automated Trading Systems and Strategy Tests

Questions from Beginners MQL4 MT4 MetaTrader 4

Sergey Gritsay, 2017.01.07 18:48

Maybe sometimes you bet too close to the current price, see what the function returns to you

double stop_level=(double)SymbolInfoInteger(_Symbol,SYMBOL_TRADE_STOPS_LEVEL);

...


Thank you for your participation. Didn't figure out how to use the suggested function. But you have encouraged me to learn more about those errors on the chart and understood that the reason is that when a Stop Loss is triggered, but the candle has not closed yet, the EA tries to place a new order, and that is where the error occurs. I have to think how to explain the EA that only one order per candle is needed

 
RichLux:

Thank you for your participation. I haven't figured out how to use the suggested function. But you have encouraged me to learn more about those errors on the chart and understood that the reason is that when a Stop Loss is triggered but the candle has not yet closed the EA tries to place a new order, that is where the error occurs. I have to think how to explain the EA that only one order per candle is needed

If the EA already has an order at the symbol, look at the difference(time of closing the order)-(time of opening the candle), if the difference is less than PeriodSeconds() - do not open a new order.
 

Forum on Trading, Automated Trading Systems and Strategy Tests

Questions from beginners MQL4 MT4 MetaTrader 4

Vitalie Postolache, 2017.01.07 21:23

Watch among the closed orders, if the Expert Advisor has an order on the given symbol, watch the difference(time of closing of the order) -(time of opening of the candle), if the difference is less than PeriodSeconds() - do not open a new order.

Did things a little differently.

New bar function:

bool NewBar()

{

static datetime lastbar = 0;

datetime curbar = Time[0];

if(lastbar != curbar)

{

lastbar = curbar;

return (true);

}

else return(false);

}

and I wrote conditions for opening only if there is a new bar