you have already written the pseudocode.
should be an easy task to convert to mql code.
static double total=0; static double tickcount=0; static double avg=0; total+=Bid; tickcount++; static datetime curr=0; if(curr!=Time[0]){ curr=Time[0]; avg=total/tickcount; total=0; tickcount=0; }
I tested this and works fine, but I have no idea how to set a timeframe (to anylize the average just for 1 hour)
static double TotalSUM = 0; // the total amount of money of all the bids
static double Average = 0; // The average price
static int counter = 0; // The total number of tick per unit time
int start()
{
double Price = Bid;
TotalSUM += Bid;
counter++;
Average = (TotalSUM/counter);
Alert("New tick ",counter," Price = ",Price, " TotalSUM = ",TotalSUM," Average Price is =", Average);
return(0);
}
Can we just use a MA?
- 1 MINUTE PERIOD
- LAST 60 PERIODS (MINUTES)
- APPLIED AT: PRICE_MEDIAN
iMA("EURUSD",PERIOD_M1,60,0,MODE_SMA,PRICE_MEDIAN,0);
thks.
NIERO
Hi Dario, "MA" means "Moving Average". Its a widely used tecnical indicator.
You can start some about https://www.metatrader5.com/en/terminal/help/indicators/trend_indicators/ma
what it is an MA??
[]'s
Daniel Niero
Hi Dario, "MA" means "Moving Average". Its a widely used tecnical indicator.
You can start some about https://www.metatrader5.com/en/terminal/help/indicators/trend_indicators/ma
[]'s
Daniel Niero
Thank you
This is exactly the type of Expert Advisor I am trying to develop, maybe you know where I can find one ready to download? I am sure it is a classic coded EA
Dario
I found the Moving Average in the list of ready to use EA of the MT4 platform, now I would like to understand more of its code:
what does it means:
#define MAGICMA 20050610
![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
I want to calculate the average price of curreny EUR/USD for the first hour of the trade,
mathematically this is achieved as follow:
TotalSum = everyTick price
Then the TotalSum is divided by the number of Ticks added to each other.
How do I implement this into an EA?