Enivid

Administrator
Staff member
Nov 30, 2008
19,240
1,507
144
Odesa
www.earnforex.com
You said that you want that price feature instead of time condition. OK, I will try to combine those two, but I cannot promise anything.

instead of time, just use an adjustable price function.

Also, NYear, NMonth, NDay, NHour and NMin...also SecBPO should not be eliminated. Timing is really important.

By the way, what's the point in SecBPO in this price-trigger EA if you can just set NYear, NMonth, NDay, NHour and NMin earlier? Or am I missing something?
 

amsteronline

Master Trader
Jul 11, 2012
92
1
64
You said that you want that price feature instead of time condition. OK, I will try to combine those two, but I cannot promise anything.





By the way, what's the point in SecBPO in this price-trigger EA if you can just set NYear, NMonth, NDay, NHour and NMin earlier? Or am I missing something?


SecBPO is very important in order to guarantee that pending orders will be placed from the desired time (let's say from 8am) to the desired price. So what the ea will do is start placing pending orders at let's say 8 o'clock and and continuously modify those orders until the price is hit. So, the time becomes the starting point for the pending orders and the when the price is hit, they will stay at that point until "pointsaway" is hit to buy or sell...

Of course this function cannot be called SecBPO, since we don't know how many seconnds it will take from time to price, it is just based on that model...It should be called something like Time-to-Price BPO, because it will keep modifying pending orders until price is hit! By the way, this function would be the key to the whole system to work perfectly and profitably!

On second thought, so I guess you are right, SecBPO does not need to be in the code, but I just want you to get a clearer picture of how the ea should work. "time-to-price BPO is simply my way to explain how the system should work, once time is set, and price is set, the ea should do the rest.
 
Last edited:

amsteronline

Master Trader
Jul 11, 2012
92
1
64
Now I am confused. Could you write a step-by-step algorithm the new EA should follow? It looks like I had a very different picture in my mind when I started modifying the EA.

Forget about Time-to-Price BPO, function. I got confused when I was trying to discard SecBPO. It is my way to explain how the ea should work.

So the main functions should be:

PointsAway
TP
SL
NHour
NMin
NPrice

SO how it works:

1.Place pending orders at X time
2. a. keep modifying orders until X Price
2. b. When X price is hit, stop modifying

That's it, plain and simple.
 

amsteronline

Master Trader
Jul 11, 2012
92
1
64
We have a problem. I have attached the picture as well, but it seems like the ea does not modify pending orders in reality only in the corner it shows like it does. If you also try it out, you will see what I mean. And SL and Pointsaway needs to be added as well.
 

Attachments

  • pic.png
    pic.png
    49.6 KB · Views: 29
Last edited:

Enivid

Administrator
Staff member
Nov 30, 2008
19,240
1,507
144
Odesa
www.earnforex.com
We have a problem. I have attached the picture as well, but it seems like the ea does not modify pending orders in reality only in the corner it shows like it does. If you also try it out, you will see what I mean. And SL and Pointsaway needs to be added as well.

I've just tried it - works fine. Please make sure that you are entering the settings correctly.
 

Attachments

  • amazing.jpg
    amazing.jpg
    417 KB · Views: 226

amsteronline

Master Trader
Jul 11, 2012
92
1
64
Ok, so if I change the SecBPO to let's say 3 hours (10800) and if I set the price to let's say GBPAUD 1.850, and if price is hit at let's say in 2 hours, then the ea will stop modifying orders, correct?

Also, the distance the BuyStop and SellStop orders are from each other appears to be 10 pips by default, same for the StopLoss, they need to be functions that we could change. And do you remember that if we use to put "0" for the day, or hour, it would use the current time? I have that modified ea, the one that also has the PointsAway function and StopLoss, I will attach it here, perhaps it could help you combine the two into one.

I tried it again, If I set the the time to any value, whatever SecBPO might be, if that time passes, the ea will stop modifying orders, so it does not work as we want it to work, yet...

You can test it yourself: pick a pair, set ea to the current time time to start it, and pick any price above or below current price, like let's say 100 pips, so the ea will not hit it (just to test). And wait and see if the ea keeps modifying pending orders until price is hit!
 

Attachments

  • AmazingEA_EveryDay_AnyHour.mq4
    25.2 KB · Views: 32
Last edited:

amsteronline

Master Trader
Jul 11, 2012
92
1
64
Enivid, you are a genius!!!

The ea works perfectly, Just the TP does not need an additional zero for any 5 digit brokers, that's not a big deal.

One last thing, if you could, do you think you could change some settings so if I place a "0" for Day, then it would just use the current day. (so I don't have to adjust the day of the trade every time)

Thanks again, man
 

amsteronline

Master Trader
Jul 11, 2012
92
1
64
Hello Enivid,

Do you think you can add a Close All Open Position at certain time function to this ea. (I will attach the amazing ea here.)

Thank you


*UPDATE, never mind, I got it to work
 

Attachments

  • AmazingEA_EveryDay_AnyHour.mq4
    25.2 KB · Views: 29
Last edited:

amsteronline

Master Trader
Jul 11, 2012
92
1
64
Ok,

So, I added the close all positions to amazing ea, but for some reason, if I set OCO to false it still cancels the other pending order, can you please help me out on this. I will attach the modified version here.

Thanks Enivid

AND theses are the codes that I added:

MQL4:
extern int   CloseHour=7;      
extern int   CloseMinute=0;
extern color clCloseBuy=Blue;   
extern color clCloseSell=Red;
 
      if (Hour()==CloseHour && Minute()>=CloseMinute) {
    for (int ii=OrdersTotal()-1; ii>=0; ii--) {
      if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
        if (OrderSymbol()==Symbol()) {
          if (OrderType()==OP_BUY) {
            OrderClose(OrderTicket(), OrderLots(), Bid, clCloseBuy);
          }
          if (OrderType()==OP_SELL) {
            OrderClose(OrderTicket(), OrderLots(), Ask, clCloseSell);
          }
        }
      }
    }
  }
 

Attachments

  • AmazingEA_EveryDay_AnyHour_AnyMM_CloseAll.mq4
    51.7 KB · Views: 25
Last edited by a moderator:

Enivid

Administrator
Staff member
Nov 30, 2008
19,240
1,507
144
Odesa
www.earnforex.com
In your code:

MQL4:
if (Hour()==CloseHour && Minute()>=CloseMinute) {

should be:

MQL4:
if ((Hour()==CloseHour) && (Minute()>=CloseMinute)) {

MQL4:
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {

should be:

MQL4:
if (OrderSelect(ii, SELECT_BY_POS, MODE_TRADES)) {

As to the OCO... Are you sure it is closed by OCO logic? Because I cannot determine in the code that it would close if OCO is set to false.
 
Last edited: