Compare Prices

 

Hello, I was thinking to solve the next problem:

If last price=Bidprevious and actual price=Bidcurrent, I would like to know when Bidcurrent=Bidprevious+(n*pips):

ex: Last price=1.4000

     Current price=1.4005

     And I would like to open trade only when the actual price will be 1.4010. I tought "CompareBids" function will work something like: when the actual price will reach (n+last price) than it will open a trade.

P.S: If this idea it is not good, I would like if someone has a better one to tell me the way and I will try to code it. Thanks in advance.

int init()
   {  BidCurrent = Bid;}
    
//--------------------------------------------------------------------   
bool CompareBids(double number1,double number2)
   {  if(NormalizeDouble(number1-number2,5)==0) return(true);
                      else return(false); } 
//-------------------------------------------------------------------- 
int start()
   {  double BidPrevious = BidCurrent; BidCurrent = Bid;
      double DifBuy = BidPrevious + (5 * Point);
   
      if (CompareBids(BidCurrent,DifBuy))
                 
                {
                ticket=OrderSend(Symbol(),OP_BUY,1,Ask,3,Ask-500*Point,Ask+500*Point);
                }
        }                                                    
 
darchii:

Hello, I was thinking to solve the next problem:

If last price=Bidprevious and actual price=Bidcurrent, I would like to know when Bidcurrent=Bidprevious+(n*pips):

ex: Last price=1.4000

     Current price=1.4005

     And I would like to open trade only when the actual price will be 1.4010. I tought "CompareBids" function will work something like: when the actual price will reach (n+last price) than it will open a trade.

P.S: If this idea it is not good, I would like if someone has a better one to tell me the way and I will try to code it. Thanks in advance.

You cannot do what you are trying to do without knowing if you have missed one or more ticks.  If you miss 6 ticks and for each of those tick Bid increases by 1 point then what you will see is a change of 6 points from tick to tick when actually there was just 1 point change from tick to tick.  Your idea can only be used when you determine that you have not missed any ticks between the last Bid price and the current Bid price.  To do this count the number of ticks ffrom the start of the bar and compare this against iVolume[0],  then you will know if you have missed ticks . . .
 
RaptorUK:
You cannot do what you are trying to do without knowing if you have missed one or more ticks.  If you miss 6 ticks and for each of those tick Bid increases by 1 point then what you will see is a change of 6 points from tick to tick when actually there was just 1 point change from tick to tick.  Your idea can only be used when you determine that you have not missed any ticks between the last Bid price and the current Bid price.  To do this count the number of ticks ffrom the start of the bar and compare this against iVolume[0],  then you will know if you have missed ticks . . .

Missing ticks is one thing, but even without missing a tick, you can miss the trade. Price doesn't always change by 1 point, you can have 1.4000, 1.4001, 14002, 1.4003, 1.4004 and then 1.4006 even without losing a tick.
 

Ok ... Than maybe should I try with last order opened ? (with openprice and a "for loop"?) It will work better like this? I found something on this way but ... it is not working if i am adding extra block in the EA (maybe i am wrong with something i don`t know because it will keep only the last open price and it will go something like :

buy    :1.3000

buy    :1.3010

buy     :1.3020

if the price go back to 1.3000 and than 1.3010 (at this price it won`t open price) only when the price reach again over 1.3020 the last buy)

Thanks for advice, I will keep searching maybe I will find an indicator or something that i can hook on.

Reason: