Why does not pending orders respond to expiry in backtesting (MT4) ?

Back to topics list To post a new topic, please log in or register
avatar
3
martinredgard 2015.08.19 14:05
 

Hi,

I wonder if someone has encountered the same issue I'm currently battling (see topic).

Should not this code suffice as to delete orders pending? Have not tried it LIVE, I'm talking back test. Still, I believe this code should do it;

Ticket = OrderSend(Symbol(), OP_BUYLIMIT, 1, Ask - (Point * 50), 3, 0, Ask - (50 * Point), "Sell(#" + MagicNumber + ")", MagicNumber, TimeCurrent()+7200, DeepPink);

 

Can someone please feedback this? Going mad trying to solve it :)

Best,

Martin 

avatar
12985
WHRoeder 2015.08.19 14:52 #
 
  1. Don't paste code
    Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. Check your return codes (OrderSend) and find out why. What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
  3. How can your TP be equal to your entry price?
  4. Some brokers do not allow expirations.

    147

    ERR_TRADE_EXPIRATION_DENIED

    Expirations are denied by broker

avatar
3
martinredgard 2015.08.19 15:52 #
 
WHRoeder:

  1. Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. Check your return codes (OrderSend) and find out why. What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
  3. How can your TP be equal to your entry price?
  4. Some brokers do not allow expirations.

    147

    ERR_TRADE_EXPIRATION_DENIED

    Expirations are denied by broker

WHRoeder,

Thank you for responding.

I edited the code to:

        Ticket = OrderSend(Symbol(), OP_SELLLIMIT, 1, Bid + (Point * 50), 3, 0, 0, "Sell(#" + MagicNumber + ")", MagicNumber, TimeCurrent()+3600, DeepPink);

 I also asked broker, no limits for such order apply. When placed "live" on paper trading account it auto-sets the expiry to 1 week. This is very odd considering OANDA claims no limit is in effect. 

Any other thoughts given the above?

Attached whole EA also 

Thank you very much for taking the time :)

Best,

Martin 

Attached files:
  new4.mq4  (13.22 KB)
avatar
12985
WHRoeder 2015.08.19 20:09 #
 
  1. //| This MQL is generated by Expert Advisor Builder                  |
    
    • We hate EA builder
    • You couldn't be bothered to learn mql4, therefor there is no common language for us to communicate.
    • There are only two choices: learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem, but we are not going to debug your hundreds lines of code.
    • EA builder makes bad code counting up while closing multiple orders.
    • EA builder makes bad code Bars is unreliable (max bars on chart) volume is unreliable (miss ticks) Always use time
    • EA builder makes bad code Not adjusting for 4/5 digit brokers
    • EA builder makes bad code not adjusting for ECN brokers.
    • EA builder makes bad code not checking return codes.
    • EATree uses objects on chart to save values - not persistent storage (files or GV+Flush.) No recovery (crash/reboot.)
  2.   double bid = MarketInfo("EURUSD", MODE_BID);
      double ask = MarketInfo("EURUSD", MODE_ASK);
    
    If you aren't on the EURUSD, your EA is broken.
  3. noOrdersInLastHour()
    Only checks for deleted/expired limit orders. Orders that open are Buy/Sells.
  4. OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, MediumSeaGreen);

    OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(OrderOpenPrice() + SetFixedSLValueAt * Point, 5), OrderTakeProfit(), 0, MediumSeaGreen);

    OrderModify(OrderTicket(), OrderOpenPrice(), Bid - Point * TrailingDistance, OrderTakeProfit(), 0, MediumSeaGreen);

    OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(OrderOpenPrice() - SetFixedSLValueAt * Point, 5), OrderTakeProfit(), 0, MediumSeaGreen);

    OrderModify(OrderTicket(), OrderOpenPrice(), Ask + Point * TrailingDistance, OrderTakeProfit(), 0, DarkOrange);

    Ticket = OrderSend(Symbol(), OP_SELLLIMIT, 1, Bid + (Point * 50), 3, 0, 0, "Sell(#" + MagicNumber + ")", MagicNumber, TimeCurrent()+604800, DeepPink);
    if(Ticket > 0) {
       :
    }
    What part of "Check your return codes" was unclear?
avatar
3
martinredgard 2015.08.20 12:01 #
 
WHRoeder:
    • We hate EA builder
    • You couldn't be bothered to learn mql4, therefor there is no common language for us to communicate.
    • There are only two choices: learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem, but we are not going to debug your hundreds lines of code.
    • EA builder makes bad code counting up while closing multiple orders.
    • EA builder makes bad code Bars is unreliable (max bars on chart) volume is unreliable (miss ticks) Always use time
    • EA builder makes bad code Not adjusting for 4/5 digit brokers
    • EA builder makes bad code not adjusting for ECN brokers.
    • EA builder makes bad code not checking return codes.
    • EATree uses objects on chart to save values - not persistent storage (files or GV+Flush.) No recovery (crash/reboot.)
  1. If you aren't on the EURUSD, your EA is broken.
  2. Only checks for deleted/expired limit orders. Orders that open are Buy/Sells.
  3. OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, MediumSeaGreen);

    OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(OrderOpenPrice() + SetFixedSLValueAt * Point, 5), OrderTakeProfit(), 0, MediumSeaGreen);

    OrderModify(OrderTicket(), OrderOpenPrice(), Bid - Point * TrailingDistance, OrderTakeProfit(), 0, MediumSeaGreen);

    OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(OrderOpenPrice() - SetFixedSLValueAt * Point, 5), OrderTakeProfit(), 0, MediumSeaGreen);

    OrderModify(OrderTicket(), OrderOpenPrice(), Ask + Point * TrailingDistance, OrderTakeProfit(), 0, DarkOrange);

    Ticket = OrderSend(Symbol(), OP_SELLLIMIT, 1, Bid + (Point * 50), 3, 0, 0, "Sell(#" + MagicNumber + ")", MagicNumber, TimeCurrent()+604800, DeepPink);
    if(Ticket > 0) {
       :
    }
    What part of "Check your return codes" was unclear?

I'm pretty sure you are misreading my intentions. I wan't to learn how to code and there for I am in the process of doing just that. Both the spreadfilter and the "noorderinlasthour" functions are written by me, as is a lot of the EA even if the total structure is EA builder, as a foundation. Sorry if I offended you in any way.

 

Back to topics list  

To add comments, please log in or register