Hi all,
and thanks in advance for everyone who's givin' up his time supportin' the community...!!!
My problem:
I got the Supertrend-Indicator
https://www.mql5.com/en/code/576
and I wanna work with his indicator data. But when I try to use it in an EA via iCustom() I don't get the right values...!?
I tested it in Strategy Tester & checked, that the indicator itself produce the correct data - I can see it in the data window. But for an unkown reason it didn't pass it correctly to my EA.
So I set up an EA which does nothing except printing the actuell value to the journal. I guess it's just a "beginner fault" - can you please make my day & give me a good advice?!?! Thx...
Attached is the EA...
Greetings
Lupo
CopyBuffer(SuperTrendHandle,2,0,20,Supertrend);
You also need to add error checking when using CopyBuffer().
Hi angevoyageur,
sorry for the delay, was hooked up in another project.
And MANY THANKS for the solution!
After getting your reply this morrning - for some reason I don't get a notification... - I thought:"Ok, that is a typical beginners fault..."
Thanks again & have a nice weekend!
Lupo
Hi angevoyageur,
sorry for the delay, was hooked up in another project.
And MANY THANKS for the solution!
After getting your reply this morrning - for some reason I don't get a notification... - I thought:"Ok, that is a typical beginners fault..."
Thanks again & have a nice weekend!
Lupo
Hi angavoygeur or anybody else who can help me!!!
I thought I got it, but there are new questions... ;-)
When I put in the EA just a
he gives me values like
2014.12.17 10:50:37.342 2014.12.03 20:00:00 Supertrend(1): 9.881312916824931e-324
but in debugging I can see that Supertrend[1] gives correct values. And also if i print directly from the indicator in tester the values he shows the correct values, e.g.:
2014.12.17 11:11:42.046 2014.12.03 05:13:40 Supertrend[11851]: 1.240622
And the EA is working after the changes provided by angevoyageur!??
I had written another custom indicator to see if I can catch it by my own. Just a
Middle=((high[i]+low[i])/2)
When I call him plain from an EA, print the values to the journal I got crap like above - when I print it from the indicator directly the values are ok...
And last question - for now! ;-) - , which I also don't get:
when I test ANY indicator from 2014-12-01 until 2014-12-16 on e.g. EURUSD oer also USDJPY he just test until the 2014-12-08!!?? I sdid it with the supertrend, with other custom indicators of mine & also with the the build-in BBs!? Never experienced this! Can anybody confirm...
I dont't understand the above!!! Can somebody help me see clearer - BIG THANKS IN ADVANCE!
Lupo
Hi angavoygeur or anybody else who can help me!!!
I thought I got it, but there are new questions... ;-)
When I put in the EA just a
he gives me values like
but in debugging I can see that Supertrend[1] gives correct values. And also if i print directly from the indicator in tester the values he shows the correct values, e.g.:
And the EA is working after the changes provided by angevoyageur!??
I had written another custom indicator to see if I can catch it by my own. Just a
Middle=((high[i]+low[i])/2)
When I call him plain from an EA, print the values to the journal I got crap like above - when I print it from the indicator directly the values are ok...
And last question - for now! ;-) - , which I also don't get:
when I test ANY indicator from 2014-12-01 until 2014-12-16 on e.g. EURUSD oer also USDJPY he just test until the 2014-12-08!!?? I sdid it with the supertrend, with other custom indicators of mine & also with the the build-in BBs!? Never experienced this! Can anybody confirm...
I dont't understand the above!!! Can somebody help me see clearer - BIG THANKS IN ADVANCE!
Lupo
Hi!
THANKS! After reviewing my code I have found the error...damn (incorrect) templates of mine! ;-)
Now I got the right values in the journal...
...but still I am not able to test indicators from beginning december 'til now?
That is nothing what is an actual problem for me, but I didn't understand it!
So maybe you can enlight me with this?
Lupo
EDIT:
After testing an EA I found the same: the backtest stops...
13:01:36.006 Trade 2014.12.08 23:59:59 position closed due end of test at 1.23185 [sell 0.10 EURUSD 1.23106]
Hello Anyone!
I have a similar problem to this...and I'm going crazy.
I use iCustom() fairly regularly but on this one occasion, when I use the custom indicator in an expert the indicator returns (slightly but) wrong values!
When I look at the chart window generated when using the expert, my custom indicator shows the "correct" value on both the GRAPH and DATA WINDOW.
Expert is printing a log file for every (4H) bar, which shows the "incorrect" returned value.
Q: How can the indicator, using iCustom(), draw one curve on graph but, at the same time, return different data?
I don't think it is a shift error, nor a rounding error. Even if it were it would produce same answer in both graph and return value.
EXPERT code ( NOTE: shift=1 on iCustom() ):
double BLUE_SAR_BUFF[5]; //global var
...
BLUE_SAR_BUFF[2] = BLUE_SAR_BUFF[1];
BLUE_SAR_BUFF[1] = BLUE_SAR_BUFF[0];
BLUE_SAR_BUFF[0] = iCustom( tsymbol, tsymbolPERIOD, "AA_PeakPSAR_bryv", BLUE_SAR_STEP, BLUE_SAR_MAX, BLUE_SAR_BARS, BLUE_SAR_FACTOR, RED_SAR_STEP, RED_SAR_MAX, RED_SAR_BARS, RED_SAR_FACTOR,
VIOLET_SAR_Step, VIOLET_SAR_MAX , VIOLET_SAR_BARS, VIOLET_SAR_STEPFACTOR, YELLOW_SAR_STEP_dn, YELLOW_SAR_MAX_dn, YELLOW_SAR_BARS_dn, YELLOW_SAR_STEPFACTOR_dn, 0, 1);
Print( " BLUE_SAR_BUFF[0] = ", BLUE_SAR_BUFF[0] );
Print( " BLUE_SAR_BUFF[1] = ", BLUE_SAR_BUFF[1] );
Print( " BLUE_SAR_BUFF[2] = ", BLUE_SAR_BUFF[2] );
LOG FILE PRINTS:
0 15:06:05.092 2007.06.21 12:00:00 AA52_gen XAUUSD,H4: BLUE_SAR_BUFF[0] = 648.4901117169277
0 15:06:05.092 2007.06.21 12:00:00 AA52_gen XAUUSD,H4: BLUE_SAR_BUFF[1] = 648.3811515047178
0 15:06:05.092 2007.06.21 12:00:00 AA52_gen XAUUSD,H4: BLUE_SAR_BUFF[2] = 648.2712571908399
See file attached. Note time is 12:00 because of time shift.
Any suggestion please?
regards,
Alex
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi all,
and thanks in advance for everyone who's givin' up his time supportin' the community...!!!
My problem:
I got the Supertrend-Indicator
https://www.mql5.com/en/code/576
and I wanna work with his indicator data. But when I try to use it in an EA via iCustom() I don't get the right values...!?
I tested it in Strategy Tester & checked, that the indicator itself produce the correct data - I can see it in the data window. But for an unkown reason it didn't pass it correctly to my EA.
So I set up an EA which does nothing except printing the actuell value to the journal. I guess it's just a "beginner fault" - can you please make my day & give me a good advice?!?! Thx...
Attached is the EA...
Greetings
Lupo
//| Supertrend Check |
//| Marc |
//| |
//+------------------------------------------------------------------+
#property copyright "Marc"
#property link ""
#property description "Supertrend_Check v0.1"
//+------------------------------------------------------------------+
//|Global variables |
//+------------------------------------------------------------------+
int SuperTrendHandle; //handle
double Supertrend[]; //dynamic array to store the indicator values
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- Get handle for SuperTrend indicator
SuperTrendHandle=iCustom(NULL,0,"supertrend",10,3,false);
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//--- Supertrend START
//--- check for errors
if(SuperTrendHandle<0)
{
Alert("Error Creating Handles for SuperTrend - error: ",GetLastError(),"!!");
}
//--- filling arrays with current values of iCustom
//--- Copying elements
CopyBuffer(SuperTrendHandle,0,0,20,Supertrend);
//--- set indexing of elements as series
ArraySetAsSeries(Supertrend,true);
//--- SuperTrend END
//--- for debugging
Print("Supertrend: ",Supertrend[0]);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---Indicator release
IndicatorRelease(SuperTrendHandle);
}
//+------------------------------------------------------------------+