bar since condition

 

hi

there is a function that tell me before how many bars conditon was true ?

for example :

bar since rsival>70 = 23 bars


and there is a  function that tell about cross over ==true  ?


for example :


i want to send order when cci cross the 100 

if i code cci > 100 and i close my position it will send a new order as long as cci > 100 i want to buy just at the cross 

 
nati2009:

hi

there is a function that tell me before how many bars conditon was true ?

for example :

bar since rsival>70 = 23 bars


and there is a  function that tell about cross over ==true  ?


for example :


i want to send order when cci cross the 100 

if i code cci > 100 and i close my position it will send a new order as long as cci > 100 i want to buy just at the cross 

you can do it yourself using;

1. iHighest() -----------for barsince

2. if cci lower than 100 at the previous bar and cci higher than at the current bar, then there is a crossover ------for crossover==true 

 
Ahmet Metin Yilmaz:

you can do it yourself using;

1. iHighest() -----------for barsince

2. if cci lower than 100 at the previous bar and cci higher than at the current bar, then there is a crossover ------for crossover==true 

Thank you for your aswer

buy it is not whay i need

1. iHighest () ------- its just for price , i need function that tell me bar since condition 

2. if i use this like you said its will give me true every tick as long the bar didnt closed, if i use 1day candle and the cci >100 so every tick its will tell me true 

i want to get true just at the moment that there was the crossover 

 
nati2009:

there is a function that tell me before how many bars conditon was true ?

and there is a  function that tell about cross over ==true  ?
  1. No; you write one. Save the time when the condition is true. iBarShift tells you how many.
  2. No; you write one.
    double aPrev = …, aCurr = …,
           bPrev = …, bCurr = …;
    bool   wasUp = aPrev > bPrev,
            isUp = aCurr > bCurr,
           isCross = isUp != wasUp;
  3. 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.

 
William Roeder:
  1. No; you write one. Save the time when the condition is true. iBarShift tells you how many.
  2. No; you write one.
  3. 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.


hi

thank you

1. i try to save to time and use to iBarShift buy after 1 bar its give me 1004 

   double ccival=iCCI(NULL,0,20,PRICE_CLOSE,0);
   double cciprev=iCCI(NULL,0,20,PRICE_CLOSE,1);
   bool opentrade=checkforopentrade(macigNM);
   datetime time;

   if(ccival>100 && cciprev<100)
   {
     time=TimeCurrent();
   }
   int barfromcross=iBarShift(NULL,0,time,False);
   Comment("bar from cross :"+barfromcross);

2.please can you expain more ? 


double aPrev = …, aCurr = …,
       bPrev = …, bCurr = …;

what mean aPrev and aCurr and  bPrev and bCurr

 
nati2009:

I know that it is not obvious, but topics concerning MT4 and MQL4 have their own section.

In future please post in the correct section.

I will move your topic to the MQL4 and Metatrader 4 section.

 
nati2009:

1. i try to save to time and use to iBarShift buy after 1 bar its give me 1004 

   datetime time;

2.please can you expain more ? 

what mean aPrev and aCurr and  bPrev and bCurr

  1.    datetime time;
       if(ccival>100 && cciprev<100){time=TimeCurrent();}
    
       int barfromcross=iBarShift(NULL,0,time,False);
    You didn't save anything. As soon as you exit, your variable has been lost. So next tick time is zero and you get Bars-1.

  2. You asked about a cross over. So whatever two lines, current and previous values, you meant. When in doubt, THINK!

  3. 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 Code Base.
              Hiring to write script - General - MQL5 programming forum 2019.08.21

 
nati2009:

Thank you for your aswer

buy it is not whay i need

1. iHighest () ------- its just for price , i need function that tell me bar since condition 

2. if i use this like you said its will give me true every tick as long the bar didnt closed, if i use 1day candle and the cci >100 so every tick its will tell me true 

i want to get true just at the moment that there was the crossover 

Imagine your EA fires an order just at the moment this happens, and the order is rejected/lost for whatever reason.

What are you going to do on the next tick? I guess you certainly want to place that order again (provided the cci is still >100.)

So accustom to that the condition is true and act on the right outcome, and don't try to fix the input.