- 2022.02.12
- www.mql5.com
Please don't double post! You already have a thread open on this subject! I've answered there.
I try to write it more clearly
#include <stdlib.mqh> #include <stderror.mqh> //--- indicator settings #property indicator_chart_window #property indicator_buffers 2 #property indicator_type1 DRAW_ARROW #property indicator_width1 3 #property indicator_color1 0xFFAA00 #property indicator_label1 "Buy" #property indicator_type2 DRAW_ARROW #property indicator_width2 3 #property indicator_color2 0xFB00FF #property indicator_label2 "Sell" //--- indicator buffers double Buffer1[]; double Buffer2[]; double myPoint; //initialized in OnInit void myAlert(string type, string message) { if(type == "print") Print(message); else if(type == "error") { Print(type+" | loop @ "+Symbol()+","+IntegerToString(Period())+" | "+message); } else if(type == "order") { } else if(type == "modify") { } } //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { IndicatorBuffers(2); SetIndexBuffer(0, Buffer1); SetIndexEmptyValue(0, EMPTY_VALUE); SetIndexArrow(0, 241); SetIndexBuffer(1, Buffer2); SetIndexEmptyValue(1, EMPTY_VALUE); SetIndexArrow(1, 242); //initialize myPoint myPoint = Point(); if(Digits() == 5 || Digits() == 3) { myPoint *= 10; } return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ 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[]) { int limit = rates_total - prev_calculated; //--- counting from 0 to rates_total ArraySetAsSeries(Buffer1, true); ArraySetAsSeries(Buffer2, true); //--- initial zero if(prev_calculated < 1) { ArrayInitialize(Buffer1, EMPTY_VALUE); ArrayInitialize(Buffer2, EMPTY_VALUE); } else limit++; //--- main loop for(int i = limit-1; i >= 0; i--) { if (i >= MathMin(5000-1, rates_total-1-50)) continue; //omit some old rates to prevent "Array out of range" or slow calculation //Indicator Buffer 1 bool bLow = true, bHigh = true; for( int j = 0; j <= 20; j++ ) { bLow &&= iDeMarker( _Symbol, _Period, 14, i + j ) > 0.20; bHigh &&= iDeMarker( _Symbol, _Period, 14, i + j ) < 0.80; }; Buffer1[ i ] = bLow ? Low[ i ] : EMPTY_VALUE; Buffer2[ i ] = bHigh ? High[ i ] : EMPTY_VALUE; return(rates_total); } //+------------------------------------------------------------------+
This is what happened after I read your comment :)
Untested, uncompiled:
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[]) { int nLookback = 20, nlimit = rates_total - fmax( prev_calculated, nLookback ) - 1; if( prev_calculated < 1 ) { ArrayInitialize( Buffer1, EMPTY_VALUE ); ArrayInitialize( Buffer2, EMPTY_VALUE ); }; for( int i = nLimit; i >= 0; i-- ) { bool bLow = true, bHigh = true; for( int j = 0; j <= nLookback; j++ ) { bLow &&= iDeMarker( _Symbol, _Period, 14, i + j ) > 0.20; bHigh &&= iDeMarker( _Symbol, _Period, 14, i + j ) < 0.80; }; Buffer1[ i ] = bLow ? low[ i ] : EMPTY_VALUE; Buffer2[ i ] = bHigh ? high[ i ] : EMPTY_VALUE; }; return(rates_total); };
In MT4/MQL4, buffers are alread as series. No need to set them AsSeries.
Untested, uncompiled:
In MT4/MQL4, buffers are alread as series. No need to set them AsSeries.
look my friend,
I have very little experience in this field
and i don't even reach 1% of your experience,
So I request you to modify this code as you see fit to solve this problem
Because when you ask me to do this, I can't understand you because of the language differences between us and my lack of experience
But when I see the modified code then I will know the difference and what should always be done in these cases
Ahmed Abd El Aziz #:
so I request you to modify this code as you see fit to solve this problem
Because when you ask me to do this, I can't understand you because of the language differences between us and my lack of experience
MT4: Learn to code it.
MT5: Begin learning to code it.
If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into your code.
Or pay (Freelance) someone to code it. Top of every page is the link Freelance.
Hiring to write script - General - MQL5 programming forum (2019)
We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using CODE button) and state the nature of your problem.
No free help (2017)
Because when you ask me to do this, I can't understand you because of the language differences between us and my lack of experience. But when I see the modified code then I will know the difference and what should always be done in these cases
I'm not your friend. I'm a total stranger to you and you to me. The forum is for helping users who want to learn to code in MQL, not to code it for them.
If you want someone to code the whole thing for you, then I direct your attention to the Freelance section. Hire someone and pay them to do it for you.
- 2022.02.15
- www.mql5.com
I'm not your friend. I'm a total stranger to you and you to me. The forum is for helping users who want to learn to code in MQL, not to code it for them.
If you want someone to code the whole thing for you, then I direct your attention to the Freelance section. Hire someone and pay them to do it for you.
When you edit this code i will really learn how to solve this kind of problems and i will not ask about it again.
This is my way of learning because of my bad English language.
But everyone in this site is trying as hard as possible to search for benefit, and this is an abhorrent sometimes
Thank you strangers.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello
Due to many conditions in this code,
I have tried to shorten these previous conditions by loop as you see in the next code:
But it is not working.
Can anyone tell me what is the mistake please?