1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. 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 :)
    Dismiss Notice

Suggestion Monkey Pips ( from the original author )

Discussion in 'Expert Advisor atau Robot Forex' started by trevor, 16 May 2018.

  1. lia786

    lia786 Well-Known Member Credit Hunter

    Equity
    Credit
    Ref Point
    5/5,
    This is my review for this thread:
    h
     
  2. brunda

    brunda Member Credit Hunter

    Equity
    Credit
    Ref Point
    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
     
  3. zeon66

    zeon66 New Member

    Equity
    Credit
    Ref Point
    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?
     
  4. arby1108

    arby1108 Member Credit Hunter

    Equity
    Credit
    Ref Point
    Hi, this is my MQL5 version of 3.01.
     

    Attached Files:

    • Winner Winner x 1
  5. brunda

    brunda Member Credit Hunter

    Equity
    Credit
    Ref Point
    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: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;
    //====================================


    }
     
  6. brunda

    brunda Member Credit Hunter

    Equity
    Credit
    Ref Point
    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".
     
  7. brunda

    brunda Member Credit Hunter

    Equity
    Credit
    Ref Point
    sorry there is a typo "we are NOT getting the good results when we do back test with "Every tick based on real ticks""
     
  8. Mxmptr

    Mxmptr New Member

    Equity
    Credit
    Ref Point
    Brunda,
    did you check the value of request.sl when you modify the stop loss?
    Which value has it?
     
  9. brunda

    brunda Member Credit Hunter

    Equity
    Credit
    Ref Point
    how to do back test with "fixed spread" in MT5?
     
  10. Mxmptr

    Mxmptr New Member

    Equity
    Credit
    Ref Point
    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.
     
  11. Mxmptr

    Mxmptr New Member

    Equity
    Credit
    Ref Point
    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());
    //---
     
    • Creative Creative x 1
  12. Mxmptr

    Mxmptr New Member

    Equity
    Credit
    Ref Point
    Sorry,
    in your code you have to check the calling in this way:
    //---
    if(!SymbolInfoTick(Symbol(),lastest_price))
    Print("SymbolInfoTick() failed, error = ",GetLastError());
    //---
     
    • Creative Creative x 1
  13. TN999

    TN999 New Member

    Equity
    Credit
    Ref Point
    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.
     
    • Winner Winner x 1
    • Optimistic Optimistic x 1
  14. brunda

    brunda Member Credit Hunter

    Equity
    Credit
    Ref Point
    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
     

    Attached Files:

    • Informative Informative x 1
  15. brunda

    brunda Member Credit Hunter

    Equity
    Credit
    Ref Point
    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.
     

    Attached Files:

    • Winner Winner x 1
  16. Mxmptr

    Mxmptr New Member

    Equity
    Credit
    Ref Point
    which version of MP did you convert in MT5?
    I'll try to convert it and check if I can do other improvement.
     
    • Optimistic Optimistic x 1
  17. brunda

    brunda Member Credit Hunter

    Equity
    Credit
    Ref Point
    it is the attached version
     

    Attached Files:

    • Useful Useful x 1
  18. brunda

    brunda Member Credit Hunter

    Equity
    Credit
    Ref Point
    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.
     
    • Creative Creative x 1
  19. brunda

    brunda Member Credit Hunter

    Equity
    Credit
    Ref Point
    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"
     

    Attached Files:

    • Like Like x 1
    • Useful Useful x 1
  20. kam2016

    kam2016 Member Credit Hunter

    Equity
    Credit
    Ref Point
    what is trailingloss in input meanings in Mt5 version ?

    is trailingstart in Mt4 ?
     
    • Optimistic Optimistic x 1

Share This Page