Hello,
try something that...
//+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ bool ShowArrowUp=true; bool ShowArrowDn=true; 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[]) { //--- //;;;;;;;;;;;;;;;;;;;;;;;;;;;; your code //--- if ((Close[i+1] > MA_)&& (rs>50)&&(cc>0) && (ShowArrowUp==true)) { ShowArrowUp=false; ShowArrowDn=true; CrossUp[i]=Low[i] - 0.0010; } if ((Close[i+1] < MA__) &&(rs_<50)&&(cc_<0) && (ShowArrowDn==true)) { ShowArrowUp=true; ShowArrowDn=false; CrossDown[i]=High[i] + 0.0010; } //--- //;;;;;;;;;;;;;;;;;;;;;;;;;;;; your code //--- return value of prev_calculated for next call return(rates_total); }
- Please edit your (original) post and use the CODE
button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Messages Editor -
if(counted_bars > 0) counted_bars--;
No need for the decrement. Contradictory information on IndicatorCounted() - MQL4 programming forum -
limit = Bars - counted_bars; for(i=0; i<=limit; i++)
When counted_bars is zero, you try to process limit (which equals Bars) which does not exist.You would know that if you had used strict.
Always use strict. Fixing the warnings will save you hours of debugging.
MA_ = iMA(Symbol(),0,144,0,3,PRICE_HIGH,i+2);
Your maximum lookback is 2. Do your lookbacks correctly.
- You should stop using the old event handlers and IndicatorCounted() and start using the new ones.
Event Handling Functions - Functions - Language Basics - MQL4 Reference
How to do your lookbacks correctly. - In both ifs, if the condition is false, you should set that buffer to EMPTY_VALUE.
- wizard_gsm: the code should plot an arrow when conditions are fulfilled {closed candle above high price MA with conditions of RSI and cci as mentioned below}That is what your code does.
Hello,
try something that...
Hello Nikolaos,
First thanks for your help
second, I Tried your idea, but it seems plotting an arrow on each candle individually till condition are not matched it stopped on the last candle,here is a screen shot.
i used also #define PLOTUP -1 #define PLOTDOWN 1 int iWaitFor = PLOTUP; and it gives same result like yours
any other idea?
- Please edit your (original) post and use the CODE
button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Messages Editor - No need for the decrement. Contradictory information on IndicatorCounted() - MQL4 programming forum
- When counted_bars is zero, you try to process limit (which equals Bars) which does not exist.
You would know that if you had used strict.
Always use strict. Fixing the warnings will save you hours of debugging.
Your maximum lookback is 2. Do your lookbacks correctly.
- You should stop using the old event handlers and IndicatorCounted() and start using the new ones.
Event Handling Functions - Functions - Language Basics - MQL4 Reference
How to do your lookbacks correctly. - In both ifs, if the condition is false, you should set that buffer to EMPTY_VALUE.
- That is what your code does.
![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
would you pls remove my post