Bid of a Certain moment

 

Hello Goodnight.

I am writing an indicator, and I want to register, and keep it fixed on the screen,

the price that was at the moment the circumstances occurred: in this case, the Bid of the moment in which the averages were crossed.

Can someone guide me? What function I should be used?

Thank you very much in advance. I'm looking for a while, and I can't find this question in the forum or anything that inspires me how to do it.

 
  1. Get the averages. Look for a cross. Get the Bid

    double aPrev = …, aCurr = …,
           bPrev = …, bCurr = …;
    bool   wasUp = aPrev > bPrev,
            isUp = aCurr > bCurr,
           isCross = isUp != wasUp;
  2. The iMA functions.

  3. You haven't stated a problem, you 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


 
 
              {
               //Indicator Buffer 4 Break_Top_Line

               if((High[i] >Buffer2[i]&& High[i+1]<Buffer2[i+1]))
                  ObjectSetText("LastSignalResult","SELL",10,"Arial Black",TopLineColor);
                  ObjectSetText("AtPriceResult",(High[i]+Low[i])/2,10,"Arial Black",TopLineColor); 
               //If the top of the candle rises above the upper channel
                 {
                  Buffer4[i] = High[i]+ Arrow_Distance * myPoint;
                 }

               if(i == 0 && Time[0] != time_alert)
                 {
                  myAlert("X Indicator", "The current candle has passed the Top Line");   //Instant alert, only once per bar
                  time_alert = Time[0];
                 }

               else
                 {
                  Buffer4[i] = EMPTY_VALUE;
                 }
William Roeder
:

  1. Get the averages. Look for a cross. Get the Bid

  2. The iMA functions.

  3. You haven't stated a problem, you 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


Okay, thank you.  My problem is that when a new bar is opened the value changes with the average of the new bar.   I have the same problem with another indicator
 
Enrique Enguix Vino: when a new bar is opened the value changes with the average of the new bar.
  1. That is not a problem; that is reality.
  2. Why is your posting code looking at bar i? Bid is now. You can only look at bar zero and one to get now.
  3. The only other approach is to compute your MAs yourself and use a binary search to find what bid would have resulted in a cross. Way beyond what you can do.
 
William Roeder:
  1. That is not a problem; that is reality.
  2. Why is your posting code looking at bar i? Bid is now. You can only look at bar zero and one to get now.
  3. The only other approach is to compute your MAs yourself and use a binary search to find what bid would have resulted in a cross. Way beyond what you can do.
So it's more complicated than I thought.  I simply want, when they cross, the buffer that I have already defined appears (it is a simple arrow) and the price at which they crossed will remain permanently on the screen (or until the appearance of a new signal).  I think there must be a slightly easier way to achieve this.  If I succeed I will write in case that can help someone in the future.  Thanks for your help William, and sorry for not explaining me correctly and adding the code from the beginning
 
Enrique Enguix Vino I simply want, when they cross, the buffer that I have already defined appears (it is a simple arrow) and the price at which they crossed

What "price at which they crossed?" The Bid or the cross?
     How To Ask Questions The Smart Way. 2004
          Be precise and informative about your problem

 
William Roeder:

What "price at which they crossed?" The Bid or the cross?
     How To Ask Questions The Smart Way. 2004
          Be precise and informative about your problem

Finally I solved it satisfactorily.  Tomorrow I will write how I did it in case that helps someone later.  Thanks again for the help
Reason: