Leverage calculation

 

I have following integer

int l_1000LUNC = 20; // custom values
int l_1000SHIB = 25; // custom values
int leverage; // value passed from broker side

i want to check on Symbol if leverage (int) defined by broker is greater than custom defined leverage (l_1000LUNC)

how can compare it with _Symbol? I am trying to call it using "l_"+_Symbol but not working.

if(leverage > "l_"+_Symbol) {
//do something
}
 
Arpit T:

I have following integer

i want to check on Symbol if leverage (int) defined by broker is greater than custom defined leverage (l_1000LUNC)

how can compare it with _Symbol? I am trying to call it using "l_"+_Symbol but not working.

I assume the l_1000LUNC and such are inputs the user controls so you would have the inputs 

input int l_1000LUNC=20;
input int l_1000SHIB=25;
input int l_1000CEL=30;

start a list with these inputs and "reflect" them to names and currency symbols 

int levers[]={l_1000LUNC,l_1000SHIB,l_1000CEL};
string lever_names[]={"Luna","ShibaInue","Celsius"};
string lever_currencies[]={"LUNC","SHIB","CEL"};

then you can go through the list and check or you can go through the list and find which symbol it is that matches the users input 

  int l=23;
  for(int i=0;i<ArraySize(levers);i++)
  {
  if(l>levers[i]){
  Print("Leverage bigger than "+lever_names[i]);
  }else{
  Print("Leverage <= than "+lever_names[i]);
  }
  }
  //by finding prefix 
    int _ix=-1;
    string prefix="1000";//i assume this is part of the symbol name 
    for(int i=0;i<ArraySize(lever_currencies);i++){if(_Symbol==prefix+lever_currencies[i]){Print("Symbol is "+lever_names[i]);_ix=i;break;}}
    if(_ix!=-1)
    {
    if(l>levers[_ix]){
    Print("leverage too big");
    }else{
    Print("leverage fine");
    }
    }else{
    Print("Symbol not found");
    }

You can then bounce if the symbol is not found , or , if the leverage is too high 

 
Lorentzos Roussos #:

I assume the l_1000LUNC and such are inputs the user controls so you would have the inputs 

start a list with these inputs and "reflect" them to names and currency symbols 

then you can go through the list and check or you can go through the list and find which symbol it is that matches the users input 

You can then bounce if the symbol is not found , or , if the leverage is too high 

thanks