Universal MA Cross EA - page 51

 

Regarding the question asked by Wagaba:

For this you can use the Multipurpose trademanager ea.

 

Hi Robert,

Thanks for your help, I can see you have been doing a fair bit of work trying to solve this problem.

I will run it again on a couple of charts on Monday,perhaps on a shorter timeframe than 1 hour to get a few cross situations and see whether it trades.

I will run it with MCD set at 5 and Look-up set at 0, and see how it goes.

I will also run the same ea but with a "5digit" bug fix that was posted earlier to my post also,and see whether that trades.

I currently have my takeprofit and stoploss set with an extra "0",as suggested by others who have had similar problems in opening trades.

So my 150 becomes 1500 and my 80 becomes 800

One thing I have noticed when doing this however, is that the "1500" becomes "1500.00",and the "80" becomes "800.00". Perhaps that is the problem here? Shoudln't it just become "1500"?

It's interesting to look at your images and and results. There is something weird going on somewhere, but I know nothing of editing mq4 code, so don't really want to try changing anything in metaeditor.

I have read through the entire thread over this same issue and it seems it has never quite been resolved. I'm wondering if anyone who runs this ea without any problems would like to post their settings, so I can at least see whether they are the same, in which case it becomes possibly a ea-server-broker problem, rather than a strictly ea code problem?

But i shall leave my platform up all day tomorrow on smaller timeframes,while i go to work,and see whether it has traded when i return home.

Thanks and regards

ricky

 

E/j

seems it worked well on EUR/JPY with 1 h TF...

 
Wagaba:
I am a new trader, am inquiring if there is some one who can add take profit levels to the Universal MA Cross EA. When am trading i prefer to exit half of my profits at 50 and let the other half run up to the next Fibonacci level. The Universal MA Cross EA works well for me but I have failed to set it to exit half of my trades and let the rest run. can any one help me?

I will be happy to look into it when we get the trade problem solved.

sn

 

just a little more debugging....

rickyc2511:
Hi Robert,

Thanks for your help, I can see you have been doing a fair bit of work trying to solve this problem.

I will run it again on a couple of charts on Monday,perhaps on a shorter timeframe than 1 hour to get a few cross situations and see whether it trades.

I will run it with MCD set at 5 and Look-up set at 0, and see how it goes.

I will also run the same ea but with a "5digit" bug fix that was posted earlier to my post also,and see whether that trades.

I currently have my takeprofit and stoploss set with an extra "0",as suggested by others who have had similar problems in opening trades.

So my 150 becomes 1500 and my 80 becomes 800

One thing I have noticed when doing this however, is that the "1500" becomes "1500.00",and the "80" becomes "800.00". Perhaps that is the problem here? Shoudln't it just become "1500"?

It's interesting to look at your images and and results. There is something weird going on somewhere, but I know nothing of editing mq4 code, so don't really want to try changing anything in metaeditor.

I have read through the entire thread over this same issue and it seems it has never quite been resolved. I'm wondering if anyone who runs this ea without any problems would like to post their settings, so I can at least see whether they are the same, in which case it becomes possibly a ea-server-broker problem, rather than a strictly ea code problem?

But i shall leave my platform up all day tomorrow on smaller timeframes,while i go to work,and see whether it has traded when i return home.

Thanks and regards

ricky

Hi Guys,

I took another look at the code and see two things:

1 - there was a Sleep(5000) in the code and normally this requires a RefreshRates(). Unlikely to cause this problem but might create a problem in the furture - so I corrected that.

2 - the stoplosses and the takeprofits are defined as doublebut get converted to int in the call to open the orders. Also, the counter trend logic has them as int. So it is a bit inconsistent - I have not changed it yet but this could be doing damage too.

So... I have thrown in one more debug line to capture more info info. If it does not lead to new clues, I'll just **FORCE** the right digits on to the prices and that should fix it.

I know this means we now have diverging version of the source - but we can try to keep track.

Last, I have tried to recreate the problem with a back test but can't (Alpari UK) so I am relying on you to test .

Oh, one other thing. I know you are having good success with this EA but in my back tests to recreate the problem, I get pretty poor results.

Could either of you attach your set file and the pair/tf again?

sn

 

Hi Robert,

Well, still no luck getting this thing to trade-it wants to,but just keeps throwing up the errors.

The only captured log info I have is as below:

Probably not much use to you, but I could not generate a test with gomarkets.

rickyc

03:05:28 universalMACrossEA[5 Dig]-V3 USDCAD,H1 inputs: Expert_Name="---------- Universal MA Cross EA v8.1"; MagicNumber=1234; StopLoss=100; TakeProfit=200; TrailingStop_Setting="---------- Trailing Stop Setting"; TrailingStopType=1; TrailingStop=40; Indicator_Setting="---------- Indicator Setting"; FastMAPeriod=3; FastMAType=1; FastMAPrice=0; FastMAshift=0; SlowMAPeriod=55; SlowMAType=1; SlowMAPrice=0; SlowMAshift=0; CossDistance_Setting="---------- Min Cross Distance Setting"; MinCrossDistance=0; MaxLookUp=3; Exit_Setting="---------- Exit Setting"; StopAndReverse=true; PureSAR=false; ExitOnCross=false; ThirdEMA_Setting="---------- Third MA Setting"; UseThirdMA=false; UseCounterTrend=false; OnlyCounterTrend=false; ThirdMAPeriod=100; ThirdMAType=1; ThirdMAPrice=0; ThirdMAshift=0; CTStopLoss=0; CTTakeProfit=0; Pivot.Setting="---------- Pivot Filter Setting"; Use.Pivot.Filter=false; Order_Setting="---------- Order Setting"; ReverseCondition=false; ConfirmedOnEntry=false; OneEntryPerBar=true; NumberOfTries=10; Slippage=5;

03:05:28 universalMACrossEA[5 Dig]-V3 USDCAD,H1: Last Trade : None

03:05:28 universalMACrossEA[5 Dig]-V3 USDCAD,H1: initialized

03:05:42 universalMACrossEA[5 Dig]-V3 USDCAD,H1: Prev : DOWN - Curr : DOWN

03:05:42 universalMACrossEA[5 Dig]-V3 USDCAD,H1: Prev : DOWN - Curr : DOWN

03:05:43 universalMACrossEA[5 Dig]-V3 USDCAD,H1: Prev : DOWN - Curr : DOWN

03:05:43 universalMACrossEA[5 Dig]-V3 USDCAD,H1: Prev : DOWN - Curr : DOWN

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: Prev : DOWN - Curr : UP

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: MA Cross BUY

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: ticket,err,count -1/130/0

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: Ask,Slippage,aStopLoss,aTakeProfit 1.06983/5.00000/1.05983/1.08983

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: ticket,err,count -1/130/1

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: Ask,Slippage,aStopLoss,aTakeProfit 1.06983/5.00000/1.05983/1.08983

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: ticket,err,count -1/130/2

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: Ask,Slippage,aStopLoss,aTakeProfit 1.06983/5.00000/1.05983/1.08983

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: ticket,err,count -1/130/3

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: Ask,Slippage,aStopLoss,aTakeProfit 1.06983/5.00000/1.05983/1.08983

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: ticket,err,count -1/130/4

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: Ask,Slippage,aStopLoss,aTakeProfit 1.06983/5.00000/1.05983/1.08983

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: ticket,err,count -1/130/5

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: Ask,Slippage,aStopLoss,aTakeProfit 1.06983/5.00000/1.05983/1.08983

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: ticket,err,count -1/130/6

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: Ask,Slippage,aStopLoss,aTakeProfit 1.06983/5.00000/1.05983/1.08983

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: ticket,err,count -1/130/7

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: Ask,Slippage,aStopLoss,aTakeProfit 1.06983/5.00000/1.05983/1.08983

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: ticket,err,count -1/130/8

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: Ask,Slippage,aStopLoss,aTakeProfit 1.06983/5.00000/1.05983/1.08983

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: ticket,err,count -1/130/9

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: Ask,Slippage,aStopLoss,aTakeProfit 1.06983/5.00000/1.05983/1.08983

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: ticket,err,count -1/130/0

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: Ask,Slippage,aStopLoss,aTakeProfit 1.06983/5.00000/1.05983/1.08983

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: ticket,err,count -1/130/1

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: Ask,Slippage,aStopLoss,aTakeProfit 1.06983/5.00000/1.05983/1.08983

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: ticket,err,count -1/130/2

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: Ask,Slippage,aStopLoss,aTakeProfit 1.06983/5.00000/1.05983/1.08983

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: ticket,err,count -1/130/3

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: Ask,Slippage,aStopLoss,aTakeProfit 1.06983/5.00000/1.05983/1.08983

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: ticket,err,count -1/130/4

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: Ask,Slippage,aStopLoss,aTakeProfit 1.06983/5.00000/1.05983/1.08983

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: ticket,err,count -1/130/5

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: Ask,Slippage,aStopLoss,aTakeProfit 1.06983/5.00000/1.05983/1.08983

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: ticket,err,count -1/130/6

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: Ask,Slippage,aStopLoss,aTakeProfit 1.06983/5.00000/1.05983/1.08983

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: ticket,err,count -1/130/7

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: Ask,Slippage,aStopLoss,aTakeProfit 1.06983/5.00000/1.05983/1.08983

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: ticket,err,count -1/130/8

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: Ask,Slippage,aStopLoss,aTakeProfit 1.06983/5.00000/1.05983/1.08983

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: ticket,err,count -1/130/9

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: Ask,Slippage,aStopLoss,aTakeProfit 1.06983/5.00000/1.05983/1.08983

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: ticket,err,count -1/130/0

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: Ask,Slippage,aStopLoss,aTakeProfit 1.06983/5.00000/1.05983/1.08983

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: ticket,err,count -1/130/1

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: Ask,Slippage,aStopLoss,aTakeProfit 1.06983/5.00000/1.05983/1.08983

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: ticket,err,count -1/130/2

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: Ask,Slippage,aStopLoss,aTakeProfit 1.06983/5.00000/1.05983/1.08983

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: ticket,err,count -1/130/3

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: Ask,Slippage,aStopLoss,aTakeProfit 1.06983/5.00000/1.05983/1.08983

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: ticket,err,count -1/130/4

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: Ask,Slippage,aStopLoss,aTakeProfit 1.06983/5.00000/1.05983/1.08983

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: ticket,err,count -1/130/5

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: Ask,Slippage,aStopLoss,aTakeProfit 1.06983/5.00000/1.05983/1.08983

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: ticket,err,count -1/130/6

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: Ask,Slippage,aStopLoss,aTakeProfit 1.06983/5.00000/1.05983/1.08983

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: ticket,err,count -1/130/7

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: Ask,Slippage,aStopLoss,aTakeProfit 1.06983/5.00000/1.05983/1.08983

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: ticket,err,count -1/130/8

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: Ask,Slippage,aStopLoss,aTakeProfit 1.06983/5.00000/1.05983/1.08983

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: ticket,err,count -1/130/9

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: sn Debug on buy: Ask,Slippage,aStopLoss,aTakeProfit 1.06983/5.00000/1.05983/1.08983

03:05:57 stdlib USDCAD,H1: loaded successfully

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: Error opening BUY order : (0) no error

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: Prev : UP - Curr : UP

03:05:57 universalMACrossEA[5 Dig]-V3 USDCAD,H1: Prev : UP - Curr : UP

 

Hi Robert,

Managed to get a backtest done, with the same erroes,but it still traded.

Have attached a set files. for your information.

Kind regards

rickyc

Files:
 

FORCED the Digits - No 4107 Errors?

Thanks Serpentsnoir...good follow up!

1) there was a Sleep(5000) in the code and normally this requires a RefreshRates(). Unlikely to cause this problem but might

create a problem in the future - so I corrected that.

* Thanks. I don't know enough to understand how RefreshRates works yet, but great if it prevents future problems!

2) the stoplosses and the takeprofits are defined as double but get converted to int in the call to open the orders. Also, the counter trend logic has them as int. So it is a bit inconsistent - I have not changed it yet but this could be doing damage too.

* I haven't found where are they are converted to int? Do you have some line numbers to help find them (I'm still learning)?

3) So... I have thrown in one more debug line to capture more info info. If it does not lead to new clues, I'll just **FORCE** the right digits on to the prices and that should fix it.

* Good job. So far the new debug line works fine but did not give me any new information. It still shows good prices for Bid, Ask, TP, SL, etc, but the error continues to be the 8 digit 4107 OrderSend error.

Your idea to "FORCE" the digits was interesting and I searched the web for solving 4107 errors. Here's what I found:

Replace Ask and Bid with NormalizedDouble:

Ask=(NormalizedDouble(Ask,Digits);

Bid =(NormalizedDouble(Bid,Digits);

Instead of forcing fixed numbers, the inclusion of Digits should make it compatible with different pair digits. (?)

Interesting that the SL and TP are already "NormalizedDouble" but the Bid and Ask are not? I found when I tried adding the above to change the Ask and Bid to "NormalizedDouble" - the logs had no more 4107 errors. This seems to FORCE the digits as you suggested. Are there other ways to do this?...and how does this help to explain the problem?

Original OrderSend for BUY

ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,aStopLoss,aTakeProfit,TicketComment,MagicNumber,0,Blue);

Modified OrderSend for BUY ticket=OrderSend(Symbol(),OP_BUY,Lots,NormalizeDouble(Ask,Digits),Slippage,aStopLoss,aTakeProfit,TicketComment,MagicNumber,0,Blue);

Original OrderSend for SELL

ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,bStopLoss,bTakeProfit,TicketComment,MagicNumber,0,Red);

Modified OrderSend for SELL ticket=OrderSend(Symbol(),OP_SELL,Lots,NormalizeDouble(Bid,Digits),Slippage,bStopLoss,bTakeProfit,TicketComment,MagicNumber,0,Red);

Try this mod and let us know the results.

I know this means we now have diverging version of the source - but we can try to keep track.

* Your version increment is doing well so far. Just add notes at top of the new version code to track the dates and changes.

Good job, thanks and good luck to our little EA!

Robert

 

MCD and MLU

rickyc2511:
Hi Robert,

Managed to get a backtest done, with the same errors,but it still traded.

Have attached a set files. for your information. Kind regards

rickyc

Thanks Ricky,

Helpful to at least see the consistency. That's actually a good thing in debugging!

Earlier you said:

1) I will run it again on a couple of charts on Monday,perhaps on a shorter timeframe than 1 hour to get a few cross situations and see whether it trades.

* Good strategy. I test for 1 month and find 1 good week of trades to help speed up testing. Smaller logs, easier to find debug errors.

2) I will run it with MCD set at 5 and Look-up set at 0, and see how it goes.

* These are interesting features and they actually work well. Problem is that the code locks them both together.

if(MaxLookUp>0 && MinCrossDistance>0)

You will notice the "&&" so both need to be > 1 for them to work. So MCD=5 and MLU=0 will not work with the present code. I explored trading on the same crossing bar and to make MCD crossing work without the MLU...I changed it to:

if(MaxLookUp==0 && MinCrossDistance>0)

Maybe someone can look at this and make it into an option? Meanwhile that change works well for me.

3) I currently have my takeprofit and stoploss set with an extra "0",as suggested by others who have had similar problems in opening trades.

So my 150 becomes 1500 and my 80 becomes 800. One thing I have noticed when doing this however, is that the "1500" becomes "1500.00",and the "80" becomes "800.00". Perhaps that is the problem here? Shouldn't it just become "1500"?

* I only use single digit TP and SL=0, so I have not found a problem with using single digits for TP or SL. BTW, where do you see the "1500.00 and 800.00"?

* I posted a follow up earlier on the 4107 error challenge. I hope this helps everyone...and thanks to Serpentsnoir for the debugging help!

Take care,

Robert

 

Universal MA cross problem

Hi to you all. I am new to using EA's and am having some trouble with Firedaves MA EA. and hope that someone can help. I trade manually normally and like the EMA cross strategy which I find pretty good on the whole (EMA5,EMA13,EMA62) however I have been looking to automate to a small degree and tried Firedaves which seemed to work one day but not the next, it's a bit hit and miss so far. It goes like this- EMA5 crosses EMA13 alert sounds but no trade placed. Next time alert sounds same crossing scenario trade placed but sometimes another opposite trade placed a minute or two later. I've checked all the settings i.e no reverse etc etc following the settings given by Firedave in post 1 but I'm not getting consistent results. Can anyone help or do I need to get back to a more simple MA EA based on crossover and if so anyone any ideas which one to try. I believe in keeping it simple if possible and the old strategies are the best as far as I can see.

Thanks everyone.

Reason: