Download MetaTrader 5

Problem with calculate the take profit and then modify an order

To add comments, please log in or register
GianpaoloMad
11
GianpaoloMad  

Hi everyone,

I have a problem with my program.

I'm starting create a program that works with bollinger bands. Here are the functions for open an order:

bool SpikeBuy(){

   double bbMinus;
   double ma;

   bbMinus=iBands(Symbol(),0,20,2,0,PRICE_CLOSE,MODE_LOWER,1);
   ma=iMA(Symbol(),0,14,0,MODE_SMA,PRICE_CLOSE,1);

   if (Open[1]>bbMinus && Close[1]<( bbMinus - SpikePips * Point ) && Open[1]<ma) return(true);
return(false);
}

bool SpikeSell(){

   double bbPlus;
   double ma;
  
   bbPlus=iBands(Symbol(),0,20,2,0,PRICE_CLOSE,MODE_UPPER,1);
   ma=iMA(Symbol(),0,14,0,MODE_SMA,PRICE_CLOSE,1);
  
   if (Open[1]<bbPlus && Close[1]>( bbPlus + SpikePips * Point ) && Open[1]>ma) return(true);
return(false);

}


Where SpikePips is a distance (in pips) between bbPlus or bbMinus and the Close[1].

If one of these functions is true, open a buy or a sell order. No problem to do this, of course.

Now an example: SpikeSell() is true, it opens a sell order. I would like to say the program to store the value of bbPlus at point 0 and then close the order when the current price reaches it. If the order doesn't close in the current bar, it has to store the next value of bbPlus and then try to close the order in the next bar.

Any ideas? Do you think it's a good thing to calculate the distance between Open[0] and bbPlus and then modify the order to take the new profit (the distance between Open[0] and bbPlus)?

I don't know... I'll wait for your help.

Thanks.

Sergey Golubev
Moderator
94676
Sergey Golubev  
GianpaoloMad
11
GianpaoloMad  
Sergey Golubev:

I'm very sorry. New on this forum. Edited.
GianpaoloMad
11
GianpaoloMad  
Nobody could help me?
To add comments, please log in or register