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.
I'm a fair programmer but new to mql4. I'm working on a box trade (aka breakout trade) expert adviser. Essentially it should find the highest and lowest values for a specific time frame, and when a candle closes outside of that box I place a trade.
Essentially there are three states, I can start my EA in
1) after the close of the previous day, and before the box start time.
2) after the start of the box but before the end of the box.
3) after the end of the box.
What I find confusing is the Time[] array because the index keeps changing. Assume I enter at state 2. In the init function I was going to set a global variable giving the position of the start of the box. As quotes come in my start function is constantly called, and once the end of the box time was reached I would have the start and end positions. Of course that is not the case as the index on the Time array keeps rolling forward.
At best I can keep incrementing the position of the box start index, but that doesn't seem a very clean way to do things.
If you have a suggestion on how I should change my thinking away traditional c/c++ to mql4 I'd love to hear it.
Also when I'm done I would obviously benefit greatly from a code review by a more senior programmer. Would anyone like to volunteer for that?
I'm a fair programmer but new to mql4. I'm working on a box trade (aka breakout trade) expert adviser. Essentially it should find the highest and lowest values for a specific time frame, and when a candle closes outside of that box I place a trade.
Essentially there are three states, I can start my EA in
1) after the close of the previous day, and before the box start time.
2) after the start of the box but before the end of the box.
3) after the end of the box.
What I find confusing is the Time[] array because the index keeps changing. Assume I enter at state 2. In the init function I was going to set a global variable giving the position of the start of the box. As quotes come in my start function is constantly called, and once the end of the box time was reached I would have the start and end positions. Of course that is not the case as the index on the Time array keeps rolling forward.
At best I can keep incrementing the position of the box start index, but that doesn't seem a very clean way to do things.
If you have a suggestion on how I should change my thinking away traditional c/c++ to mql4 I'd love to hear it.
Also when I'm done I would obviously benefit greatly from a code review by a more senior programmer. Would anyone like to volunteer for that?
Thanks for your time,
Markus
Hi. The Time[] function does not keep changing - only at the end of the current chart bar does it change. TimeCurrent() on the other hand returns a continuously changing value (albeit, with a 1 sec resolution).
You can get the exact time of any bar and timeframe using iTime() as well. There's quite a few ways to go about it...
I would like to code an indicator for compute the close value wich create a reversal of an indicator like HMA. For that i need to create a function for compute one value of HMA with a close values tab where i modify the current value in an dichotomy loop to find the value wich create the reversal.
Somebody can help me with my ComputeHull function ?
Here my code, without dichotomy reseach it is just a simple HMA indicator with computeHull function, the indicator is displayed but it is shifted down
Regards
//#property indicator_separate_window
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Blue
//---- input parameters
extern int HullAntPeriod=12;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- 1 additional buffers are used for temporary data.
IndicatorBuffers(3);
//---- drawing settings
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_NONE);
//---- 2 indicator buffers mapping
SetIndexBuffer(0,HullAntBuf);
SetIndexBuffer(1,TempBuf1);
SetIndexBuffer(2,TempBuf2);
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("HULL ANTICIP("+HullAntPeriod+")");
SetIndexLabel(0,"HULL ANTICIPATION");
SetIndexLabel(1,NULL);
SetIndexLabel(2,NULL);
//---- Specific indicator initialization
HalfHullAntPeriod = MathFloor(HullAntPeriod/2);
SqrtHullAntPeriod = MathFloor(MathSqrt(HullAntPeriod));
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int bar, limit, i;
int counted_bars=IndicatorCounted();