CiIchimoku returns incorrect data. I'm not seeing buffer data as it doesn't seem to be updating m_data_total in CArray
Here is a sample code that might help:
//+------------------------------------------------------------------+ //| Simple Ichimoku system.mq5 | //| Copyright 2022, MetaQuotes Ltd. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2022, MetaQuotes Ltd." #property link "https://www.mql5.com" #property version "1.00" #include <Indicators/Trend.mqh> CiIchimoku*Ichimoku; //+------------------------------------------------------------------+ void OnInit() { Ichimoku = new CiIchimoku(); Ichimoku.Create(_Symbol,PERIOD_CURRENT,9,26,52); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void OnTick() { Ichimoku.Refresh(-1); double TenkanVal= Ichimoku.TenkanSen(0); double KijunVal= Ichimoku.KijunSen(0); double SpanAVal= Ichimoku.SenkouSpanA(-26); double SpanBVal= Ichimoku.SenkouSpanB(-26); double ChikouVal= Ichimoku.ChinkouSpan(26); Comment("Tenkan Sen Value is: ",TenkanVal,"\n", "Kijun Sen Value is: ",KijunVal,"\n", "Senkou Span A Value is: ", SpanAVal,"\n", "Senkou Span B Value is: ",SpanBVal,"\n", "Chikou Span Value is: ",ChikouVal); } //+------------------------------------------------------------------+
I'm not sure the reason for using a pointer at the top? I actually had the code you suggested in earlier, but I was getting errors and was trying to get rid of anything I didn't need. Immediately after posting I thought about this. In any case, it compiled and ran, but gave the same erroneous indicator numbers. I went to debug and this time it showed the correct number of buffers as 5. It therefore looked like it was reading the buffers, but instead gave the the maximum double precision number. Possibly I need to write indicator declarations into the EA? I will search in a bit for more information. Thanks for helping, and if you have any ideas I welcome them.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I'm a little rusty on my coding, but used to code C++ in Qt and KDE. The Medtaeditor reminds me very much of C++. I was coding the Ichimoku editor, and decided I liked the idea of using object oriented programming with CiIchimoku. Right off the bat I noticed that the Chikou data was retrieved by ChinkouSpan. Note the gratuitous "n". I submitted a change on github. After a bunch of clumsy novice mistakes I managed to get my code to compile. When I tested it the idicator data made sense, but the EA didn't place any trades. My debug data was producing indicator numbers that ended in e318, which I believe is like as high as my computer can count. So I made a test EA that was just looking at a few indicator values. It was the same error, so I stepped through debug. in Trendmqh it went to check the buffer, which went to ArrayObj.mqh and CArrayObj::At, which runs some checks. the last of which is to see if the buffer index is >= m_data_total, the total buffers. I decided to read it, and it is always zero. I found I could also check m_step_resize and that returned 16. It looks like I can talk to it, but not read indicator data.
It's possible I'm still doing something stupid, as I'm just learning this and haven't written code for over a decade. I'll attach the file. It would be better if it was my mistake than broken code. Thanks.