• Welcome back! Thank you for being a part of this Traders Community. Let's discuss and share :)
    Selamat datang kembali! Trimakasih telah menjadi bagian dari Komunitas Trader ini. Mari berdiskusi dan berbagi :)

Suggestion Monkey Pips ( from the original author )

case OP_BUY:
if( Bid - OrderOpenPrice() + commissionPoints > Trailing * Point ){
if( OrderStopLoss() == 0.0 || Bid - OrderStopLoss() > Trailing * Point )
if( NormalizeDouble( Bid - ( Trailing * Point ), Digits ) != OrderStopLoss() )
r = OrderModify( OrderTicket(), OrderOpenPrice(), NormalizeDouble( Bid - ( Trailing * Point ), Digits ), OrderTakeProfit(), 0 );
} else {
if( AccountEquity() > max || AccountEquity() / AccountBalance() < ( double ) MaxDrawdown / 100 ){
if( rateChangeBid < -VelocityStop * Point && Bid < OrderOpenPrice() - ( VelocityTrigger * Point ) )
if( OrderStopLoss() == 0.0 || Bid - OrderStopLoss() > ( Trailing * Point * TrailingLoss ) )
if( NormalizeDouble( Bid - ( Trailing * Point * TrailingLoss ), Digits ) != OrderStopLoss() )
r = OrderModify( OrderTicket(), OrderOpenPrice(), NormalizeDouble( Bid - ( Trailing * Point * TrailingLoss ), Digits ), OrderTakeProfit(), 0 );
}
}
Hi please any one help me in convert the above mq4 code to mq5
 
The conversion seems to be very difficult and almost impossible when you think that only one error could break/distort the correct results...
Would you be able to detect it?
 
Many thanks arby1108 for your contribution of efforts. in this the problem I found out is that. by using below header files we are not getting the same results with "every tick" and "Every tick based on real ticks" .
#include <Trade\PositionInfo.mqh>
#include <Trade\OrderInfo.mqh>
//#include <Trade\TradeAsync.mqh>
#include <Trade\Trade.mqh>
#include <Trade\SymbolInfo.mqh>
#include <Trade\AccountInfo.mqh>

when we back test with "every tick" we are getting good results. but when we do back test with "Every tick based on real ticks" , results are not the same as results as "every tick". I found that if we make the ea with out using the above header files we are getting almost same results with both "Every tick based on real ticks" and "every tick".
i tried with below code. but it is not modifying the SL as expected (We are getting "Invalid Stops" error). please check the below code and check if you can make any changes to it

MqlTick latest_price; // To be used for getting recent/latest price quotes
MqlTradeRequest request = {0};
MqlTradeResult result ={0};

{
if(AccountInfoDouble(ACCOUNT_EQUITY) > max || AccountInfoDouble(ACCOUNT_EQUITY) / AccountInfoDouble(ACCOUNT_BALANCE) < (double) MaxDrawdown / 100)
{
if(rateChangeBid < -VelocityStop * SymbolInfoDouble(_Symbol, SYMBOL_POINT) && latest_price.bid < PositionGetDouble(POSITION_PRICE_OPEN) - (VelocityTrigger * SymbolInfoDouble(_Symbol, SYMBOL_POINT)))
{
if(PositionGetDouble(POSITION_SL) == 0.0 || latest_price.bid - PositionGetDouble(POSITION_SL) > (trail * SymbolInfoDouble(_Symbol, SYMBOL_POINT) * trailLoss))
{
if(NormalizeDouble(latest_price.bid - (trail * SymbolInfoDouble(_Symbol, SYMBOL_POINT) * trailLoss), (int)SymbolInfoInteger(_Symbol, SYMBOL_DIGITS)) != PositionGetDouble(POSITION_SL))
{
// SL1= NormalizeDouble(Bid - (trail * SymbolInfoDouble(_Symbol, SYMBOL_POINT) * trailLoss), (int)SymbolInfoInteger(_Symbol, SYMBOL_DIGITS));
//====================================
ZeroMemory(request);
ZeroMemory(result);
request.action = TRADE_ACTION_SLTP;
// request.order = ticket;
request.position = PosistionTicket;
request.symbol = _Symbol; // symbol
request.sl = NormalizeDouble(latest_price.bid - (trail * SymbolInfoDouble(_Symbol, SYMBOL_POINT) * trailLoss), (int)SymbolInfoInteger(_Symbol, SYMBOL_DIGITS));
request.tp = PositionGetDouble(POSITION_TP);
for(i=0; i<3; i++)
{
result.retcode=OrderSend(request,result);
if(result.retcode==10009 || result.retcode==10008) // request executed
Print("Moving Stop Loss of Buy position #",request.order);
else
{
Print(ResultRetcodeDescription(result.retcode));
return;
}
}
return;
//====================================


}
 
arby1108, you too might have observed that with your MT5 ea, we are getting the good results when we do back test with "Every tick based on real ticks".
 
sorry there is a typo "we are NOT getting the good results when we do back test with "Every tick based on real ticks""
 
Many thanks arby1108 for your contribution of efforts. in this the problem I found out is that. by using below header files we .....
i tried with below code. but it is not modifying the SL as expected (We are getting "Invalid Stops" error). please check the below code and check if you can make any changes to it

MqlTick latest_price; // To be used for getting recent/latest price quotes
MqlTradeRequest request = {0};
MqlTradeResult result ={0};

{
if(AccountInfoDouble(ACCOUNT_EQUITY) > max || AccountInfoDouble(ACCOUNT_EQUITY) / AccountInfoDouble(ACCOUNT_BALANCE) < (double) MaxDrawdown / 100)
{
if(rateChangeBid < -VelocityStop * SymbolInfoDouble(_Symbol, SYMBOL_POINT) && latest_price.bid < PositionGetDouble(POSITION_PRICE_OPEN) - (VelocityTrigger * SymbolInfoDouble(_Symbol, SYMBOL_POINT)))
{
if(PositionGetDouble(POSITION_SL) == 0.0 || latest_price.bid - PositionGetDouble(POSITION_SL) > (trail * SymbolInfoDouble(_Symbol, SYMBOL_POINT) * trailLoss))
{
if(NormalizeDouble(latest_price.bid - (trail * SymbolInfoDouble(_Symbol, SYMBOL_POINT) * trailLoss), (int)SymbolInfoInteger(_Symbol, SYMBOL_DIGITS)) != PositionGetDouble(POSITION_SL))
{
// SL1= NormalizeDouble(Bid - (trail * SymbolInfoDouble(_Symbol, SYMBOL_POINT) * trailLoss), (int)SymbolInfoInteger(_Symbol, SYMBOL_DIGITS));
//====================================
ZeroMemory(request);
ZeroMemory(result);
request.action = TRADE_ACTION_SLTP;
// request.order = ticket;
request.position = PosistionTicket;
request.symbol = _Symbol; // symbol
request.sl = NormalizeDouble(latest_price.bid - (trail * SymbolInfoDouble(_Symbol, SYMBOL_POINT) * trailLoss), (int)SymbolInfoInteger(_Symbol, SYMBOL_DIGITS));
request.tp = PositionGetDouble(POSITION_TP);
for(i=0; i:h:; i++)
{
result.retcode=OrderSend(request,result);
if(result.retcode==10009 || result.retcode==10008) // request executed
Print("Moving Stop Loss of Buy position #",request.order);
else
{
Print(ResultRetcodeDescription(result.retcode));
return;
}
}
return;
//====================================


}

Brunda,
did you check the value of request.sl when you modify the stop loss?
Which value has it?
 
how to do back test with "fixed spread" in MT5?
This could be a way.
I never tried it
  • Create a custom symbol
  • Export to a .csv original symbol data (Bars)
  • Edit the spread (excel +++) to the fixed one (if it's floating, choose a spread higher than the average one)
  • Reimport the datas from the file to the custom symbol created previously.
 
I think you should add the call of the SymbolInfoTick() function after "MqlTick latest_price;" line

MqlTick latest_price; // To be used for getting recent/latest price quotes
SymbolInfoTick(Symbol(),latest_price)

Or better you should check the calling in this way:

//---
if(!SymbolInfoTick(Symbol(),last_tick))
Print("SymbolInfoTick() failed, error = ",GetLastError());
//---
 
Sorry,
in your code you have to check the calling in this way:
//---
if(!SymbolInfoTick(Symbol(),lastest_price))
Print("SymbolInfoTick() failed, error = ",GetLastError());
//---
 
Hi Every one & Brunda,

I think MP EA behaves very similar to a tick scalper. I believe you can improve the trade winning % by adding;

1) a trend filter with optimizable time frame period/trend strength etc.

2) trial with a KDJ or TEMA indicator filter with optimizable paramaters.

3) a trading hour filter

4) basic martingale option

5) an averaging/basket trading option with optimizable paramaters may help

4) a "Reverse" trade option , i.e. SELL a Buy signal & vice versa

Trevor has been kind enough to email me the source code of a number of versions his MT5 MP EAs, if you would like to work on them let me know.
Email: [email protected]

Best regards,
Trung.
 
below attached are the diff between Every Tick and Every Tick based on real ticks.
there appears to be primarily 2 reasons to opt MT5 by Trover
1. to excecute the multiple trades asynchronously in the market with out waiting for confirmation from broker.
2. Since the tick data is not at all reliable/accurate data to test with MT4. because of this BT is misleading us with false impression (with MP even one trade did not went to loss in the last year test with USDJPY pair). thanks for advise of Trung ,Mxmptr and arby1108. a little bit improvement I can see with every tick based on real tick in mt5
 

Attachments

  • everyTick.png
    everyTick.png
    21.3 KB · Views: 194
  • EveryTickBasedOnRealTicks.png
    EveryTickBasedOnRealTicks.png
    28.1 KB · Views: 200
Sorry,
in your code you have to check the calling in this way:
//---
if(!SymbolInfoTick(Symbol(),lastest_price))
Print("SymbolInfoTick() failed, error = ",GetLastError());
//---
Many thanks for your advise Mxmptr. really it made difference. attached is the test result with "Every tick based on real ticks" another small progress.
 

Attachments

  • GBPUSD_GRAPH_2019.10.23.png
    GBPUSD_GRAPH_2019.10.23.png
    18.4 KB · Views: 197
Many thanks for your advise Mxmptr. really it made difference. attached is the test result with "Every tick based on real ticks" another small progress.
which version of MP did you convert in MT5?
I'll try to convert it and check if I can do other improvement.
 
you need to use OrderSendAsync(request,result); function to place the orders not OrderSend() . don't use any header files to place/modify delete the orders/positions. rest all same as mq4. I don't know the reason why I am not getting same results with using header files and witout using header files.
 
please any one run the attached ea with any broker, in live with 0.01 lot with $20 deposit, with suitable any pair after back testing with Modeling as "Every tick based on real tick"
 

Attachments

Back
Top