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 Fri May 17, 2024 1:17 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 13 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Importing Indicator from IB into SB Issue for BUY and SELL
PostPosted: Thu Aug 22, 2013 7:06 pm 
Offline

Joined: Mon Dec 26, 2011 5:41 am
Posts: 46
Hi,

I have done the following. Created an custom indicator using IB with two inputs for BUY and SELL rules to be used in the strategy. So the strategy is in the custom indicator with two inputs. Mode 0 for BUY and Mode 1 for SELL.

When I attach the custom indicator to chart, it paints, and can see it's doing what it's suppose to as per the strategy for BUY and SELL.

In SB for BUY and SELL rules, all I am doing is importing the custom indicator that was created within an MQL block

MQL BLOCK FOR BUY: iCustom(Symbol(),0,"custom_indicator_created",0,0) --- (1)

MQL BLOCK FOR SELL: iCustom(Symbol(),0,"custom_indicator_created",1,0) --- (2)

Custom indicator created uses [i+1], [i+2] etc ... it does not use [i] (current bar)

So really wherever the indicator paints on chart I expect EA to only execute BUY or SELL, if I've done this correctly. I assume that i from custom indicator is being replaced with the value of '0' making i+1=>1 , i+2=>2 etc ... when checking the condition for true (1)

However I am running into situations when BUY and SELL are being executed while there is no painting on chart.

Is there any difference by calling BUY or SELL this way over :

1. using TA+, TA blocks or;
2. even using the custom indicator code and paste it the MQL block removing i

Am still investigating this, and at present will try 2. to see if this resolves the issue.


Top
 Profile  
 
 Post subject: Re: Importing Indicator from IB into SB Issue for BUY and SELL
PostPosted: Thu Aug 22, 2013 10:42 pm 
Offline

Joined: Mon Dec 26, 2011 5:41 am
Posts: 46
Also to add that debugging information added to show from Experts Log when EA opens a trade clearly shows that the condition of the custom indicator was not followed. So custom indicator did not paint as it was not an entry but EA thought it was :?: The trading diagram is quite simple and is attached.


Attachments:
EA-MolanisDesign-2013-08-23_1328.png
EA-MolanisDesign-2013-08-23_1328.png [ 61.39 KiB | Viewed 7120 times ]
Top
 Profile  
 
 Post subject: Re: Importing Indicator from IB into SB Issue for BUY and SELL
PostPosted: Fri Aug 23, 2013 4:03 am 
Offline

Joined: Mon Dec 26, 2011 5:41 am
Posts: 46
This issues seems to relate to this post and what I am working on http://www.molanis.com/forum/viewtopic.php?f=3&t=5944&p=10971#p10971 with multi timeframe.

See two difference in values when calling a custom indicator in two different ways checking it's values at point in time BUY or SELL is executed.

Way 1: import the custom indicator builder (see Way 2) with period set to higher timeframe for each of it's mode. The indicator has 3 x modes, and save as Indicator-M30.mol and create mq4 and ex4. In arithmetic calculations I use this indicator calling it as

(iCustom(NULL,0,"Indicator-M30",2,i+1)<iCustom(NULL,0,"Indicator-M30",2,i+2))&& etc ...

Way 2: Just use the indicator as it as what it shows when importing in Way 1, as

(iCustom(Symbol(),PERIOD_M30,"Indicator", "-----Alert Settings-----", FALSE, FALSE, "alert.wave", FALSE, 17,2,i+1)<iCustom(Symbol(),PERIOD_M30,"Indicator", "-----Alert Settings-----", FALSE, FALSE, "alert.wave", FALSE, 17,2,i+2))&& etc ...

Debugging information shows the value for iCustom(NULL,0,"Indicator-M30",2,i+2) not the same as iCustom(Symbol(),PERIOD_M30,"Indicator", "-----Alert Settings-----", FALSE, FALSE, "alert.wave", FALSE, 17,2,i+2)

But both custom indicator I built and EA uses the multitimeframe arithmetic from Way 1 when checking the difference. So why EA executes and custom indicator does not paint. Visually from chart, EA should not have executed.

The value for iCustom(Symbol(),PERIOD_M30,"Indicator", "-----Alert Settings-----", FALSE, FALSE, "alert.wave", FALSE, 17,2,i+1) and iCustom(NULL,0,"Indicator-M30",2,i+1) are both the same from the debugging.

I also print the values of this indicator on timeframe 0 for (i+1) and (i+2), and they are different as expected and match the M15 chart.

Is there a difference between NULL and Symbol()? I don't see any here.

My understanding of http://www.molanis.com/forum/viewtopic.php?f=3&t=5944&p=10971#p10971 is the hardcoded one with timeframe 0 will use the M30 timeframe when printing it's values, which is correct as far as I can see as (i+1) are the same, while (i+2) are different.


Top
 Profile  
 
 Post subject: Re: Importing Indicator from IB into SB Issue for BUY and SELL
PostPosted: Fri Aug 23, 2013 7:31 pm 
Offline

Joined: Tue Dec 22, 2009 12:22 am
Posts: 1761
To help you we need your indicator file .moi file, and the strategy file .mol file, and any other custom indicator. First we need to understand the strategy and how you get the signals


Top
 Profile  
 
 Post subject: Re: Importing Indicator from IB into SB Issue for BUY and SELL
PostPosted: Fri Aug 23, 2013 8:43 pm 
Offline

Joined: Mon Dec 26, 2011 5:41 am
Posts: 46
Quote:
To help you we need your indicator file .moi file, and the strategy file .mol file, and any other custom indicator. First we need to understand the strategy and how you get the signals


The strategy and custom indicator are not mine. Am building it for someone, and don't have permission to give on forum. Other than emailing support separately to advise.


Top
 Profile  
 
 Post subject: Re: Importing Indicator from IB into SB Issue for BUY and SELL
PostPosted: Sat Aug 24, 2013 3:19 pm 
Offline

Joined: Tue Dec 22, 2009 12:22 am
Posts: 1761
As per you questions:
Is there a difference using
1. using TA+, TA blocks or;
2. even using the custom indicator code and paste it the MQL block removing i

With the TA icons you are sure the condition code is correct because it is generated by the builder. If you use the MQL icon and the code is correct you will get the same result. If you are not getting the same result maybe you need to check your code.


Quote:
(iCustom(NULL,0,"Indicator-M30",2,i+1)<iCustom(NULL,0,"Indicator-M30",2,i+2))&& etc ...

That does not seem correct. the i+1 is a format for creating the indicator but not for using it. When you use it you use the numbers only to indicate the bar that will be used to get the indicator value (1 is the previous bar, 0 current bar)


Top
 Profile  
 
 Post subject: Re: Importing Indicator from IB into SB Issue for BUY and SELL
PostPosted: Sat Aug 24, 2013 6:47 pm 
Offline

Joined: Mon Dec 26, 2011 5:41 am
Posts: 46
Quote:
As per you questions:
Is there a difference using
1. using TA+, TA blocks or;
2. even using the custom indicator code and paste it the MQL block removing i

With the TA icons you are sure the condition code is correct because it is generated by the builder. If you use the MQL icon and the code is correct you will get the same result. If you are not getting the same result maybe you need to check your code.


I have checked the code many times, and see no issues with it. Like I said how the custom indicator built is tested is by painting on the chart using arrows. The arrows painted and looking at the chart and the indicators it uses, matches the condition for BUY or SELL, of the strategy.

I have pasted the indicator code in SB removing i, and saw same results with the differences in values with one specific condition mentioned above. I've even created a separate one in SB that uses TA blocks instead of using the custom indicator, and saw the same effects. The debugging printed, that I added in SB after code generation, is looking at all the values of interest that the condition is checking, and how I saw the issue.

Quote:
Quote:
(iCustom(NULL,0,"Indicator-M30",2,i+1)<iCustom(NULL,0,"Indicator-M30",2,i+2))&& etc ...


That does not seem correct. the i+1 is a format for creating the indicator but not for using it. When you use it you use the numbers only to indicate the bar that will be used to get the indicator value (1 is the previous bar, 0 current bar)


am not sure am with you here. When using the Indicator Builder, it adds the i+1, i+2 etc ... I add open, it puts open[i], open[1], it puts open[i+1]. The manual of indicator builder does not say we have to remove the i when using the indicator builder. So I just save, validate, and generate mql4 code. The mql4 code does show the shifts with i in them. But the ex4 generated works for me as it paints on chart where I expect it to paint.

I had a separate MT4 looking at this indicator from two separate charts. One chart (lower timeframe) has the hardcoded of the higher timeframe referencing the 3 x modes built using indicator builder. The other chart is the higher timeframe chart using the indicator as is (timeframe 0). The hardcoded version of higher timeframe from lower timeframe eventually loses sync with the higher timeframe one, where the values of the modes don't match what the higher timeframe is showing.

Like I said in my other posts, I don't see this type of problem using the MT4 built-in indicators.

Whenever the value loses sync from the hardcoded higher timeframe indicator attached to the lower timeframe, I have to keep switching it to the higher timeframe it's referencing to be in sync. Having both charts open makes no difference to this issue, as far as I can see.

So right now I have found the safest way for my calculations on the lower timeframe, in indicator builder, is to use this way

Quote:
(iCustom(Symbol(),PERIOD_M30,"Indicator", "-----Alert Settings-----", FALSE, FALSE, "alert.wave", FALSE, 17,2,i+1)< iCustom(Symbol(),PERIOD_M30,"Indicator", "-----Alert Settings-----", FALSE, FALSE, "alert.wave", FALSE, 17,2,i+2))&&


over this way

Quote:
(iCustom(NULL,0,"Indicator-M30",2,i+1)< iCustom(NULL,0,"Indicator-M30",2,i+2))&&


It just means I cannot use a hardcoded version of this indicator attach to lower timeframe for visual use. Just have to look at the higher timeframe of that indicator by looking at the higher timeframe chart manually, when referencing back. Or even if I do use it visually, I just have to sync it's higher timeframe it uses first to be sure am visually seeing correct things :)

I just have one question, when we send a hardcoded period like PERIOD_M30 to an indicator, is this in effect replacing wherever the indicator uses 0 for timeframe references to PERIOD_M30 :?:


Top
 Profile  
 
 Post subject: Re: Importing Indicator from IB into SB Issue for BUY and SELL
PostPosted: Sat Aug 24, 2013 7:31 pm 
Offline

Joined: Mon Dec 26, 2011 5:41 am
Posts: 46
Quote:
Quote:
Quote:
(iCustom(NULL,0,"Indicator-M30",2,i+1)<iCustom(NULL,0,"Indicator-M30",2,i+2))&& etc ...



That does not seem correct. the i+1 is a format for creating the indicator but not for using it. When you use it you use the numbers only to indicate the bar that will be used to get the indicator value (1 is the previous bar, 0 current bar)



am not sure am with you here. When using the Indicator Builder, it adds the i+1, i+2 etc ... I add open, it puts open[i], open[1], it puts open[i+1]. The manual of indicator builder does not say we have to remove the i when using the indicator builder. So I just save, validate, and generate mql4 code. The mql4 code does show the shifts with i in them. But the ex4 generated works for me as it paints on chart where I expect it to paint.


Looking at the mql4 that Indicator Builder generates, in start(), it uses the variable i, replacing it from Bars-Counted_bars-1; or i = Bars -1 -FixZeroD; looped all the way down to zero. So the use is correct as far as I see :|


Top
 Profile  
 
 Post subject: Re: Importing Indicator from IB into SB Issue for BUY and SELL
PostPosted: Mon Aug 26, 2013 9:46 am 
Offline

Joined: Tue Dec 22, 2009 12:22 am
Posts: 1761
Sorry. It is too difficult to help you without the strategy files. I thought you were using i+... in the strategy builder. Send us an email with the files an a short explanation of the ea.


Top
 Profile  
 
 Post subject: Re: Importing Indicator from IB into SB Issue for BUY and SELL
PostPosted: Sat Aug 31, 2013 4:56 pm 
Offline

Joined: Mon Dec 26, 2011 5:41 am
Posts: 46
thank you for the email feedback. I actually had completed bars to true before. the indicator arrows and EA trades were matching then. Changed to ticks after this post at http://www.molanis.com/forum/posting.php?mode=reply&f=3&t=5948 . I see from http://www.marketcalls.in/metatrader/how-to-setup-tick-charts-in-metatrader-4.html that we can also view tick charts. Can such a chart reflect what the EA sees when it trades every tick :?:


Last edited by louisfrenchy on Sat Aug 31, 2013 8:45 pm, edited 2 times in total.

Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 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