- remove your array resizes and add those arrays as buffers in init.
- or resize them correctly.
bool ResizeBuffer(double& buffer[], int size){ if (ArraySize(buffer) != size){ ArraySetAsSeries(buffer, false); // Shift values B[2]=B[1]; B[1]=B[0] if (ArrayResize(buffer, size) <= 0){ trading.disabled = "ArrayResize [1] failed: "+GetLastError() + " Trading disabled."; Alert(trading.disabled); Print(trading.disabled); return(false); } ArraySetAsSeries(buffer, true); } return(true); }
- You have no problem with iCustom - next time use a better title.
Also it might help you to look over the code for that kaufman indicator (KAMA) in the codebase
Thanks guys. I will try putting my arrays as buffers.
@ WHRoeder, I'm not sure that I understand why ArraySetAsSeries is set to false and back again to true in the above function you provided. Could you please explain?
thanks!
Series set to true
Elements A B C D Index 3 2 1 0 Series set to false
Elements A B C D Index 0 1 2 3 Resized
Elements A B C D ? Index 0 1 2 3 4 Series set to true
Elements A B C D ? Index 4 3 2 1 0 Elements Shifted.
Series set to true
Elements A B C D Index 3 2 1 0 Resized
Elements not shifted.Elements ? A B C D Index 4 3 2 1 0
WHRoeder:
Series set to true
Elements A B C D Index 3 2 1 0 Series set to false
Elements A B C D Index 0 1 2 3 Resized
Elements A B C D ? Index 0 1 2 3 4 Series set to true
Elements A B C D ? Index 4 3 2 1 0 Elements Shifted.
Series set to true
Elements A B C D Index 3 2 1 0 Resized
Elements not shifted.Elements ? A B C D Index 4 3 2 1 0
Thanks a lot! Very useful indeed.
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
Hi all,
Recently I have started learning to make custom indicators. I figured that a good learning project would be to make the kaufman adaptive moving average. With the help from the
indicators I found in the the code base and the documentation on this subject I have made the attached indicator. At first sight it seemd to work as it should, but when it is attached to a live chart
or to a chart while testing in visal mode, it doesn't seem to draw correctly.. It does draw, but when the properties window is openend and closed (without changing any parameter) the indicator values on the newly drawn bars
change to, what I believe are the correct values. It seems the values on the historical bars are drawn correctly but the values for newly formed bars are not. At this point I am kind of stuck. I have read
again the documentation on IndicatorCounted ( i think it might have to do with that) but after looking it over and over, I fail to spot the problem.
It would be greatly appreciated if someone could have a look and clear this up for me.