Download MetaTrader 5
To add comments, please log in or register
Freelance service: the safe way to order a trading robot. Try it!
RVT101
18
RVT101 2016.08.29 10:52 

I need assistance with a custom function to control pending orders.

My EA works around  placing one pending buy stop order above price and one pending sell stop below price. I have managed to limit the total amount of pending orders to 2 however in some cases the EA would place 2 buy stop orders above the price instead of one pending buys stop and one pending sell stop.

Is it possible to use custom functions to limit buy stop orders to 1 and sell stop orders to 1 to overcome the problem?

Keith Watford
Moderator
7899
Keith Watford 2016.08.29 11:02  

Yes, it is possible.

You will need to show your code to get any advice though.

RVT101
18
RVT101 2016.08.29 11:35  

Hi GumRai,

Thanks for your reply.

Please see attached.

Keith Watford
Moderator
7899
Keith Watford 2016.08.29 11:48  

This is a forum that is mainly coders helping coders to learn.

Code that is generated by an EA builder is not likely to find many people willing to respond as it can be quite time consuming to go through the code. Then you are unlikely to understand unless you have at least studied mql4 for a while.

RVT101
18
RVT101 2016.08.29 11:53  
No worries thanks for the effort GumiRai
whroeder1
13607
whroeder1 2016.08.29 12:11  
    • 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. double MM_Size(){ //martingale / anti-martingale
      :
       if(SelectLastHistoryTrade())
    
    Martingale, guaranteed to blow your account. No recovery on restart. Assume history is ordered, it's not. Could EA Really Live By Order_History Alone? (ubzen) - MQL4 forum
  2.   if(TradesCount(OP_BUY) + TradesCount(OP_SELL) == 0 //Open Trades is equal to fixed value
       && Bid > iMA(NULL, PERIOD_CURRENT, 13, 0, MODE_EMA, PRICE_CLOSE, 0) //Price > Moving Average
       && iRSI(NULL, PERIOD_CURRENT, 50, PRICE_CLOSE, 0) > 52 //Relative Strength Index > fixed value
       ){
          :
             ticket = myOrderSend(OP_SELLSTOP, price, MM_Size(), ""); //pending order at Price - fixed value
     
    If you have no active trades place a pending order. Next tick, it hasn't opened yet, no active trades, place another pending order...
RVT101
18
RVT101 2016.08.29 12:41  

Hi WHRoeder,

I fully agree with the fact that EA builder is clearly unreliable, something I was not aware of when I started out a few month's ago.

I have however started teaching myself MQL 4 however unfortunately for me I am VERY much a newbie when it comes to coding and as I am already using the trading system I created in EA builder that I am by no means capable of recreating myself at this point I thought someone would perhaps be willing to assist me in finding the problem that I have been unable to fix myself after many hours of trying and lots of frustration.

Thanks for the feedback though, I am sure in time I will be at a level that will allow me to fully code the system myself or at the very least fix the current problem until I am more proficient at programming.

Sure I will have much to learn for the group as time goes on. 

Keith Watford
Moderator
7899
Keith Watford 2016.08.29 13:18  

Well, if you are learning mql4, you should work through the code and try to fathom out what it is doing.

if(TradesCount(OP_BUY) + TradesCount(OP_SELL) == 0

Checks for OP_BUY and OP_SELL, shouldn't it also check if there is also a pending order open of the type that you want to place? That could be why you are getting 2 pendings of the same type.

I have not read through all of the code, so I can't be sure that the check is made somewhere else in the code.

RVT101
18
RVT101 2016.08.29 13:40  

that is a good point,

Thank you GumRai, I will work on this further think you have a very valid point.

Thanks for your assistance I appreciate it. 

RVT101
18
RVT101 2016.08.29 14:22  

GumRai,

You where correct, I managed to track down the problem as you suggested and the EA is now working just the way I wanted it to.

Thank you for your assistance, really helped allot.

Cheers 

/
To add comments, please log in or register