Discussion of article "Step-by-Step Guide to Writing an Expert Advisor in MQL5 for Beginners" - page 3

To add comments, please log in or register
statarb
27
statarb  

Why when tighten the S/L to 5 (supposed to be 5 pips)

I have the following

 

Files:
Capture.PNG 8 kb
Rashid Umarov
Admin
14462
Rashid Umarov  
statarb:

Why when tighten the S/L to 5 (supposed to be 5 pips)

I have the following

 

You should check Stop Levels (SYMBOL_TRADE_STOPS_LEVEL) for a symbol before sending of trade request. The SL/TP mustn't be closer than this distance to current price to close. The sample to get this property:

int StopLevel_Distance=(int)SymbolInfoInteger(_Symbol,SYMBOL_TRADE_STOPS_LEVEL);
double SL=... // get new SL by calculation
//--- check current calculated Stop Loss level
if(SL>SymbolInfoDouble(_Symbol,SYMBOL_ASK)-StopLevel_Distance*_Point) 
   SL=SymbolInfoDouble(_Symbol,SYMBOL_ASK)-StopLevel_Distance*_Point;
//... modify SL for position
Lorenz Funderburk
682
Lorenz Funderburk  

Thanks, but neither my SL nor my TP are being carried out. In the compiler "Terminal" they are listed as "0.00" or "0.0"  Anyway it's impossible to give a general stoploss for all orders. And I haven't been successful yet in changing the parameter values from "outside", i.e. without changing the code in the editor.

Otherwise it's working great! And the comments are a great help!

Thanks again,

locan BBS

.locan.BBS:


mistrytrader
4
mistrytrader  

Hi Olowsam,

Thanks for this step-bystep guide. I have a few question, which I hope you'll be able to help me with.

        I have followed your instruction to the letter, but have failed to reach the desired result. First of all, I am working with the latest version of Meta Trader 5.00, Build 6.55 (6th June 2012).  I have noted several differences, the 1st being the MQL5 wizard template has extra options, then what you show in your notes. Any way, I have ensured the program is exactly as you have described. I have compiled it. No problems. Zero errors. I have managed to insert all the 5 debug break points as suggested in your notes in the OnTick subroutine. Click the Green Run button & NOTHING happens. The program execution does not get to this point. Why? What's happening? If I insert the debug breakpoints @ the start of OnInit sub, @ say, adzHandle=iADX9Null,0,ADX_Period) line, then this is OK. The debug STEP tabs, light up & I can single step this control all the way to the end of the OnInit sub. However, after that, again nothing. In short, I cannot reach the OnTick sub. What's happening & why? Is this a known bug in the operation of the Meta Trader system? How can I resolve this issue & move on?

I hope the above explains the problem I've had, & hope that you can see what's going on & that you will be able to assist.

Thanks.

Best Regards

Kishor 

mycall_14
3
mycall_14  

Hey Great Article,

Typed all the code out as i went along and didnt get any compile errors at the end so must of been well explained. A good excersise for first time using the metatrader5/mql5 system.

Might need to do some optimisation to make the graph go in an upward direction thou :D

All the best, and thanks!!

Mike

polymath
183
polymath  

Hi, 

I really liked the coding style of this article,  very easy to read and follow.  I just have one request if you don't mind, can you also give an example of how to implement trailing stops with this sample?

Thank you very much! 

Andrew Kreimer
762
Andrew Kreimer  
Thank you very much for a wonderful guide!
M Oldemiro Fernandes
17
M Oldemiro Fernandes  

thank you for this article.

I felt lost when I start looking the MQL5 examples... after looking at your article, everithing is much easier to understand.

Mauro Bracuti
2272
Mauro Bracuti  

Ottima spiegazione :-)  Grazie :-)

Excellent article Tank You :-)

 

Hamed Tabasi
177
Hamed Tabasi  

Great Article,

It helps me to save more than 3 months, Thank you, I am going to your next related article (OOP)

hoping to see money marking expert and sharing with you, I looking forward to such article,

Thank you again, 

To add comments, please log in or register