Is anything wrong with this snippet of code - page 3

 
ernest02:

That sounds to me the best way to go. I know how to distinguish between the values of two different shifts in an indicator, but how do I do that with a variable based on the previous tick/bar?

Please be patient with this beginner programmer!



Actually, it may be better to use the BuySignal variable in a different way.

In this example, conditions are right for a signal when the RSI is below the 30 level and above it the next. A signal will be sent and then BuySignal set to false.

Another signal will not be sent until the RSI moves below the 30 level and above it again. Of course, in ranging periods this could be possible alternating bars.

static BuySignal;
 
 if(iRSI(NULL,0,14,PRICE_CLOSE,1)>30 && iRSI(NULL,0,14,PRICE_CLOSE,2)<30 )
   BuySignal=true;
   
 // Code to determine values of Trade and Buy
    
 if (Trade == true && Buy == true && BuySignal == true)
 
         {

            PlaySound("Alert.wav");
            Alert("ALERT: BUY " + Pair);
            SendMail("SR System Alert ", "BUY " + Pair + "  Timeframe = " + Period()+ "; " + " Date = " + 
                  TimeToStr(TimeLocal(),TIME_DATE) + "; " + " Time = " +  TimeToStr(TimeLocal(),TIME_MINUTES));
          
            BuySignal = false;
            
         } 
 

I want to thank all of you for taking some time to give me assistance with this problem.

It is highly appreciated.

Reason: