Profit target and Stop loss Alert

To add comments, please log in or register
.
59
.  

Hello, 

I have a problem on my indicator that I have noted in the case of achieving Profit target and stop loss. How to modify code that notice was displayed only for a time?
For example: every 10 seconds
  I tried using function : Sleep (), unfortunately without success.
Thank you for your help

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+

extern bool   Percent  = true; 
extern bool Play_Sound = true;
extern double Risk = 2.0;

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
if (Percent  == true)
if (Play_Sound  == true)  

double stop =AccountBalance()*(-Risk)/100;
double profit =AccountBalance()*(Risk)/100;
double floating_profit =AccountProfit();
{ 
  if(StrToDouble(floating_profit) <= stop) 

  { 
   if(Play_Sound) PlaySound("alert.wav");

      Alert("Warning price: Stopp-loss "+Symbol()+" "+Hour()+":"+Minute()+":"+Seconds());

    {
  if(StrToDouble(floating_profit) >= profit) {
      if(Play_Sound) PlaySound("alert.wav");
      
      Alert("Warning price: Profit-target "+Symbol()+" "+Hour()+":"+Minute()+":"+Seconds());
      
}}}}
//----
   return(0);
  }
.
59
.  
Any idea?
whroeder1
17954
whroeder1  
double stop =AccountBalance()*(-Risk)/100;
double profit =AccountBalance()*(Risk)/100;
double floating_profit =AccountProfit();
{ 
  if(StrToDouble(floating_profit) <= stop) 

...

Question 1: Why are you taking a double (floating_profit) converting it to a string (to be passed to StrToDouble) which will return the exact same doulble you started with?


Question 2: Stop is always less then zero, but floating_profit will not be, unless this trade is wiping out all profits from all previous trades. Shouldn't you be comparing to AccountEquity()-AccountBalance()

.
59
.  
Thank you for your answer, I'm not a programmer, because code contains inaccuracies. Please help with programming of EA, indicator or script that would prove this.
.
59
.  
The code used to the condition to be met, which is that the price is below a certain allowed percentage, activated the Alert function and PlaySound only once?
.
59
.  
Any idea?
whroeder1
17954
whroeder1  

I'm not a programmer, ....

Learn

Please help with programming of EA,

or pay someone. No slaves here.

.
59
.  
to WHRoeder: I just asked politely for help. Such advice on anything you leave.
To add comments, please log in or register