When is CheckOpenLong called?

 

posted this question under General, but this seems like a better place...

I'm creating my first EA following the instructions in MQL5 Wizard: How to Create a Module of Trading Signals

My init function gets called and returns true.  I set a break point in CheckOpenLong but the debugger never breaks there.

Under what conditions is CheckOpenLong called?  I searched the docs and don't see any explanation of it, so I don't know if I'm creating the right conditions for the method to be called.


thanks,
Rik 

MQL5 Wizard: Creating Expert Advisors without Programming
MQL5 Wizard: Creating Expert Advisors without Programming
  • 2011.01.11
  • MetaQuotes Software Corp.
  • www.mql5.com
Do you want to try out a trading strategy while wasting no time for programming? In MQL5 Wizard you can simply select the type of trading signals, add modules of trailing positions and money management - and your work is done! Create your own implementations of modules or order them via the Jobs service - and combine your new modules with existing ones.
 
rik:

posted this question under General, but this seems like a better place...

I'm creating my first EA following the instructions in MQL5 Wizard: How to Create a Module of Trading Signals

My init function gets called and returns true.  I set a break point in CheckOpenLong but the debugger never breaks there.

Under what conditions is CheckOpenLong called?  I searched the docs and don't see any explanation of it, so I don't know if I'm creating the right conditions for the method to be called.


thanks,
Rik 

Have you ever try to set the breakpoint at the end of CheckOpenLong() ?
 
phi.nuts:
Have you ever try to set the breakpoint at the end of CheckOpenLong() ?

I didn't try that but thanks for responding. Long story short, this is what I get for trying to use someone else's code from a tutorial, where I didn't understand what the effect of the trading threshold parameter was. The fuller explanation follows, maybe it will help others...

When the program started, the value of the trading threshold input parameter was set to 10, which seemed fine, so I never changed it.  But internally one of the super classes was calling a method to get "direction", which was coming back 0.  0 doesn't exceed the threshold of 10, so my own CheckOpenLong method was not called in that case.  So I gather I have to write my own Direction method to overcome this.  I have just discovered this in the last 10 minutes, so haven't fully tested whether setting the threshold lower or making direction return a larger value will fix it, but at least I can see that the debugger steps to all those places, so I think I will fix this without much more trouble.

Thanks to the developers for a pretty good debugger.  Now if anyone can tell me how to launch it from MT5 and not from the meta editor, that would be better.  Then I could drop it onto the chart I want instead of it popping up a new chart based on (apparently) the top symbol in the market watch window.  I hope that's clear.  In other words, when I start the debugger from the meta editor, it doesn't know which chart I want to use, so it pops up a new one using whatever's at the top of the market watch list.  Instead, I would like to drop the EA onto an existing chart and have it start up in debug mode, if that's possible.  (I didn't make that link to the left.  I just checked where that goes and can't say it pertains to this discussion.)

 
rik:

I didn't try that but thanks for responding. Long story short, this is what I get for trying to use someone else's code from a tutorial, where I didn't understand what the effect of the trading threshold parameter was. The fuller explanation follows, maybe it will help others...

When the program started, the value of the trading threshold input parameter was set to 10, which seemed fine, so I never changed it.  But internally one of the super classes was calling a method to get "direction", which was coming back 0.  0 doesn't exceed the threshold of 10, so my own CheckOpenLong method was not called in that case.  So I gather I have to write my own Direction method to overcome this.  I have just discovered this in the last 10 minutes, so haven't fully tested whether setting the threshold lower or making direction return a larger value will fix it, but at least I can see that the debugger steps to all those places, so I think I will fix this without much more trouble.

Thanks to the developers for a pretty good debugger.  Now if anyone can tell me how to launch it from MT5 and not from the meta editor, that would be better.  Then I could drop it onto the chart I want instead of it popping up a new chart based on (apparently) the top symbol in the market watch window.  I hope that's clear.  In other words, when I start the debugger from the meta editor, it doesn't know which chart I want to use, so it pops up a new one using whatever's at the top of the market watch list.  Instead, I would like to drop the EA onto an existing chart and have it start up in debug mode, if that's possible.  (I didn't make that link to the left.  I just checked where that goes and can't say it pertains to this discussion.)

About debug symbol, press F1 to open help file and search for debug - there's plenty interesting stuff there  about debug, or click tool menu in MetaEditor > select Option > and click debug tab.
 
phi nuts:
About debug symbol, press F1 to open help file and search for debug - there's plenty interesting stuff there  about debug, or click tool menu in MetaEditor > select Option > and click debug tab.

rik:

I didn't try that but thanks for responding. Long story short, this is what I get for trying to use someone else's code from a tutorial, where I didn't understand what the effect of the trading threshold parameter was. The fuller explanation follows, maybe it will help others...

When the program started, the value of the trading threshold input parameter was set to 10, which seemed fine, so I never changed it.  But internally one of the super classes was calling a method to get "direction", which was coming back 0.  0 doesn't exceed the threshold of 10, so my own CheckOpenLong method was not called in that case.  So I gather I have to write my own Direction method to overcome this.  I have just discovered this in the last 10 minutes, so haven't fully tested whether setting the threshold lower or making direction return a larger value will fix it, but at least I can see that the debugger steps to all those places, so I think I will fix this without much more trouble.

Thanks to the developers for a pretty good debugger.  Now if anyone can tell me how to launch it from MT5 and not from the meta editor, that would be better.  Then I could drop it onto the chart I want instead of it popping up a new chart based on (apparently) the top symbol in the market watch window.  I hope that's clear.  In other words, when I start the debugger from the meta editor, it doesn't know which chart I want to use, so it pops up a new one using whatever's at the top of the market watch list.  Instead, I would like to drop the EA onto an existing chart and have it start up in debug mode, if that's possible.  (I didn't make that link to the left.  I just checked where that goes and can't say it pertains to this discussion.)


Rik: 

Note that the Direction function in CExpertSignal only calls two of the virtual functions, namely, LongCondition and ShortCondition; this means that the remaining virtual functions, even if they are overwritten by your customized filter would never be called, unless as you suggested, you call them from your new version of Direction function. However, if you want the price, sl, tp, and expiration to be set by your function, then you should get the base signal instance in your Expert Advisor to be an instance of your customize class and not that of CExpertSignal, which is what is put there by default. All you need to do is to change this line in the generated Expert Advisor code:

int OnInit()

  {

   ...

   CExpertSignal *signal=new CExpertSignalCustomized;

   ...

  }


This way, when the framework calls CheckOpenLong function, for example, your overwritten version will be called and not the original one. I hope that this helps. 

Reason: