Forex



Go Back   Forex Trading > Training > Metatrader > Metatrader 4 mql 4 - Development course > Questions
Forex Forum Register More recent Calendar Advertising Others Help






Register
Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.

From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.

Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
  • Elite Section
    Get access to private discussions, specialized support, indicators and trading systems reported every week.
  • Advanced Elite Section
    For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
See more

Reply
 
Thread Tools Display Modes
  #1491 (permalink)  
Old 05-12-2009, 02:13 AM
Senior Member
 
Join Date: Nov 2006
Posts: 308
luxinterior is on a distinguished road
Quote:
Originally Posted by JForex78 View Post
Totally makes sense. How will you see a M5 10MA on a H1 chart?

10/12=0.84. Can you put a 0.84 MA on a H1 chart? No.

It works the other way though - H1 10MA = M5 120MA.

So my question is, how do I see a cross of 5MA on a higher Timeframe like H4.

Thanks.
You could use the iMA function and write your own MA indicator. Just set the time frame to H4 and drop it on your 5M chart. You'd have to do some extra coding to draw the same level for every 48 5M bars too. Not sure how much help an indicator like this would be but haven't looked at it too much.

Lux
__________________
Build An Expert Advisor. FREE E-course As Seen On TV
ForexArea.com
Users of Gap Trader from 'Forex-Assistant' MUST Read This

Last edited by luxinterior; 05-12-2009 at 02:16 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #1492 (permalink)  
Old 05-12-2009, 03:00 AM
Junior Member
 
Join Date: Feb 2009
Location: Perth, Oz
Posts: 19
Couso is on a distinguished road
Indicator crashing MT4

(Orginally posted in the Digital Filters/ Jurik thread)

Hi folks, I'm in desperate need of some coder assistance.

I've been loving these Jurik tools, but I've hit a wall and my hair is coming out in clumps trying to get past this... The real killer is that this code initially worked, then as I developed a bit more it all went wrong and now I can't even revert without drama.

The situation is this: I took the JMA and patched together a MTF indicator based on the iMax MTF I found here - sorry I can't remember who wrote that one, but thanks, it's sweet. It worked fine until I got a bit clever and tried to incorporate two JMAs with different length into the calculation. The two versions are below.

Ever since I made the second mod this indicator and some others, plus an EA with JMA in it cause MT4 to crash immediately and even commenting out all the JMA doesn't help.

All the JMA indicators from here still work fine, so that suggests to me it's an issue of the code rather than the JMA - well, obviously... Hopefully it's either the way I'm calling the JMA function (although it worked before) or there's some fatal error like an infinite loop or whatever. It compiles, but crashes MT4 straight away...

The first attachment is an old version and it works, so you can see what I'm trying to do - but I don't have that mq4 any more, sorry. The current mq4 'should' be the same, but crashes, and the real indicator I'm trying to achieve is the final file, JMA2- which also crashes. Come on gurus, I'm crossing my fingers,

rjc.
Attached Files
File Type: ex4 JMA MTF DETECTOR.ex4 (11.0 KB, 6 views)
File Type: mq4 JMA MTF DETECTOR.mq4 (11.7 KB, 11 views)
File Type: mq4 JMA2 MTF DETECTOR.mq4 (16.0 KB, 8 views)
File Type: mq4 JMA.mq4 (10.7 KB, 9 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #1493 (permalink)  
Old 05-12-2009, 03:34 AM
wolfe's Avatar
Senior Member
 
Join Date: Jan 2006
Posts: 820
wolfe is on a distinguished road
Quote:
I will try with yours Wolfe, if I don't see a trade soon.

Thanks
Chili
Good luck Chili.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #1494 (permalink)  
Old 05-12-2009, 05:59 AM
1Dave7's Avatar
Senior Member
 
Join Date: Aug 2007
Posts: 183
1Dave7 is on a distinguished road
Red face Programming SundayStartUp of EA

Variables used - StartDay=0, StartHour=5, StartMinute =30.

PHP Code:
 if(UseSundayStartup==true)
 
         {
      if (!(
Day()>=StartDay))     
         {
Comment("Day Start Time Not Yet!");
         return(
0);}      
      else if(!(
Hour()>=StartHour))      
         {
Comment("Day Start Time Not Yet!");
         return(
0);}      
      else if(!(
Minute()>=StartMinute)){
         
Comment("Day Start Time Not Yet!");
         return(
0);
         }
         } 
It works ok to start the Sunday. Problem happens that if I need to or have to reboot the system during the week for whatever reason, the system returns to the Comment("Day Start Time Not Yet!").

I have not been able to resolve this problem - Any suggestions on code to allow the program to run if rebooted at a later date with a earlier Hour and Minute??

Dave
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #1495 (permalink)  
Old 05-12-2009, 10:54 AM
Senior Member
 
Join Date: Nov 2006
Posts: 308
luxinterior is on a distinguished road
Take a look at global variables or you could write to a file.

Lux
__________________
Build An Expert Advisor. FREE E-course As Seen On TV
ForexArea.com
Users of Gap Trader from 'Forex-Assistant' MUST Read This
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #1496 (permalink)  
Old 05-12-2009, 07:10 PM
Junior Member
 
Join Date: Apr 2009
Posts: 3
MSV_Trader is on a distinguished road
Please help me !

Hi all,

Please i really need some help coding this to MQ4 since i´m switching platform from Tradestation to Metatrader and need this to be coded, somebody can help me.

The indicator uses 2 built in functions from Tradestation they are SummationFC and AverageFC, but i don´t know if they are really necessary in MQ4.

Here is the code for both functions :

SummationFC

inputs:
Price( numericseries ),
Length( numericsimple ) ; { this input is assumed to be constant }
variables:
Sum( 0 ) ;
if CurrentBar = 1 then
begin
for Value1 = 0 to Length - 1
begin
Sum = Sum + Price[Value1] ;
end ;
end
else
Sum = Sum[1] + Price - Price[Length] ;
SummationFC = Sum ;

AverageFC

inputs:
Price( numericseries ),
Length( numericsimple ) ; { this input is assumed to be a constant >= 1; will get
divide-by-zero error if Length = 0 }
AverageFC = SummationFC( Price, Length ) / Length ;


Now this is a function that the indicator uses to calculate the value, so then he can paintbar : The name is eggvr

Inputs: avgrange(NUMERIC),Factor(NUMERIC);
Variables: Variable1(0), Variable2(0), Variable3(CLOSE), Variable4(CLOSE);
Variables: Variable5(CLOSE), Variable6(0);

IF true THEN
BEGIN
;
Variable2 = Factor*(AVERAGEFC (RANGE, avgrange)) ;
IF CURRENTBAR = 1 THEN
BEGIN
Variable4 = CLOSE+Variable2 ;
Variable3 = CLOSE-Variable2 ;
Variable1 = 0 ;
END ;

IF Variable1[1] = 1 THEN
BEGIN
Variable3 = Variable5-Variable2 ;
eggvr = Variable3 ;
IF CLOSE > Variable5 THEN Variable5 = CLOSE ;
IF CLOSE < Variable3 THEN
BEGIN
Variable6 = CLOSE ;
Variable4 = CLOSE+Variable2 ;
Variable1 =-1 ;
END ;

END ;

IF Variable1[1] =-1 THEN
BEGIN
Variable4 = Variable6+Variable2 ;
eggvr = Variable4 ;
IF CLOSE < Variable6 THEN Variable6 = CLOSE ;
IF CLOSE > Variable4 THEN
BEGIN
Variable5 = CLOSE ;
Variable3 = CLOSE-Variable2 ;
Variable1 = 1 ;
END ;

END ;

IF Variable1 = 0 THEN
BEGIN
eggvr = CLOSE ;
IF CLOSE > Variable4 THEN
BEGIN
Variable5 = CLOSE ;
Variable3 = CLOSE-Variable2 ;
Variable1 = 1 ;
END ;

IF CLOSE < Variable3 THEN
BEGIN
Variable6 = CLOSE ;
Variable4 = CLOSE+Variable2 ;
Variable1 =-1 ;
END ;

END ;

END ;


Now this is the paintbar indicator:


Inputs: AvgRange(100) ,Sensitivity(2), UpColor(blue), DnColor(red);

Variables: DIR(0), Value1(0), Fract(0);
Variables: Setbar(0), textID(- 1), TxtColor(0);


Value1 = eggvr (AvgRange, Sensitivity) ;

if Value1 = CLOSE then Value1 = Value1[1] ;
if rangevector = 1 then
begin
if CLOSE <> Value1 OR CLOSE = Value1 then
begin
PLOTPAINTBAR (HIGH, LOW, "Trend") ;
end ;

if Value1 <> 0 then
begin
if CLOSE > Value1 then SETPLOTCOLOR (1, UpColor) ;
if CLOSE < Value1 then SETPLOTCOLOR (1, DnColor) ;
end ;

end ;

-----------------------------------------------------------------------


Please i need desesperately help in coding this, i think there is no need of having, like in TS, this functions and indicator separated.

Many thanks in advance, best regards

Msv_Trader
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #1497 (permalink)  
Old 05-13-2009, 02:39 AM
Member
 
Join Date: Jan 2009
Posts: 33
JForex78 is on a distinguished road
Quote:
Originally Posted by luxinterior View Post
You could use the iMA function and write your own MA indicator. Just set the time frame to H4 and drop it on your 5M chart. You'd have to do some extra coding to draw the same level for every 48 5M bars too. Not sure how much help an indicator like this would be but haven't looked at it too much.

Lux
Well, I wrote an indicator that can actually draw a M5 MA cross on higher chart like H4.

Its attached to higher TF chart (H4), calculates MA cross on Period_M5, and then draws the cross on the correct H4 bar using iBarShift(NULL,Period(),Time[i],false);

Its working the way I want it to.

Thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #1498 (permalink)  
Old 05-14-2009, 12:51 PM
Junior Member
 
Join Date: Apr 2009
Posts: 5
atkfam is on a distinguished road
Quote:
Originally Posted by Couso View Post
(Orginally posted in the Digital Filters/ Jurik thread)

...
All the JMA indicators from here still work fine, so that suggests to me it's an issue of the code rather than the JMA - well, obviously... Hopefully it's either the way I'm calling the JMA function (although it worked before) or there's some fatal error like an infinite loop or whatever. It compiles, but crashes MT4 straight away...


rjc.
Couso,

I haven't seen any guru responding but JMA Weld/JurikRes is notoriously buggy. I've been throu similar issues myself so I switched to JMA_StarLight (by Kositsin) with much better memory comsumption and performance. Same guy has posted a whole library of JMA-type smoothing tools on MQL4 dot com forum for most common indicators. Search for "Effective Averaging Algorithms" and it will bring you to his article with code samples. Good luck.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #1499 (permalink)  
Old 05-22-2009, 02:49 PM
Junior Member
 
Join Date: May 2009
Posts: 10
medc77 is on a distinguished road
Exclamation basic questions

I'm new to MQL and I'm trying to familiarize myself with the language. I come from technical analysis using Amibroker's AFL scripting language. I also have experience with php but no experience programming C so please bare with me.

My questions about this code are very basic and general in nature, but I think they're essential to understanding how MQL works. Perhaps you should include a topic in your very informative tutorial.

Question 1: what is the purpose of using return(0) and return(-1) inside an if statement or within the start() function?

Question 2: In other scripting languages that i'm familiar with, after you execute your logic and calculations and you want to display the information in a chart you would have to use a function such as Plot(yourresults) so that the chart window knows what to plot. However, this is not evident to me in the code posted below. When this code executes, how does Metatrader know what information to plot in the chart window?

Question 3: I see in many MQL indicators and advisors the use of "buffer" variables. what is the purpose of this?


Code:
//+------------------------------------------------------------------+
//|                                                          AMA.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, by konKop,wellx"
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Sienna
#property indicator_color2 DeepSkyBlue
#property indicator_color3 Gold

//---- input parameters
extern int       periodAMA=9;
extern int       nfast=2;
extern int       nslow=30;
extern double    G=2.0;
extern double    dK=2.0; 

//---- buffers
double kAMAbuffer[];
double kAMAupsig[];
double kAMAdownsig[];

//+------------------------------------------------------------------+

int    cbars=0, prevbars=0, prevtime=0;

double slowSC,fastSC;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE,0,2);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,159);
   SetIndexStyle(2,DRAW_ARROW);
   SetIndexArrow(2,159);
   //SetIndexDrawBegin(0,nslow+nfast);
   SetIndexBuffer(0,kAMAbuffer);
   SetIndexBuffer(1,kAMAupsig);
   SetIndexBuffer(2,kAMAdownsig);
   
   
   IndicatorDigits(4);

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    i,pos=0;
   double noise=0.000000001,AMA,AMA0,signal,ER;
   double dSC,ERSC,SSC,ddK;
   
   if (prevbars==Bars) return(0);
    
//---- TODO: add your code here
   slowSC=(2.0 /(nslow+1));
   fastSC=(2.0 /(nfast+1));
   cbars=IndicatorCounted();
   if (Bars<=(periodAMA+2)) return(0);
//---- check for possible errors
   if (cbars<0) return(-1);
//---- last counted bar will be recounted
   if (cbars>0) cbars--;
   pos=Bars-periodAMA-2;
   AMA0=Close[pos+1];
   while (pos>=0)
     {
      if(pos==Bars-periodAMA-2) AMA0=Close[pos+1];
      signal=MathAbs(Close[pos]-Close[pos+periodAMA]);
      noise=0.000000001;
      for(i=0;i<periodAMA;i++)
       {
        noise=noise+MathAbs(Close[pos+i]-Close[pos+i+1]);
       }
      ER =signal/noise;
      dSC=(fastSC-slowSC);
      ERSC=ER*dSC;
      SSC=ERSC+slowSC;
      AMA=AMA0+(MathPow(SSC,G)*(Close[pos]-AMA0));
      kAMAbuffer[pos]=AMA;

      ddK=(AMA-AMA0);
      if ((MathAbs(ddK)) > (dK*Point) && (ddK > 0)) kAMAupsig[pos] =AMA; else kAMAupsig[pos]=0;
      if ((MathAbs(ddK)) > (dK*Point) && (ddK < 0)) kAMAdownsig[pos]=AMA; else kAMAdownsig[pos]=0; 

     
      AMA0=AMA;
      pos--;
     }
//----
   prevbars=Bars;
   return(0);
  }
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #1500 (permalink)  
Old 05-23-2009, 07:49 PM
Junior Member
 
Join Date: Jun 2008
Posts: 1
moshilion is on a distinguished road
scanning a list if symbols

Hi all,

who could explain me the way to scan a list of symbols with mt4 ( the 40 firms of the CAC40 for instance) with an EA.

I would have in result the symbols which match the pattern included in EA.

Difficult for me to write in english, sorry
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
Reply

Bookmarks

Tags
forex, histogram, JMASlope, ToR 1.20, ZUP_v1.mq4


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump


All times are GMT. The time now is 10:39 PM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.