EA function not displaying indicator

 

Hi wrote this code (MQL4) that checks currency pairs to contain USD and install the DXY indicator if so.

It works as intended except when going between non USD pairs and USD pairs, the DXY is not visible despite

MT4 -> Terminal -> Experts tab tells me the Custom Indicator was loaded and installed successfully.

Any suggestions?

Thank you.

void OnTick() {
int Current_symbol = StringFind(_Symbol, "USD", 0);

if (Current_symbol==-1) {    
   ChartIndicatorDelete(0, 1, indiName);
   indiCount=0;
} else {  
   if (indiCount==0) {
      indiName = ChartIndicatorName(0, 1, 0);   
      CheckAndInstallDIX();   
   }   
   indiCount=1;  
}
}

//---> Custom functions below this line

void CheckAndInstallDIX() {
   int subWindowIndex = 1; // We are checking Subwindow 1
   bool isDIXInstalled = false;

   if (indiName== "Dollar Index: DXY / 20SMA / 40SMA" && subWindowIndex==1) {
      isDIXInstalled = true;
   }
   
   // If "DIX" is not installed in Subwindow 1, install it
   if (!isDIXInstalled) {
      Print("Installing DIX in Subwindow 1...");
      // Apply the DIX indicator to Subwindow 1
      double handle = iCustom(Symbol(), Period(), "MLWS\\Dollar_Index", 0, 0, subWindowIndex);
      if (handle != INVALID_HANDLE) {
         Print("DIX indicator successfully installed.");       
         WindowRedraw(); 
         indiCount=1;          
      } else {
         Print("Failed to install DIX indicator.");         
      }
   } else {
      Print("DIX indicator is already installed in Subwindow 1.");
   }     
}

DXY Load Success

 
Did you really write this? I do not think so. This is not a good act to post AI generated code in this forum.
 
Your topic has been moved to the section: MQL4 and MetaTrader 4
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
 
Lode Loyens: Hi wrote this code (MQL4) that checks currency pairs to contain USD and install the DXY indicator if so. It works as intended except when going between non USD pairs and USD pairs, the DXY is not visible despite

MT4 -> Terminal -> Experts tab tells me the Custom Indicator was loaded and installed successfully. Any suggestions?

Your code is invalid for MQL4. It seems more like MQL5 than MQL4.

Please, don't request help for ChatGPT (or other A.I.) generated code. It generates horrible code, mixing MQL4 and MQL5.

Consider using Freelance section for such requests.

 

My sincere apologies.  I wasn't trying to play smart or fool anyone.

I simply went looking for some 3rd party assistance thinking it would help.

I know better now.

Thank you for your response.


Lode