help tweak the indicator - can't get a handle on the last bar!
The indicator considers a series of continuous wins for binary options, taking into account that the bet will be made every 2 bars (ie, after one - win/loss, wait for the current bar), the external variable is a price analysis of the previous bar in an upward or downward price
I have a feeling it works, but online the last bar is not considered correctly, and as a consequence if I place the indicator on M1 the data from the history will be correct, but everything online is not calculated correctly, the code:
Задавайте вопросы по техническому анализу, обсуждайте торговые системы и улучшайте свои навыки программирования торговых стратегий на языке MQL5. Общайтесь и обменивайтесь опытом на форуме с трейдерами всего мира и помогайте ответами новичкам — наше сообщество развивается вместе с вами. Ошибки, баги, вопросы Ошибка после команды CopyClose...
yur4ik: Hello! Please help me with the signals module to close positions. What am I doing wrong?
Your file is the SIGNAL module. In the Expert Advisor system, it is integrated in the same way as the USER indicator's SIGNALS module. In other words, the signals generated by your module have a WEIGHT, and it may happen that this weight is not enough to trigger the signal.
You need to think about the best way to do the closing in your case. Perhaps you should not do it in the signal module
Your file is the SIGNAL module. In the Expert Advisor system, it is integrated in the same way as the USER indicator's SIGNALS module. In other words, the signals generated by your module have a WEIGHT, and it may happen that this weight is not enough to trigger the signal.
You need to think about the best way to do the closing in your case. You may not want to do it in a signal module.
I would like it to be done as a signals module that could be collected by an Expert Advisor generator. At the moment when the module is to be triggered, LongCondition() and ShortCondition() in the second EA module return zero values - i.e. weight=0, I understand it correctly? Accordingly, the weight of this module must outweigh the signal, but it does not work. In CheckCloseLong() and CheckCloseShort(), I have inserted the Print("-------------"); and Print(time_GMT_DST()); which, during normal module operation, should make appropriate entries in the log upon receipt of each tick. The entries are not made; CheckCloseLong() and CheckCloseShort() are not called. What's the catch?
I would like it to be in the form of a signals module, so that it would be possible to assemble through the EA generator. At the moment when the module is to be triggered, LongCondition() and ShortCondition() in the second module of the EA return zero values - i.e. weight=0, I understand it correctly? Accordingly, the weight of this module must outweigh the signal, but it does not work. In CheckCloseLong() and CheckCloseShort(), I have inserted the Print("-------------"); and Print(time_GMT_DST()); which, during normal module operation, should make appropriate entries in the log upon receipt of each tick. The entries are not made; CheckCloseLong() and CheckCloseShort() are not called. What's the catch?
I'm certainly a clumsy explanation, but I'm just learning
Use methods
//--- methods of checking if the market models are formedvirtualint LongCondition(void);
virtualint ShortCondition(void);
Instead of their CheckCloseLong and CheckCloseShort.
Hello, can you tell me how to make a counter for losing trades? The Expert Advisor analyses the last trade on the history - if it is unprofitable, then it adds +1 to the variable, which will be the number of consecutive losing trades.
As soon as a profitable trade comes in - the variable needs to be reset to zero.
Hello, could you please advise how to make a counter for losing trades? The Expert Advisor analyzes the last trade on the history - if it is losing, then it adds +1 to the variable, which will be the number of consecutive losing trades.
As soon as a profitable trade comes, the variable must be zeroed.
We can refuse from working with trading history and work only with OnTradeTransaction() - there we will catch a deal of type "OUT" - i.e. it will be the position closing. Once this trade is found - we determine whether it was profitable or unprofitable. Respectively, the counter"losses" should be reset or increased.
//+------------------------------------------------------------------+//| TradeTransaction function |//+------------------------------------------------------------------+voidOnTradeTransaction(constMqlTradeTransaction &trans,
constMqlTradeRequest &request,
constMqlTradeResult &result)
{
//--- get transaction type as enumeration value ENUM_TRADE_TRANSACTION_TYPE type=trans.type;
//--- if transaction is result of addition of the transaction in historyif(type==TRADE_TRANSACTION_DEAL_ADD)
{
long deal_ticket =0;
long deal_order =0;
long deal_time =0;
long deal_time_msc =0;
long deal_type =-1;
long deal_entry =-1;
long deal_magic =0;
long deal_reason =-1;
long deal_position_id =0;
double deal_volume =0.0;
double deal_price =0.0;
double deal_commission =0.0;
double deal_swap =0.0;
double deal_profit =0.0;
string deal_symbol ="";
string deal_comment ="";
string deal_external_id ="";
if(HistoryDealSelect(trans.deal))
{
deal_ticket =HistoryDealGetInteger(trans.deal,DEAL_TICKET);
deal_order =HistoryDealGetInteger(trans.deal,DEAL_ORDER);
deal_time =HistoryDealGetInteger(trans.deal,DEAL_TIME);
deal_time_msc =HistoryDealGetInteger(trans.deal,DEAL_TIME_MSC);
deal_type =HistoryDealGetInteger(trans.deal,DEAL_TYPE);
deal_entry =HistoryDealGetInteger(trans.deal,DEAL_ENTRY);
deal_magic =HistoryDealGetInteger(trans.deal,DEAL_MAGIC);
deal_reason =HistoryDealGetInteger(trans.deal,DEAL_REASON);
deal_position_id =HistoryDealGetInteger(trans.deal,DEAL_POSITION_ID);
deal_volume =HistoryDealGetDouble(trans.deal,DEAL_VOLUME);
deal_price =HistoryDealGetDouble(trans.deal,DEAL_PRICE);
deal_commission =HistoryDealGetDouble(trans.deal,DEAL_COMMISSION);
deal_swap =HistoryDealGetDouble(trans.deal,DEAL_SWAP);
deal_profit =HistoryDealGetDouble(trans.deal,DEAL_PROFIT);
deal_symbol =HistoryDealGetString(trans.deal,DEAL_SYMBOL);
deal_comment =HistoryDealGetString(trans.deal,DEAL_COMMENT);
deal_external_id =HistoryDealGetString(trans.deal,DEAL_EXTERNAL_ID);
}
elsereturn;
if(deal_symbol==Symbol() && deal_magic==m_magic)
if(deal_entry==DEAL_ENTRY_OUT)
{
if(deal_commission+deal_swap+deal_profit>0)
{
losses=0;
}
else
{
losses++;
}
}
}
}
And the check in the trading history should be done in OnInit() - once at start of the Expert Advisor.
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.
help tweak the indicator - can't get a handle on the last bar!
The indicator considers a series of continuous wins for binary options, taking into account that the bet will be made every 2 bars (ie, after one - win/loss, wait for the current bar), the external variable is a price analysis of the previous bar in an upward or downward price
I have a feeling it works, but online the last bar is not considered correctly, and as a consequence if I place the indicator on M1 the data from the history will be correct, but everything online is not calculated correctly, the code:
thanks in advance!
Hello! Please help me with the signals module to close positions. What am I doing wrong?
Your file is the SIGNAL module. In the Expert Advisor system, it is integrated in the same way as the USER indicator's SIGNALS module. In other words, the signals generated by your module have a WEIGHT, and it may happen that this weight is not enough to trigger the signal.
You need to think about the best way to do the closing in your case. Perhaps you should not do it in the signal module
Your file is the SIGNAL module. In the Expert Advisor system, it is integrated in the same way as the USER indicator's SIGNALS module. In other words, the signals generated by your module have a WEIGHT, and it may happen that this weight is not enough to trigger the signal.
You need to think about the best way to do the closing in your case. You may not want to do it in a signal module.
I would like it to be done as a signals module that could be collected by an Expert Advisor generator. At the moment when the module is to be triggered, LongCondition() and ShortCondition() in the second EA module return zero values - i.e. weight=0, I understand it correctly? Accordingly, the weight of this module must outweigh the signal, but it does not work. In CheckCloseLong() and CheckCloseShort(), I have inserted the Print("-------------"); and Print(time_GMT_DST()); which, during normal module operation, should make appropriate entries in the log upon receipt of each tick. The entries are not made; CheckCloseLong() and CheckCloseShort() are not called. What's the catch?
I'm clumsy, of course, but I'm just learning.I would like it to be in the form of a signals module, so that it would be possible to assemble through the EA generator. At the moment when the module is to be triggered, LongCondition() and ShortCondition() in the second module of the EA return zero values - i.e. weight=0, I understand it correctly? Accordingly, the weight of this module must outweigh the signal, but it does not work. In CheckCloseLong() and CheckCloseShort(), I have inserted the Print("-------------"); and Print(time_GMT_DST()); which, during normal module operation, should make appropriate entries in the log upon receipt of each tick. The entries are not made; CheckCloseLong() and CheckCloseShort() are not called. What's the catch?
I'm certainly a clumsy explanation, but I'm just learningUse methods
Instead of their CheckCloseLong and CheckCloseShort.
Thank you.
Hello, can you tell me how to make a counter for losing trades?
The Expert Advisor analyses the last trade on the history - if it is unprofitable, then it adds +1 to the variable, which will be the number of consecutive losing trades.
As soon as a profitable trade comes in - the variable needs to be reset to zero.
Hello, could you please advise how to make a counter for losing trades?
The Expert Advisor analyzes the last trade on the history - if it is losing, then it adds +1 to the variable, which will be the number of consecutive losing trades.
As soon as a profitable trade comes, the variable must be zeroed.
We can refuse from working with trading history and work only with OnTradeTransaction() - there we will catch a deal of type "OUT" - i.e. it will be the position closing. Once this trade is found - we determine whether it was profitable or unprofitable. Respectively, the counter"losses" should be reset or increased.
And the check in the trading history should be done in OnInit() - once at start of the Expert Advisor.Hi all,
Can you tell me how I can programmatically clear the EA log before displaying information in it :?
Only through Win API?
Thank you!
Hi all,
Could you tell me how to programmatically clear the EA log before displaying information in it :?
Only through Win API?
Thank you!