Download MetaTrader 5

closed chart indicator

To add comments, please log in or register
texoro
149
texoro  
Guys, I created this small indicator that should analyze more than one currency exchange rate; calling the function "AlertSupportAndResistence (symbol1, timeframeSimbol1)" on "x" declared currencies at the beginning.

I would expect that even if I load it only on a graph, for example "EURUSD DAY", when there is a signal on a different graph (GBPUSD, which is the second call), that this also gives me the signal of that currency, but it only gives me the "EURUSD" alerts where the indicator is inserted. Where is the error? How do I change it?

input symbols symbol1 = EURUSD;
input ENUM_TIMEFRAMES   timeframeSimbol1  = PERIOD_M15;;  // Qui puoi impostare un timeframe diverso da quello del grafico

input symbols symbol2 = GBPUSD;
input ENUM_TIMEFRAMES   timeframeSimbol2  = PERIOD_M15;;  // Qui puoi impostare un timeframe diverso da quello del grafico

input symbols symbol3 = USDJPY;
input ENUM_TIMEFRAMES   timeframeSimbol3  = PERIOD_M15;;  // Qui puoi impostare un timeframe diverso da quello del grafico

input symbols symbol4 = AUDUSD;
input ENUM_TIMEFRAMES   timeframeSimbol4  = PERIOD_M15;;  // Qui puoi impostare un timeframe diverso da quello del grafico

input symbols symbol5 = USDCHF;
input ENUM_TIMEFRAMES   timeframeSimbol5  = PERIOD_M15;;  // Qui puoi impostare un timeframe diverso da quello del grafico

input symbols symbol6 = NZDUSD;
input ENUM_TIMEFRAMES   timeframeSimbol6  = PERIOD_M15;;  // Qui puoi impostare un timeframe diverso da quello del grafico

input symbols symbol7 = USDCAD;
input ENUM_TIMEFRAMES   timeframeSimbol7  = PERIOD_M15;;  // Qui puoi impostare un timeframe diverso da quello del grafico

input symbols symbol8 = XAUUSD;
input ENUM_TIMEFRAMES   timeframeSimbol8  = PERIOD_M15;;  // Qui puoi impostare un timeframe diverso da quello del grafico

input symbols symbol9 = XAGUSD;
input ENUM_TIMEFRAMES   timeframeSimbol9  = PERIOD_M15;;  // Qui puoi impostare un timeframe diverso da quello del grafico

int AlertSupportAndResistence(symbols symb, ENUM_TIMEFRAMES timeframe){
   
   if(barTemp!=Bars)
        {
         for(int j=0; j<Bars; j++)
           {
            if(iFractals(symb,timeframe,MODE_UPPER,j)!=0 && j>=resistenceBar)
              {
               //Alert("Resistenza su "+Symbol()+" a TF "+IntegerToString(Period(),0,0));
               resistenceBar=j;
               barTemp=Bars;
               j=Bars;
               return (1);//sell
              }
   
            if(iFractals(symb,timeframe,MODE_LOWER,j)!=0 && j>=supportBar)
              {
               //Alert("\nSupport su "+Symbol()+" a TF "+IntegerToString(Period(),0,0)+" al tempo "+Time[j]);       
               supportBar=j;
               barTemp=Bars;
               j=Bars;
               return(2);//buy
              }
           }
        }
       return (0);//neutro
   }

int start() 
{  
   
   if(AlertSupportAndResistence(symbol1,timeframeSimbol1)==1)
      Alert("Resistenza su "+symbol1+" a TF "+IntegerToString(timeframeSimbol1,0,0));
   if(AlertSupportAndResistence(symbol1,timeframeSimbol1)==2)
      Alert("Supportp su "+symbol1+" a TF "+IntegerToString(timeframeSimbol1,0,0));
   
   if(AlertSupportAndResistence(symbol2,timeframeSimbol2)==1)
      Alert("Resistenza su "+symbol2+" a TF "+IntegerToString(timeframeSimbol2,0,0));
   if(AlertSupportAndResistence(symbol2,timeframeSimbol2)==2)
      Alert("Supportp su "+symbol1+" a TF "+IntegerToString(timeframeSimbol2,0,0));
      
   if(AlertSupportAndResistence(symbol2,timeframeSimbol3)==1)
      Alert("Resistenza su "+symbol3+" a TF "+IntegerToString(timeframeSimbol3,0,0));
   if(AlertSupportAndResistence(symbol2,timeframeSimbol3)==2)
      Alert("Supportp su "+symbol1+" a TF "+IntegerToString(timeframeSimbol3,0,0));   
          
   return(0);
}
 


texoro
149
texoro  
Then guys I fixed a problem that was not working on the unopened charts, now the problem is that it gives alert to each tick, as I said before I would like it to sound only when there is the condition and not every tick as it does now.
whroeder1
17512
whroeder1  
texoro: only when there is the condition and not every tick as it does now.
That is exactly why you have the problem. Alert on a change in condition.
          MQL4 (in Strategy Tester) - double testing of entry conditions - Strategy Tester - Expert Advisors and Automated Trading - MQL5 programming forum
To add comments, please log in or register