Indicators - Functions and Arrays

 

Hello!

My question is related to using functions and arrays in plenty of indicators. I will give an example.

Let's look at DeMarker. There are two levels - 20 and 80. The current indicator value is above the level of 80 and I need my EA to detect when the DeMarker crosses the level of 80. If I use the simple function like this one below I will detect when the value is just over 80. Please help me!

if (DeMarker > 80)
 
  1. How To Ask Questions The Smart Way. 2004
              Prune pointless queries.

  2. Damyan Dimitrov: My question is related … Please help me!

    No question asked. Help you with what? You haven't stated a problem, you haven't even stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
              No free help 2017.04.21

    Or pay someone. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum 2018.05.12

 
William Roeder:
  1. How To Ask Questions The Smart Way. 2004
              Prune pointless queries.

  2. No question asked. Help you with what? You haven't stated a problem, you haven't even stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
              No free help 2017.04.21

    Or pay someone. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum 2018.05.12

You are totally right. Excuse me for that. I am providing the code. My question is that how may I use the Array for previous value of any indicator. For example. If the value of the indicator was above 80 3 bars ago and now is below 80, that means the indicator had crossed from upside the level is 80. I had tried many times to take the previous value of any indicator, but there were not any result for me.

void OnTick()
   {
      double myPriceArray[];
      int CCIDefinition = iCCI(_Symbol,_Period,14,PRICE_CLOSE);
      ArraySetAsSeries(myPriceArray,true);
      CopyBuffer(CCIDefinition,0,0,3,myPriceArray);
      double CCIValue=(myPriceArray[0]);
      if (CCIValue > 100)
         {
            Comment("OverBought: ",CCIValue);
         }
      if (CCIValue < -100)
         {
            Comment ("OverSold: ",CCIValue );
         }
      if ((CCIValue > -100)&&(CCIValue < 100))
         {
            Comment ("",CCIValue );
         }
   }
 
  1. Don't double post! You already had this thread open.
              General rules and best pratices of the Forum. - General - MQL5 programming forum

  2. Perhaps you should read the manual.
    How To Ask Questions The Smart Way. 2004
         How To Interpret Answers.
              RTFM and STFW: How To Tell You've Seriously Screwed Up.

    Perhaps you should read the manual, especially the examples. They all (including iCustom) return a handle (an int.) You get that in OnInit. In OnTick (after the indicator has updated its buffers,) you use the handle, shift and count to get the data.
              Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
              Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
              How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 2020.03.08
              How to call indicators in MQL5 - MQL5 Articles 12 March 2010

 
Well, I know how to do this in mql4, but I need to convert this in mql5.
Reason: