what did i miss "my first code" how to make it only one arrow

 

would you pls remove my post

 
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}
{
rs2=0;
rs1=0;
MA_ =0;
MA__=0;
rs =0;
cc1=0;
cc2=0;
cc=0;
cc_=0;
rs_=0;
int counted_bars = IndicatorCounted();
int i;
int limit;
if(counted_bars < 0)
return(-1);
if(counted_bars > 0)
counted_bars--;
limit = Bars - counted_bars;
for(i=0; i<=limit; i++)

{

MA_ = iMA(Symbol(),0,144,0,3,PRICE_HIGH,i+2);
MA__= iMA(Symbol(),0,144,0,3,PRICE_LOW,i+2);
rs1= iRSI (Symbol(),PERIOD_CURRENT,144,0,i+1);
rs2=iRSI (Symbol(),PERIOD_CURRENT,144,0,i+1);
rs = iRSI (Symbol(),PERIOD_CURRENT,144,2,i);
rs_ = iRSI (Symbol(),PERIOD_CURRENT,144,3,i);
cc = iCCI (Symbol(),PERIOD_CURRENT,144,0,i);
cc_= iCCI (Symbol(),PERIOD_CURRENT,144,0,i);
cc1= iCCI (Symbol(),PERIOD_CURRENT,144,0,i+1);
cc2=iCCI (Symbol(),PERIOD_CURRENT,144,0,i+1);

if ((Close[i+1] > MA_)&& (rs>50)&&(cc>0))
{
CrossUp[i]=Low[i] - 0.0010;
}
if ((Close[i+1] < MA__) &&(rs_<50)&&(cc_<0))
{
CrossDown[i]=High[i] + 0.0010;
}
}
return(0);


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);
  }

 
  1. 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

  2.  if(counted_bars > 0)
    counted_bars--; 
    No need for the decrement. Contradictory information on IndicatorCounted() - MQL4 programming forum

  3.  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.

  4. 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.

  5. In both ifs, if the condition is false, you should set that buffer to EMPTY_VALUE.
  6. 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.
 
Nikolaos Pantzos:

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?


Files:
arrows.jpg  43 kb
 
William Roeder:
  1. 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

  2. No need for the decrement. Contradictory information on IndicatorCounted() - MQL4 programming forum

  3. 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.

  4. 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.

  5. In both ifs, if the condition is false, you should set that buffer to EMPTY_VALUE.
  6. That is what your code does.
ya thank you  specially no-6