All I can say is : if there is a bug, it's in your code. Debug it ?
double movingaverage = iMA(Symbol(),0,2,0,MODE_LWMA,0,0); double selldistance = MathFloor(MathAbs((Bid-average)/Point)) ; double buydistance = MathFloor(MathAbs((average-Ask)/Point)) ;
Forum on trading, automated trading systems and testing trading strategies
Hello,
Please EDIT your post and use the SRC button when you post code.
double movingaverage = iMA(Symbol(),0,2,0,MODE_LWMA,0,0); double selldistance = MathFloor(MathAbs((Bid-movingaverage)/Point)) ; double buydistance = MathFloor(MathAbs((movingaverage-Ask)/Point)) ;
Thanks for pointing that typo out.
1. Can you provide any way to get the exact correct ima data as per the pictures attached ?
Seems like its supposed to work as intended, yet its still not working for some reason. Need the exact data on the Value field of the moving average box in variable form. Is this what is supposed to be returned by the
iMA(Symbol(),0,2,0,MODE_LWMA,0,0);
?
2. Im running MT4 under Wine in Debian 9, which may be the reason for this apparent glitchism. If you can confirm that the yellow box's value field in the second picture is indeed correctly returned by the above iMA command in other OS's, then its definately a Wine issue and I should look maybe at a custom indicator
Its Wine then?

- 2009.11.23
- Комбинатор
- www.mql5.com
Notice in the movingaverage calculation, in the Timeframe, I put a 0 there instead of the 1 (1m) which is the one that should work, because putting PERIOD_M1 or 1 (default for 1m) gives off the wrong data. Looks like it may even be a bug .
After many hours I found a workaround by setting Timeframe to 0 and just attaching the EA to a chart that is already set to 1m timeframe instead . However, it works only like half the time.
Ive included 2 screenshots to make it more clear what I want:. The first picture is of the actual moving average settings in the dialogue window that I need in variable form so I can place orders at a distance from it.
Does it "work" on all the sell orders, but not the buys?
I can't recreate a problem:
int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { double ma_value=iMA(_Symbol,PERIOD_CURRENT,2,0,MODE_LWMA,PRICE_CLOSE,0); Comment(DoubleToString(ma_value,_Digits)); return(rates_total); }

Does it "work" on all the sell orders, but not the buys?
Ive confirmed its independent of what type of order is placed.
Ive confirmed once more, its independent of order placement.
Its a problem with the actual returned value of the following commands:
As I said, I can't recreate the issue. I think your problem is elsewhere.
int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { double ma_value1=iMA(_Symbol,PERIOD_CURRENT,2,0,MODE_LWMA,PRICE_CLOSE,0), ma_value2=iMA(Symbol(),1,2,0,MODE_LWMA,0,0), ma_value3=iMA(Symbol(),PERIOD_M1,2,0,MODE_LWMA,0,0), ma_value4=iMA(Symbol(),0,2,0,MODE_LWMA,0,0); string text=DoubleToString(ma_value1,_Digits)+"\n"; text+=DoubleToString(ma_value2,_Digits)+"\n"; text+=DoubleToString(ma_value3,_Digits)+"\n"; text+=DoubleToString(ma_value4,_Digits); Comment(text); return(rates_total); }
OK its just Wine then.
OK its just Wine then.
Thanks all .
God bless
Why don't you try the code I posted on Wine?
I don't have a linux box running right now to test.
Why don't you try the code I posted on Wine?
I don't have a linux box running right now to test.
I've created:
1. Custom Indicator with your code, which I've attached (average.mq4)
2. A Test EA (icustomcallwithalert.mq4) with the call to your Custom Indicator code to test it out.
Your code indicator (average.mq4) works perfect when its being used on its own on a chart. However, when I try to call it in Test EA (icustomcallwithalert.mq4) with :
double realaverage = iCustom(Symbol(), 0, "average.ex4", 0, 0);
all I get is a weird 2123412.00 value, which I've included in the Screen-shot (more wine glitch or not.png). Never used iCustom before; is this being executed correctly?
Notice correct value in the top left of the chart because I'm using the custom indicator on it, however when I call it with the test ea function call through alert, all I get is that 21123424.00 . Its in the Indicator folder.
Ive never done this before, so dont know if its more bad whine or more bad wine?

- 2009.11.23
- Комбинатор
- www.mql5.com

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
How do I code the movingaverage variable so that it gives the exact correct data ?
In other words , I cant correctly retrieve the iMA data.
Searched online and cant find a solution. These are my variables:
Notice in the movingaverage calculation, in the Timeframe, I put a 0 there instead of the 1 (1m) which is the one that should work, because putting PERIOD_M1 or 1 (default for 1m) gives off the wrong data. Looks like it may even be a bug .
After many hours I found a workaround by setting Timeframe to 0 and just attaching the EA to a chart that is already set to 1m timeframe instead . However, it works only like half the time.
Ive included 2 screenshots to make it more clear what I want:. The first picture is of the actual moving average settings in the dialogue window that I need in variable form so I can place orders at a distance from it.
The second screen is about the actual data per se from chart so its even more clear. its what results from those settings , which I just cant get in variable form.
Thanks in advanced.