How to write a code for smoothing WMA with MA?

 

Dear All,

I am quite fresh to programming and I would appreciate your help. In my EA I use a condition based on smoothed WMA. Could you please help me to write a function that calculates 3 days SMA of 4 days WMA for 1 bar ago, 2 bar ago and 3 bar ago for closing price? Do I need array function for it?

Thank you very much.

Greetings

Qhciu

 
#define WMA_PERIOD 4
double sma=0; int count=0;
for(int shift=1; shift < 4 shift++){
   sma += iMA(NULL,0, WMA_PERIOD, 0, MODE_WMA, PRICE_CLOSE, shift); count++;
}
sma /= count;
Do I need array function for it
Not if you know how to compute SMA.
 

I think that should be MODE_LWMA

 
WHRoeder:
Not if you know how to compute SMA.


Dear WHRoeder,

Thank you very much for fast reply but I still do not know how to implement your suggestions. I would be very gratefull if you colud put the whole code for such trading condition:

Buy if: SMA(external variable_a) of WMA(eternal variable_b) for current bar > SMA(external variable_a) of WMA(eternal variable_b) for (-1) bar AND

SMA(external variable_a) of WMA(eternal variable_b) for (-1) bar > SMA(external variable_a) of WMA(eternal variable_b) for (-2) bar

Close if: SMA(external variable_a) of WMA(eternal variable_b) for current bar < SMA(external variable_a) of WMA(eternal variable_b) for (-1) bar AND

SMA(external variable_a) of WMA(eternal variable_b) for (-1) bar < SMA(external variable_a) of WMA(eternal variable_b) for (-2) bar

Thank you very much in advance

Qhciu

 
No slaves here, Learn to Code or Pay someone.
 
WHRoeder:
No slaves here, Learn to Code or Pay someone.


Hi,

You gave me a "kick" to get down to work and I finally managed to finish it on my own and it works !!! I have one more question. What function should I use if I want to trade on open price of the current bar based on the signal coming from my indicator calculated on the just closed bar?

Thanks

Qhciu

 
Qhciu:
What function should I use if I want to trade on open price of the current bar based on the signal coming from my indicator calculated on the just closed bar?
OrderSend()