How to calculate indicator buffer only once per day mql4

How to calculate indicator buffer only once per day mql4

Manage alerts

Loading saved threads...

Sajjad Hossain Sagor · External communityPost link
External question — Stack Overflow Stack Exchange Author: Sajjad Hossain Sagor Original post: https://stackoverflow.com/questions/63865702 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 have an indicator which gives one signal [Down Buffer]... I wish to only give signal once per day... Like after the first signal it will not paint any signal for the rest of the day! I have tested with below code it's now not painting at all? //--- indicator buffers double Buffer1[]; int day = 0; int OnInit() { ........................ } int OnCalculate(......) { //--- main loop for(int i = limit-1; i >= 0; i--) { //Indicator Buffer 1 if( here goes my condition ) { if( day != Day() ) { Buffer1[i] = High[i] + iATR(NULL, PERIOD_CURRENT, 14, i); //Set indicator value at Candlestick High + Average True Range day = Day(); } } else { Buffer1[i] = EMPTY_VALUE; } } return(rates_total); } What is wrong with my code? It's now not showing any signal at all... Note : I have removed some of the code to make it simple...
Quote
Report
TheLastStark · External communityPost link
External answer — Stack Overflow Stack Exchange Author: TheLastStark Original post: https://stackoverflow.com/a/63995167 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. Use the following function to check whether it is a new day. It returns true if it is a new day, else returns false. bool IsNewDay(){ static datetime prevDay = -1; if( iTime(_Symbol, PERIOD_D1, 0) == prevDay ) return false; prevDay = iTime(_Symbol, PERIOD_D1, 0); return true; }
Quote
Report

Post Reply

Checking account access…