Newbe needs help...

 

I find in the documentation I can execute a script from inside a custom indicator. However, I am unable to find examples showing how this is done. If anyone can provide insight into how to do this it would be very much appreciated. Some code snippets would help.

Thanks in advance.

 

create a library or include file with function that can be called from script or from indicator.

 

I spent the weekend coding. Maybe for nothing.

I used the article by Richard Grosh "vangrosh 2009.06.16 12:28" at https://www.mql5.com/en/forum/117933 as a guide. I created the header file (mqh) a text file and placed it in \experts\include folder. I created a mq4 library file and compiled it, placing both mq4 and ex4 files in the \experts\library folder. The library file contained global variables and a subroutine to close existing positions and open a new position as in a oscillator strategy.

Everything compiled without errors. When I drop the custom indicator on the chart I get continuous errors:

"MyLibrary USDJPY,M15: Alert: Order 0 failed to close. Error: 4105"

and

"Custom indicator 'MyLibrary': OrderClose function cannot be called from a custom indicator".

The OrderClose() function is causing the error. Is there a better way? or What to do now?

 

hi,

as you can see in documentation indicators are not allowed to trade. if you want to trade you have to use a script or a EA

//z

 

Beat me to it zzuegg

Here is the link to program types and their capabilities though...

https://book.mql4.com/basics/programms

hth

v

 
Viffer:

Beat me to it zzuegg

Here is the link to program types and their capabilities though...

https://book.mql4.com/basics/programms

hth

v

Thanks to all for your guidance. The original post above asked for help with a script to solve the problem. Then I went on a wild goose chase. I suppose that is part of the learning curve.


Thank you anyway.

Reason: