First deal of my expert

 

Hello everybody. This morning my new expert advisor made his first trade, but I'm thinking it was not a good deal cause it's suposed that the expert has to entry when the blue MA crosses the yellow MA, but I don't see that in the chart... anybody knows some of this?


-

I post the logic:

      //--- Check for SHORT
      if(FastMAprev>SlowMAprev&&FastMAcurr<SlowMAcurr){
         if(Spread<=MaxSpread){
            if(AccountFreeMarginCheck(Symbol(),OP_SELL,LotsOptimized())>=MarketInfo(Symbol(),MODE_MARGINREQUIRED)*LotsOptimized()){
               if(!OrderSend(Symbol(),OP_SELL,LotsOptimized(),Bid,3,ShortSL,ShortTP,BOTNAME,MAGICNUM,0,clrRed)){
                  Print("OrderSend error ",GetLastError());
                  return;
                  }
               }
            else{
               Print("Not enough money for sell ",LotsOptimized()," lots");
               return;
               }
            }
         else{
            Print("Spread is higher than allowed");
            return;
            }
         }
 

First of all it looks like it may have crossed this morning, can't really tell from the image


Also if you're using an offset of 0 for current then it may have crossed anytime within the 15 mins triggering the trade, if it then crosses back it won't be visible on the chart as it would only the the value at the end of the candle

 
iRick:

First of all it looks like it may have crossed this morning, can't really tell from the image


Also if you're using an offset of 0 for current then it may have crossed anytime within the 15 mins triggering the trade, if it then crosses back it won't be visible on the chart as it would only the the value at the end of the candle

Could be that. Thank you.
 

Please post your mql4/MT4 question on mql4/MT4 section.

It will avoid you to waste your time and other's one.

 

You can use Strategy Tester to run the EA on the date with visual mode to see what exactly happen. 

But then again, my guess is that moving averages are lagging, and they need history bars to be filled before your EA can work out the trade, so you may not get your expected result.

Suggest you left your EA on for a few hours to a few days depending on the configured period of your moving averages, then turn on AutoTrading when the history bars are ready.

 
Zee Zhou Ma:

You can use Strategy Tester to run the EA on the date with visual mode to see what exactly happen. 

But then again, my guess is that moving averages are lagging, and they need history bars to be filled before your EA can work out the trade, so you may not get your expected result.

Suggest you left your EA on for a few hours to a few days depending on the configured period of your moving averages, then turn on AutoTrading when the history bars are ready.

What are you talking about ? In general you are right, but MAs can be seen on his screenshot, so obviously data are available.

 

Yes you are right, the MAs can be seen on his screenshot, so there is chart history for the calculations of the MAs. Please pardon me.

Then it could be spread is more than his max spread or some other conditions that prevent the trade.

Inconclusive..

This thread is linked to https://www.mql5.com/en/forum/295431.
EA failures
EA failures
  • 2018.12.18
  • www.mql5.com
I got the first deal of my expert. As seen in the chart, it's not doing what I wrote in the code. 1...