www.freebinaryoptios.one

Let’s ask Artificial Intelligence to correct our indicator!

Even if you are not familiar with programming metatrader indicators by reading this article you will be amazed at what AI can do!

Here we report the chat with AI

FreeBinaryOptions: If I give you an MQL4 indicator with arrows with his script, can you tell me how many positive signals I got in the past?

AI: As a text based language model, I don’t have the ability to directly execute MQL4 code or any other programming language. However, I can give you general guidance on how you might calculate the number of positive signals generated by an MQL4 script in the past.

To calculate the number of positive signals generated by an MQL4 script in the past, you should follow these steps:

  1. Open the MQL4 script code which gives you the arrow indicators.
  2. Identifies the logic used in the script to generate signal arrows.
  3. Determines the condition or conditions that are evaluated to generate a positive arrow.
  4. Using the same logic and conditions, loop through your financial instrument’s historical data (for example, closing prices) to determine when the conditions have been met to generate a positive arrow.
  5. Increments a counter each time a positive condition occurs during the historical data cycle.
  6. At the end of the cycle, the counter value will represent the number of positive signals generated in the past.

Remember that this is just a general explanation of how you might go about calculating the number of positive signals in the past using an MQL4 script. However, the specific logic and implementation will depend on the indicator and script you are using. Make sure you are familiar with the code and adapt it to your specific needs.

If you need specific assistance in the MQL4 indicator code, it would be helpful to include the indicator code in your message, so that I can provide you with more specific support.

FreeBinaryOptions: Well, here is the code of my indicator

/* forzaforex.it */ #property indicator_chart_window #property indicator_buffers 3 #property indicator_color1 Green #property indicator_color2 Red #property indicator_color3 Orange extern bool Sound_Alert = TRUE; double G_ibuf_80[]; double G_ibuf_84[]; // int init() { SetIndexStyle(0, DRAW_ARROW, EMPTY, 4); SetIndexArrow(0, 221); SetIndexBuffer(0, G_ibuf_80); SetIndexEmptyValue(0, 0.0); SetIndexStyle(1, DRAW_ARROW, EMPTY, 4); SetIndexArrow(1, 222); SetIndexBuffer(1, G_ibuf_84); SetIndexEmptyValue(1, 0.0); return(0); } // int deinit() { return (0); } // int start() { double Lda_0[2]; Comment(“FYI: https://www.forzaforex.it/indicator-non-repaint https://www.freebinaryoptions.one/no-repaint-indicator-alert-arrows/”); double iatr_4 = iATR(Symbol(), 0, 50, 1); for (int index_12 = 0; index_12 < Bars; index_12++) { G_ibuf_80[index_12] = 0.0; G_ibuf_84[index_12] = 0.0; for (int index_16 = 0; index_16 < 2; index_16++) Lda_0[index_16] = iRSI(Symbol(), 0, 14.0, PRICE_CLOSE, index_12 + index_16); if (Lda_0[0] > 25.0 && Lda_0[1] < 25.0) G_ibuf_80[index_12] = Low[index_12] – iatr_4 / 2.0; if (Lda_0[0] < 75.0 && Lda_0[1] > 75.0) G_ibuf_84[index_12] = High[index_12] + iatr_4 / 2.0; } if (G_ibuf_80[2] == 0.0 && G_ibuf_80[1] != 0.0 && Open[0] == Low[0] && Open[0] == High[0] && Open[0] == Close[0 ]) Alert(“Arrow Signal Call”); if (G_ibuf_84[2] == 0.0 && G_ibuf_84[1] != 0.0 && Open[0] == Low[0] && Open[0] == High[0] && Open[0] == Close[0] ) Alert(“Arrow Signal Put”); return(0); index_12 + index_16); if (Lda_0[0] > 25.0 && Lda_0[1] < 25.0) G_ibuf_80[index_12] = Low[index_12] – iatr_4 / 2.0; if (Lda_0[0] < 75.0 && Lda_0[1] > 75.0) G_ibuf_84[index_12] = High[index_12] + iatr_4 / 2.0; } if (G_ibuf_80[2] == 0.0 && G_ibuf_80[1] != 0.0 && Open[0] == Low[0] && Open[0] == High[0] && Open[0] == Close[0 ]) Alert(“Arrow Signal Call”); if (G_ibuf_84[2] == 0.0 && G_ibuf_84[1] != 0.0 && Open[0] == Low[0] && Open[0] == High[0] && Open[0] == Close[0] ) Alert(“Arrow Signal Put”); return(0); index_12 + index_16); if (Lda_0[0] > 25.0 && Lda_0[1] < 25.0) G_ibuf_80[index_12] = Low[index_12] – iatr_4 / 2.0; if (Lda_0[0] < 75.0 && Lda_0[1] > 75.0) G_ibuf_84[index_12] = High[index_12] + iatr_4 / 2.0; } if (G_ibuf_80[2] == 0.0 && G_ibuf_80[1] != 0.0 && Open[0] == Low[0] && Open[0] == High[0] && Open[0] == Close[0 ]) Alert(“Arrow Signal Call”); if (G_ibuf_84[2] == 0.0 && G_ibuf_84[1] != 0.0 && Open[0] == Low[0] && Open[0] == High[0] && Open[0] == Close[0] ) Alert(“Arrow Signal Put”); return(0); & G_ibuf_80[1] != 0.0 && Open[0] == Low[0] && Open[0] == High[0] && Open[0] == Close[0]) Alert(“Arrow Signal Call”) ; if (G_ibuf_84[2] == 0.0 && G_ibuf_84[1] != 0.0 && Open[0] == Low[0] && Open[0] == High[0] && Open[0] == Close[0] ) Alert(“Arrow Signal Put”); return(0); & G_ibuf_80[1] != 0.0 && Open[0] == Low[0] && Open[0] == High[0] && Open[0] == Close[0]) Alert(“Arrow Signal Call”) ; if (G_ibuf_84[2] == 0.0 && G_ibuf_84[1] != 0.0 && Open[0] == Low[0] && Open[0] == High[0] && Open[0] == Close[0] ) Alert(“Arrow Signal Put”); return(0);

AI: Thanks for providing the MQL4 indicator code.

Analyzing the code, it appears that the indicator generates signal arrows for both BUY (CALL) and SELL (PUT) signals based on the conditions of the RSI indicator.

To determine the number of positive signals in the past, you would need to make some code changes. Here’s how you can proceed:

  1. Add a counter variable at the beginning of your code to track the number of positive signals. For example, you can declare a variable called “positiveSignals” and set it to zero:
arduinoCopy codeint positiveSignals = 0;
  1. In the loop forthat iterates through the historical data, just after the lines G_ibuf_80[index_12] = 0.0;and G_ibuf_84[index_12] = 0.0;, add the check to see if a positive signal has been generated. You can do this by using the conditions you’ve identified for the positive signal arrows. For example, for the CALL signal, you can add:
cssCopy codeif (G_ibuf_80[index_12] > 0.0) {
   positiveSignals++;
}
  1. At the end of the loop, after the loop for, you can print the number of positive signals generated in the past using the function Print:
mathematicaCopy codePrint("Numero di segnali positivi nel passato: ", positiveSignals);
  1. Now, when you run the indicator on the chart, it will display the number of positive signals generated in the past in the MetaTrader output window.

I remind you that this code only provides the count of positive signals in the past, but if you need more detailed analysis or specific processing on the signals, you may need to make more code changes or write more complex logic.

Remember to compile the indicator again after making the changes and test it on historical data to verify the correctness of counting positive signals.

FreeBinaryOptions: can you make these changes directly to me and give me the new code?

Beginning of the code that is sending…

Certainly! Here is the modified code of the MQL4 indicator with the changes described above:

/* forzaforex.it */ #property indicator_chart_window #property indicator_buffers 3 #property indicator_color1 Green #property indicator_color2 Red #property indicator_color3 Orange extern bool Sound_Alert = TRUE; double G_ibuf_80[]; double G_ibuf_84[]; // int init() { SetIndexStyle(0, DRAW_ARROW, EMPTY, 4); SetIndexArrow(0, 221); SetIndexBuffer(0, G_ibuf_80); SetIndexEmptyValue(0, 0.0); SetIndexStyle(1, DRAW_ARROW, EMPTY, 4); SetIndexArrow(1, 222); SetIndexBuffer(1, G_ibuf_84); SetIndexEmptyValue(1, 0.0); return (0); } // int deinit() { return (0); } // int start() { double Lda_0[2]; Comment("FYI: https://www.forzaforex.it/indicatore-non-repaint https://www.freebinaryoptions.one/no-repaint-indicator-alert-arrows/"); double iatr_4 = iATR(Symbol(), 0, 50, 1); int positiveSignals = 0; // Variabile contatore per i segnali positivi for (int index_12 = 0; index_12 < Bars; index_12++) { G_ibuf_80[index_12] = 0.0; G_ibuf_84[index_12] = 0.0; for (int index_16 = 0; index_16 < 2; index_16++) Lda_0[index_16] = iRSI(Symbol(), 0, 14.0, PRICE_CLOSE, index_12 + index_16); if (Lda_0[0] > 25.0 && Lda_0[1] < 25.0) { G_ibuf_80[index_12] = Low[index_12] - iatr_4 / 2.0; positiveSignals++; // Incrementa il contatore dei segnali positivi } if (Lda_0[0] < 75.0 && Lda_0[1] > 75.0) G_ibuf_84[index_12] = High[index_12] + iatr_4 / 2.0; } if (G_ibuf_80[2] == 0.0 && G_ibuf_80[1] != 0.0 && Open[0] == Low[0] && Open[0] == High[0] && Open[0] == Close[0]) Alert("Arrow Signal Call"); if (G_ibuf_84[2] == 0.0 && G_ibuf_84[1] != 0.0 && Open[0] == Low[0] && Open[0] == High[0] && Open[0] == Close[0]) Alert("Arrow Signal Put"); Print("Numero di segnali positivi nel passato: ", positiveSignals); // Stampa il numero di segnali positivi return (0); }

The changes were made inside the function start(), where I added the variable positiveSignalsfor counting positive signals and incremented its value when a positive signal is generated.

I recommend that you compile the indicator again in your MetaEditor and test it on a chart to see the number of positive signals generated in the past in the MetaTrader output window.

Conclusion

Even without particular experience on our part, Artificial Intelligence can be of great help in trading. The possibilities are endless.