molanis.com/forum - Tools for MetaTrader : The place to ask about the best expert advisor builder, expert advisor downloads, and expert advisor programming

AFTER YOU REGISTER SEND US AN EMAIL TO ACTIVATE YOUR ACCOUNT - Before posting:-1- Please read the user guide -2- Try the examples -3- Search in the forum
It is currently Sat May 11, 2024 10:12 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 14 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: MQL Block: Practical Usage Help
PostPosted: Wed Mar 14, 2012 7:15 pm 
Offline

Joined: Wed Mar 14, 2012 12:31 am
Posts: 118
Hello Technical Support:

I am currently evaluating Molanis, before making a purchase decision. I've downloaded the trial version and began looking at the MQL Block. I also read some of the information in your support documentation, but I did not see my particular set of questions answered. My trade logic requires the use of Variables that are essentially derivative calculations of both Price and Indicator. I use mostly iCustom indicators and an occasional standard MT4 indicator.

Questions:

1) If I can construct a statement inside the MQL Block Trading Condition with Advanced Mode "On," that tests out "Ok" (after clicking on Test Trading Condition), how do I then call that Variable Trading Condition from within a TA+ Block?

2) If I cannot essentially "call" the Variable Trading Condition established within the MQL Block, through a TA+ Block either on the left or right operand side of the TA+ Block trading rule editor, then how do I get the value/output produced by the MQL Block's Trading Condition, into the overall EA trade logic by way of using AND, or OR?

Please give me one or two clear examples of how I might do the above.

I can see that by using the MQL Block to establish a Trading Condition, I can extend my trade logic and create a more sophisticated EA, because I can control the direction and content of the Trading Condition itself. This is a really nice feature. However, I don't see how you then implement the MQL Block's Trading Condition, after it has been constructed.

- I do see that you can connect Start -to- MQL
- I do see that you can connect MQL -to- AND
- I do see that you can connect MQL -to- BUY/SELL

My gut tells me that you cannot "call" the MQL Block from within the TA+ Block, and that you must insert the MQL Block into the logic flow of AND/OR, between TA+ and BUY/SELL. But, I'll wait for your confirmation on that guess.

3) It would be really nice, if it were possible to give each MQL Block Trading Condition a Name, so that identifying it from the Diagram level, or identifying it from within a TA+ Block (if that is even possible) would be much easier.

Thank you!
cfx


Top
 Profile  
 
 Post subject: Re: MQL Block: Practical Usage Help
PostPosted: Thu Mar 15, 2012 9:31 am 
Offline
Site Admin

Joined: Fri Oct 16, 2009 3:40 pm
Posts: 451
1) The mql icon works as a TA icon. You don't call it from a TA.
The mql icon was designed to create a trading condition in mql4 as in IF trading condition THEN, so you need to connect it to an execution icon like buy or sell

2) See 1 - just in case, you can create variables using the mt var icon - see latest user guide at molanis.com/support/manuals
You guess was right

3) I get your point. Under the mql condition you see part of the code to identify it - not a name but it works


Top
 Profile  
 
 Post subject: Re: MQL Block: Practical Usage Help
PostPosted: Thu Mar 15, 2012 3:45 pm 
Offline

Joined: Wed Mar 14, 2012 12:31 am
Posts: 118
admin wrote:
1) The mql icon works as a TA icon.


Thank you. After some experimentation with the MQL Block, I'll extend my questions to its functionality.


admin wrote:
2) See 1 - just in case, you can create variables using the mt var icon..


I looked at the Molanis Users Guide online and things seem a bit foggy on the use of the MT/VAR. I am able to get it to display on the diagram. The problems are three fold:

a) MT/VAR only shows the Double form of MT4 variable. There are many others such as: String, Integer, Boolean, DateTime and Color, that MT/VAR does not show. Why is this?

b) MT/VAR has no functionality for Variable Assignment such as: External, Parameter, Global, System, Function, or Flag. Therefore, you cannot assign the variable once you create it. Why is this?

c) I don't see where you can ever create the value that gets used inside the TA+ Block, that was created inside MT/VAR? All you can do is Name the new Variable inside MT/VAR and then "select" that same variable name in the TA+ Block. However, I don't see exactly where you input the actual value for the variable in either the MT/VAR or the TA+ Block?

Can you please give a succinct example of how to accomplish this?


admin wrote:
3) I get your point. Under the mql condition you see part of the code to identify it - not a name but it works


If you only have one or two, no problem at all. But, you can imagine the visual nightmare that might be caused, if you had to constantly plow through 10 on each side (Buy and Sell) for a total of twenty possible MQL Blocks. Naming them really helps when you need to use more than a couple.

Thank you!
cfx


Top
 Profile  
 
 Post subject: Re: MQL Block: Practical Usage Help
PostPosted: Fri Mar 16, 2012 8:48 am 
Offline

Joined: Tue Dec 22, 2009 12:22 am
Posts: 1761
Quote:
a) MT/VAR only shows the Double form of MT4 variable. There are many others such as: String, Integer, Boolean, DateTime and Color, that MT/VAR does not show. Why is this?

You can enter an integer number as a double
We want to keep it simple since most of the ea variables are related to the indicator period so double makes perfect sense. These variables are the most used during backtesting and optimizatrion in mt4.

Code:
b) MT/VAR has no functionality for Variable Assignment such as: External, Parameter, Global, System, Function, or Flag. Therefore, you cannot assign the variable once you create it. Why is this?

All variables defined in the ea builder are used as inputs in the expert advisor. That's the way people needed to do backtesting in mt4.

Quote:
c) I don't see where you can ever create the value that gets used inside the TA+ Block, that was created inside MT/VAR? All you can do is Name the new Variable inside MT/VAR and then "select" that same variable name in the TA+ Block. However, I don't see exactly where you input the actual value for the variable in either the MT/VAR or the TA+ Block?

You define the variable in the mt var icon. The value is taken from the TA+ where you add it. If you add it to two TA+ make sure the value is the same - if not - the ea builder will will assign one of the two values. You can change that value in metaeditor (if you have a pro version) or in the ea inputs in metatrader.


Top
 Profile  
 
 Post subject: Re: MQL Block: Practical Usage Help
PostPosted: Fri Mar 16, 2012 6:46 pm 
Offline

Joined: Wed Mar 14, 2012 12:31 am
Posts: 118
Thanks for the reply, Molanisfx.

molanisfx wrote:
We want to keep it simple since most of the ea variables are related to the indicator period so double makes perfect sense. These variables are the most used during backtesting and optimizatrion in mt4.


Does that mean that if I have a more sophisticated iCustom indicator, that I won't be able to use it with Molanis? Or, does that mean that a more complex, yet well coded iCustom indicator cannot be used with External Variables in Molanis?


molanisfx wrote:
All variables defined in the ea builder are used as inputs in the expert advisor. That's the way people needed to do backtesting in mt4.


Does this apply to iCustom indicators that pass through the Molanis iCustom import feature?


molanisfx wrote:
You define the variable in the mt var icon.


That part I understood.


molanisfx wrote:
The value is taken from the TA+ where you add it.


That part I do not understand. The following MQL code snippet comes from one of the iCustom indicators that I imported through Molanis in a TA+ Block. The following shows two things:

a) The only two parameters that allow for adjustments in the Averaging Period for the indicator
b) Each Mode that is output by the indicator (0 through 7)

External Variables:

extern int TACperiod = 5;
extern int SACperiod = 8;


Modes

SetIndexStyle (0,DRAW_HISTOGRAM);
SetIndexBuffer(0,db_TCD_L);
SetIndexLabel (0,"TCD-Long");

SetIndexStyle (1,DRAW_HISTOGRAM);
SetIndexBuffer(1,db_TCD_S);
SetIndexLabel (1,"TCD-Short");


SetIndexStyle (2,DRAW_LINE);
SetIndexBuffer(2,db_TAC_L);
SetIndexLabel (2,"TAC-Long");

SetIndexStyle (3,DRAW_LINE);
SetIndexBuffer(3,db_TAC_S);
SetIndexLabel (3,"TAC-Short");


SetIndexStyle (4,DRAW_LINE);
SetIndexBuffer(4,db_SAC_L);
SetIndexLabel (4,"SAC-Long");

SetIndexStyle (5,DRAW_LINE);
SetIndexBuffer(5,db_SAC_S);
SetIndexLabel (5,"SAC-Short");


SetIndexStyle (6,DRAW_LINE);
SetIndexArrow (6,110);
SetIndexBuffer(6,db_MTCD_L);
SetIndexLabel (6,"M-TCD-L");

SetIndexStyle (7,DRAW_LINE);
SetIndexArrow (7,110);
SetIndexBuffer(7,db_MTCD_S);
SetIndexLabel (7,"M-TCD-S");

There are eight (8) modes output for this one iCustom indicator and there are two External Variables that allow for the optimization of of the Period calculation that determines how the indicator is averaged. Knowing each mode used by the indicator and knowing which parameters are used to set its Period, I created the following two MT/VARs:

Image


I then imported the iCustom indicator called TCDi7_0001 using the TA+ Block's iCustom import feature:

Image


But, when I went to configure those two variables (TacPeriod and SacPeriod) in the TA+ Block containing the imported iCustomer indicator TCDi7_0001, there were no fields containing TacPeriod and SacPeriod, nor were there any drop-down lists to the right of each field, containing the name of the variables I just created in the MT/Var Block:

Image


molanisfx wrote:
If you add it to two TA+ make sure the value is the same...


I don't see how, given the illustrations above. Can you confirm, how?


molanisfx wrote:
...You can change that value in metaeditor (if you have a pro version) or in the ea inputs in metatrader.


To expedite all EA testing, optimization and evaluation, I was hoping to be able to simply create External Variables (TacPeriod and SacPeriod) that could easily be edited at EA load-time, rather than editing the indicator itself in Meta Editor, re-compiling and then re-importing the same back through the same TA+ Block. Editing the variables at EA load-time would save a lot of time overall.

Your assistance is appreciated. Thanks!

Regards,
cfx


Top
 Profile  
 
 Post subject: Re: MQL Block: Practical Usage Help
PostPosted: Fri Mar 16, 2012 9:48 pm 
Offline

Joined: Wed Mar 14, 2012 12:31 am
Posts: 118
Hello Admin,

After taking another looking at this, it appears as though after you import the iCustom indicator, the TA+ Block never displays a field for any of the External Variables for that particular iCustom indicator. That is the piece that is very confusing for me.

If I were to select a standard MT4 indicator as the comparator within the TA+ Block, then I do get a drop-down list of potential Variables to use. But, not when one of the TA+ Block comparators is an iCustom indicator. The TA+ Block simply ignores all of the External Variables contained within the iCustom indicator.

Of course, when you load that same iCustom indicator to any chart, you are immediately presented with the following window:

Image

So, how do I get the opportunity to edit any of the above External Variables at EA load time, instead of iCustom indicator load time (if that is at all possible).

My gut tells me this is not possible with Molanis, and the any time I need to edit an iCustom External Variable, I'll have to do it by opening the .mq4 file and making the edits manually while going through the back-testing and optimization process. But, again, I'll wait for conformation from you about that.

Thanks,
cfx


Top
 Profile  
 
 Post subject: Re: MQL Block: Practical Usage Help
PostPosted: Sun Mar 18, 2012 3:23 pm 
Offline

Joined: Tue Dec 22, 2009 12:22 am
Posts: 1761
To use variables created with the strategy builder in your custom indicator you need to understand the indicator.
Let's say your custom indicator has 2 variables for two periods 5 and 10, you create 2 variables in mt var called var1 and var2.
The import process with setup the parameters for you.You will get something like "indicator_name",5,10
Since you want to use variables for those inputs, you need to rewrite manually from "indicator_name",5,10 to "indicator_name",var1,var2
Now you can control the custom indicator input using var1 and var2 in the ea


Top
 Profile  
 
 Post subject: Re: MQL Block: Practical Usage Help
PostPosted: Mon Mar 19, 2012 2:33 pm 
Offline

Joined: Wed Mar 14, 2012 12:31 am
Posts: 118
molanisfx wrote:
Since you want to use variables for those inputs, you need to rewrite manually from "indicator_name",5,10 to "indicator_name",var1,var2
Now you can control the custom indicator input using var1 and var2 in the ea


That does not work. Here's what you get when you replace 5 and 8 inside the TA+ Block's Custom Fields and then attempt to compile the MQL in Molanis:

Image


The actual text file that this dialog box refers to, contains the following:

2;75;C:\Program Files (x86)\FXCM MetaTrader 4 Test\experts\EA Load Test for ExternVar.mq4;382:44;'TACPeriod' - variable not defined
2;75;C:\Program Files (x86)\FXCM MetaTrader 4 Test\experts\EA Load Test for ExternVar.mq4;382:55;'SACPeriod' - variable not defined
2;75;C:\Program Files (x86)\FXCM MetaTrader 4 Test\experts\EA Load Test for ExternVar.mq4;409:44;'TACPeriod' - variable not defined
2;75;C:\Program Files (x86)\FXCM MetaTrader 4 Test\experts\EA Load Test for ExternVar.mq4;409:55;'SACPeriod' - variable not defined


So, simply changing the indicators default period values from 5 and 8, to TACPeriod and SACPeriod (after having declared those new variable names in the MT/VAR Block), will not work. And, if you don't "rewrite" those values inside the TA+ Block, then where else would you "rewrite" them? Can you give a clear example of the location for the "rewrite?"

Also, note that the very first thing the indicator's code does, is declare its Variables. These are the very first two lines of code in the TCDi7_0001 indicator:

extern int TACperiod = 5;
extern int SACperiod = 8;

Clearly, you cannot "rewrite" the indicator file by changing its 5 and 8, to TACPeriod and SACPeriod, such as:


extern int TACperiod = TACperiod ;
extern int SACperiod = SACperiod ;

...because MetaEditor will not compile that code without throwing at least two errors:

Image


So, where exactly does this manually rewriting of the indicator's default input variables (5 and 8) take place? Where exactly would I manually encode TACPeriod (for 5) and SACPeriod (for 8)?

Thank you.


Top
 Profile  
 
 Post subject: Re: MQL Block: Practical Usage Help
PostPosted: Tue Mar 20, 2012 4:29 pm 
Offline

Joined: Tue Dec 22, 2009 12:22 am
Posts: 1761
What I posted before is a workaround. You still need to assign tha vars to a dummy TA+ for them to be defined in the EA. Create a TA+ with a condition that won't be true (like 1=5) and assign the initial value for the variable there.


Top
 Profile  
 
 Post subject: Re: MQL Block: Practical Usage Help
PostPosted: Tue Mar 20, 2012 6:41 pm 
Offline

Joined: Wed Mar 14, 2012 12:31 am
Posts: 118
molanisfx wrote:
What I posted before is a workaround.


I'm confused. The workaround didn't work. That's what I showed.

Can you please, post a pic of the sequence of events that you are referring to, just as I have done. That will give me a walk-through of exactly how to use MT/VAR with iCustom.

You tell me to "assign" the variables in the TA+ Block. Well, that's not possible when using iCustom. Here are the pics that demonstrate what I'm talking about.


My newly created MT\VARs:

Image


Here are those variables inside the TA+ Block with a Standard MT4 Indicator:

Image


Here are those same variables inside the TA+ Block with an iCustom Indicator, using a condition that I know will not resolve to True:

Image


As you can clearly see, the TA+ Block never allows you to assign the newly created variables (TACPeriod and SACPeriod) anywhere within its window, whenever you are using an iCustom indicator. You can also clearly see that the TA+ Block does indeed allow you to assign the new variables, when you are using a Standard MT4 indicator.

So, variable assignment is available with a Standard Indicator, not with an iCustom indicator. Is this correct? If this is not correct, please post a pictorial walk-through just like mine that shows how and where you assign the newly created variables TACPeriod and SACPeriod.

MT/VAR creates them, but TA+ does not see them when using iCustom. The pics demonstrate this behavior.

Thank you!
cfx


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by Molanis © 2009