How do you write a function that returns the low and the top of the moving average for a specified number of candles in mql4?

How do you write a function that returns the low and the top of the moving average for a specified number of candles in mql4?

Manage alerts

Loading saved threads...

hre007 · External communityPost link
External question — Stack Overflow Stack Exchange Author: hre007 Original post: https://stackoverflow.com/questions/73518024 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I hope someone guides me, I want to calculate the lowest moving average level during a certain number of candles, as well as the highest moving average level during a certain number of candles. That is, I want the moving average top and the moving average bottom, not the price. How do I write a function that returns these values ​​to me? Thank you for your interest and help
Quote
Report
PaulB · External communityPost link
External answer — Stack Overflow Stack Exchange Author: PaulB Original post: https://stackoverflow.com/a/73543541 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. You should try to attempt to write the code yourself, you will learn a lot more and get more help along the way when you hit any problems. int startCandle=1; int endCandle=100; double highest=NULL, lowest=NULL; for(int i=startCandle; i<=endCandle; i++) { double ma=iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_CLOSE, i); if(highest==NULL){highest=ma; lowest=highest;} if(ma>highest) highest=ma; if(ma<lowest) lowest=ma; }
Quote
Report

Post Reply

Quoted from Forex.com.bd-Editorial External answer — Stack Overflow Stack Exchange Author: PaulB Source score (net votes, not local likes): 1 Original post: https://stackoverflow.com/a/73543541 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. You should try to attempt to write the code yourself, you will learn a lot more and get more help along the way when you hit any problems. int startCandle=1; int endCandle=100; double highest=NULL, lowest=NULL; for(int i=startCandle; i<=endCandle; i++) { double ma=iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_CLOSE, i); if(highest==NULL){highest=ma; lowest=highest;} if(ma>highest) highest=ma; if(ma<lowest) lowest=ma; }

Cancel quote

Checking account access…