How to code? - page 5

 

Debugging MQL4 code

Hello Everybody,

I have a lot of problems in debuging the code written for MT4. So I thought of writting most of the code in a DLL file then import those function to my MQL4 code. The problem I am facing is that this method doesn't succeed for DLL's written in C#. Does anybody now where the problem could be? A demonstration code would be so much appreciated.

I would also appreciate any other ideas for debugging MQL4 code.

regrard,

 
FX5:
Hello Everybody,

I have a lot of problems in debuging the code written for MT4. So I thought of writting most of the code in a DLL file then import those function to my MQL4 code. The problem I am facing is that this method doesn't succeed for DLL's written in C#. Does anybody now where the problem could be? A demonstration code would be so much appreciated.

I would also appreciate any other ideas for debugging MQL4 code.

regrard,

FX5,

I've wrote the dll code in C++, maybe it helps!

https://www.mql5.com/en/forum/173113

 

Thanks codersguru for the Ultrafast reply.

I will check the code and get back to you.

 

Check My MQL4 Code please.

This is just a sample EA based on a price/simple MA cross. The reason I'm asking to get it checked out is because it's essentially the backbone of a few EA's I'm developing (the structure, not the strategy). All I need to do is verify that this EA will only trade on the completion of a bar. If someone can help me verify this, I'd appreciate it a lot. I'm still pretty new to MQL4 and just want to get this double checked before I go any further. I have about 4 EA's being developed @ the moment, and just want to be sure they execute trades correctly. In this case it would be only on a full bar.

In the EA one would only need to change EachTickMode to TRUE to make it trade tick by tick instead of bar by bar. Anyway, that's the idea. I'd appreciate any help.

Files:
new_robot.mq4  7 kb
 

Debug code

hi all

how i debug the code (experts, indicatos, script) in runtime

(step by step)

thanks

 

hi

as you know, the MA indicator attachs to the main chart window, so it's scale will equal to price ratio, when you want to set a level=20, it means, you want to draw a horizontal line at 20 price ratio, the prices are too far from 20, so you can't see any line

 

Good Question

DooMGuarD:
hi all

how i debug the code (experts, indicatos, script) in runtime

(step by step)

thanks

Wish I had the answer.

I just finished writing my first EA and tried testing it in Strategy Tester.

I was getting errors showing in the ST journal so I tried using the Print function in my EA to debug the problems. I've worked out a few bugs so far this way, but it's a slow process.

 
 

The problem is with your stoploss. Your OrderSend statement should be written as:

OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-StopLoss*Point,Ask+TakeProfit*Point,"TH_Buy",16384,0,Green);

Also, for some brokers, it is not possible to use 10pips as takeprofit. You may have to increase it to 15pips.

 

Thank you very much, i will try it.

Reason: