EA tested worked out great but

Hi guys, i just tried made some EA and when i tried it out on strategy tester, it worked out great, i mean it works, there’s a results of win and losing. However when i tried it on demo account, i left computer on for whole night but my EA doesn’t execute any order at all? Am i missing something here?

FYI : i am converting my regular indicator to EA, and i am using 5 minutes charts. Smiley face already appear on Top right corner. and since i am converting my indicator to EA, it should have some order because my indicator already gave alot signal at night.

Make sure your MT4 options allow Live Trading, and that the little smiley at the upper right corner of a chart the EA is attached to appears.

O.

How often did your EA trade in the backtest, and during what trading hours? Are there any trading conditions that must be met for a trade to be initialized? (aka spread, trending marketing, ect). If no problems there and the perfect conditions existed overnight I’d wonder about my MQL4 code and how it interacts with the broker.

Just throwing some ideas out there, but then again…some of the EA I run dont trade for days at a time…

I did that already

Sent from my iPhone using BabyPips

Yeah there’s some condition for trade to open. Thx i’ll take a look again.

Sent from my iPhone using BabyPips

This is really weird, i am trying to convert my indicator to EA, and my indicator already gave signal to sell but my EA which is suppose to open a trade didn’t do anything. is there anyway to trace the EA, to know what i am missing here?
I am creating EA using EA Builder, is the code generated from there really working?

couple things:

1 - backtesting allows use of Stop and Tp levels when testing, but then when “live” do not allow this /// mine only allows 0.00 for both stop and take profit - try :: allowing opening an order with 0.00 then do an ordermodify next to set your stop and take profit

2- number of digits? (I struggle with this one) so no advice, but something to look at if #1 doesn’t work.

3- convert indicator to EA - maybe wrong folder? inicators are not found in the ‘experts’ folder?

Thanks for the reply, i just email my broker and asked them the condition about their platform, and they reply saying that make sure my ea can work on market execution and do not place SL and TP at ordersend.
So what is that mean about market execution thing? did the ea builder at Expert Advisor Builder for MetaTrader 4 doesn’t execute on market execution?

Hey it worked now, it open a trade after i empty SL and TP.

So now the next question is, is it possible to modify SL and TP after the trade is open? and if yes could anybody share the script please or point me to the right direction?

thanks

Yeah i did it. Just wanna share it, it is possible to modify SL and TP after it open.

Thank you guys

Sent from my iPhone using BabyPips

Whenever you open a trade at ‘[I]Market Execution[/I]’ (ECN broker), it is not possible to enter S/L and T/P right away.
The opened trade has to be modified, in order to add these levels to the position, so all you have to do is make your EA do that … not hard to add this to your code.

It’s good to hear that all seems to be working well now.
Happy trading.

Cheers,
P.

Thanks. But it’s not 100% correct. It could modify the order but sometimes it doesnt modify too. Does the EA execute at the end of bar or beginning of the bar? If thats true then i have to wait for another bar for it to modify the order then?

Sent from my iPhone using BabyPips

I don’t know how you have set up your EA, but it can execute at any time. You definitely do not have to wait for another bar to modify your order … imagine what that would mean, if your EA traded on H4 or D1 timeframes.
As soon as a position has been opened, S/L and T/P can be modified, no matter the bar status.

However you must observe the minimum distance between current market price and S/L & T/P, as specified by your broker. If the values your EA attempts to set are too close to current price, the S/L or T/P will not be modified.

P.

Isn’t it depends on signal mode? My signal mode is not every tick but complete bar.
This is the code for buying, do you think it will work?

Ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, StopLossLevel, TakeProfitLevel, "Buy(#" + MagicNumber + ")", MagicNumber, 0, Lime);
if(Ticket > 0) {
            if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) {            
				    Print("BUY order opened : ", OrderOpenPrice());
                if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Open Buy");
                StopLossLevel = Bid + SL * Point; 
                TakeProfitLevel = Bid - TP * Point;
                OrderModify(OrderTicket(), OrderOpenPrice(), StopLossLevel, TakeProfitLevel, 0, MediumSeaGreen);               
			} else {
				Print("Error opening BUY order : ", GetLastError());
			}

Okay so the code i put above doesn’t work, i dont know why, but maybe it can’t modify right after open, so i edit my program like below but still doesn’t work too. so can anybody tell me why it doesn’t work? is it the if ((OrderStopLoss() == 0.0) && (OrderTakeProfit() == 0.0)), maybe i should do this instead if ((OrderStopLoss() == 0) && (OrderTakeProfit() == 0))? or are both the same? i know that the trailing is working, and some of order modify on buying is working too thats why i said sometimes it work, sometimes it doesn’t, so i’m clueless here guys…

if (EachTickMode && Bars != BarCount) TickCheck = False;
   Total = OrdersTotal();
   Order = SIGNAL_NONE;

   //Check position
   bool IsTrade = False;

   for (int i = 0; i < Total; i ++) {
      OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
      if(OrderType() <= OP_SELL &&  OrderSymbol() == Symbol()) {
         if (Total < MaxOrders) { IsTrade = False; }
         else IsTrade = True;
            
         if(OrderType() == OP_BUY) {

            //Modifying SL and TP for BUY ORDER
            if ((OrderStopLoss() == 0.0) && (OrderTakeProfit() == 0.0)) {
               StopLossLevel = Bid + SL * Point; 
               TakeProfitLevel = Bid - TP * Point;
               OrderModify(OrderTicket(), OrderOpenPrice(), StopLossLevel, TakeProfitLevel, 0, MediumSeaGreen);               
            }
            //Trailing stop
            if(UseTrailingStop && Trail > 0) {                 
               if(Bid - OrderOpenPrice() > Point * Trail) { 
                  if(OrderStopLoss() < Bid - Point * Trail) {
                     OrderModify(OrderTicket(), OrderOpenPrice(), Bid - Point * Trail, OrderTakeProfit(), 0, MediumSeaGreen);
                     if (!EachTickMode) BarCount = Bars;
//                        continue;
                  }
               }
            }                        
         } else {

            //Modidying SL and TP SELL ORDER
            if ((OrderStopLoss() == 0.0) && (OrderTakeProfit() == 0.0)) {
               StopLossLevel = Ask - SL * Point; 
               TakeProfitLevel = Ask + TP * Point;
               OrderModify(OrderTicket(), OrderOpenPrice(), StopLossLevel, TakeProfitLevel, 0, DarkOrange);
            }
            //Trailing stop
            if(UseTrailingStop && Trail > 0) {
               if((OrderOpenPrice() - Ask) > (Point * Trail)) {
                  if((OrderStopLoss() > (Ask + Point * Trail)) || (OrderStopLoss() == 0.0)) {
                     OrderModify(OrderTicket(), OrderOpenPrice(), Ask + Point * Trail, OrderTakeProfit(), 0, DarkOrange);
                     if (!EachTickMode) BarCount = Bars;
//                     continue;
                  }
               }
            }                      
         }
      }
   }

I found the culprit, it’s the point value, my SL and TP after calculating is too small, thats why it doesn’t execute the ordermodify function. so just to be clear what is the return value for point exactly? it’s different for every currency right? like for eurusd is 0.00001, usdjpy is 0.001. so how to solve this? don’t tell me i have to create different EA for every currency.

Unfortunately I don’t know enough about coding to give any advice here.

Regarding 5-digit and 3-digit currencies, I’m running an EA that handles both, although I don’t know how it is done.
I have seen indicator code using ‘IF’ function to handle 4/5-digit brokers, so I guess it could work along those lines … but I’m too noob at coding to be sure.

The best thing would be to register with MQL4: automated trading forum, I guess … there are many really good coders there who can advise you, and the website has extensive MQL4 documentation and courses, too.

Cheers,
P.

Thank you guys for your input, i finnaly finished it, it worked out great, modify, trailing, everything working…

Once again thank you :59::slight_smile: