Hello friends, how can I make my EA have a license that allows the EA to only work on a default broker and thus cannot work on any other broker?
-
Greetings everyone, please help me friends on this topic that I explain below: how can I guarantee that my Expert Advisor (EA) has a license that enables it to operate exclusively on a default broker and, therefore, cannot be used in any other broker?
-
in account you can get the broker name, and check if this matches what you specify, otherwise terminate
-
In short something like this
#define DEFAULT_BROKER_IDENTIFIER "YOUR_BROKER_IDENTIFIER"
bool VerifyLicense(){
string brokerIdentifier = TerminalInfoString(TERMINAL_COMPANY);
if(brokerIdentifier != DEFAULT_BROKER_IDENTIFIER) {
Print("ERROR: Invalid broker.");
return false; // License verification failed
ExpertRemove();
}
return true; // License verification succeeded
}int OnInit(){
if(!VerifyLicense()) {
Print("ERROR: Invalid license. This EA is not authorized to run on this broker.");
return INIT_FAILED; // Exit initialization process
ExpertRemove();
}
// Continue with EA initialization
return INIT_SUCCEEDED;
} -
@lazyfxceo That code will not work in FX without modification, and it is all in FX meaning minimal code is be needed
-
@lazyfxceo said in Hello friends, how can I make my EA have a license that allows the EA to only work on a default broker and thus cannot work on any other broker?:
return true; // License verification succeeded
Yes you have to open the .Mq5 file In the metaQuotes Editor and you can then manually add the code to the EA, and rebuild
-
OnInit
Block: Modify Variable
Account - Name:Broker (Store as Variable: BrokerName, store your broker in Input setting of the EA)
Block: Condition
Account - Name:Broker = BrokerName (Your variable storing your sepcific Broker) = True
Block: Terminate
-
Muchas gracias por sus comentarios, estoy probando con las sugerencias que no requieran de conocimiento de codificacion en mql.
Thank you very much for your comments, I am trying the suggestions that do not require MQL coding knowledge.