Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 139

 
Artyom Trishkin:

Even on Windows, the tabs cannot be sorted using mql4.

You can only open charts in the order you want and set the necessary templates on them.

Of course, you cannot sort them, but you can move them one by one manually.

As for sorting using mql, I think you can try the following option:

1. We close all the windows except the one where the code, Expert Advisor or script is running.

2. open new windows in a certain sequence, including the one with the Expert Advisor and adjust them or apply a template.

3. Lastly, delete the window in which the code is running.

 
Alexey Viktorov:

Of course you can't sort it, but you can move it manually one at a time.

As for sorting using mql, I think you can try the following option:

1. Close all windows except the one where the code, Expert Advisor or script is running.

2. open new windows in a certain sequence, including the one with the Expert Advisor and adjust them or apply a template.

3. Lastly, delete the window in which the code is running.

I have already thought about it - there are a number of interfering factors, for example - at any of the charts the Expert Advisor is running
 
Artyom Trishkin:
I've already thought about it - there are a number of interfering factors, for example - an EA is running on some of the charts
Well then it's probably better to make templates from all charts first before deleting them. And after opening, apply these templates. I hope that very few EAs are writing now that do not pick up their orders.
 
Artyom Trishkin:
I've already thought about it - there are a number of interfering factors, for example - an Expert Advisor is running on one of the charts

ChartID

Returns the ID of the current chart.

longChartID();

Returned value

Value of long type.

 
Alekseu Fedotov:

ChartID

Returns the ID of the current chart.

longChartID();

Returned value

Value of long type.

И? How can knowing your identifier help in sorting the open charts, on which the Expert Advisors work? :)
 
Artyom Trishkin:
И? How does knowing your ID help in sorting out the open charts on which EAs work? :)


I mean the chart on which the Expert Advisor works.

Artyom Trishkin:

I have already thought about it - there are some confusing factors, for example -at some of the charts where the Expert Advisor is running
 
Alekseu Fedotov:


I'm talking about the chart on which the EA works

Artyom Trishkin:

I have already thought about it - there are a number of interfering factors, for example -on some of the charts the Expert Advisor is running
You do not see any problem in deleting existing charts and re-opening them in the correct order in case the Expert Advisor or indicators are running on some of them?
So think about how you're going to do it, and you'll see that the ID and the fact of knowing it won't help you here.
 
Alekseu Fedotov:


I'm talking about the chart on which the EA is running

Artyom Trishkin:

I've already thought about it - there are a number of interfering factors, for example - theEA is running on some of the charts

I understand that in a profile folder I need to rename chars in a certain sequence - re-save to chars happens when I change the profile or close the terminal - hence it's obvious that I need to work with files with a closed profile. But, all this requires calling libraries. That's how it is, I think.
 

Dear forum users!

I have an idea to add a condition to theposition volume calculation function: if the last order closed with a loss, the next one will be placed with an increased ratio.

I have already written it but one of the returns doesn't work, then the other.

Please advise what I am doing wrong?

double GetLot(int type)

{

if(CountOrdersType(type)==0 || LastOrderTypeLots(type)>Max_Lot)

{

if(!Auto_Lot)return(Start_Lot);

return(AccountBalance()*(Lot_Percents/100)*AccountLeverage()/MarketInfo(Symbol(),MODE_LOTSIZE)); }

{ if(!History)return(Start_Lot);

datetime time=0;double lastlot=0;int lastop=0;double prof=0;

for(int i=OrdersHistoryTotal()-1;i>=0;i--)

if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)&&OrderSymbol()==Symbol()&&OrderMagicNumber()==Magic&&OrderType()<=1)

{

if(time<OrderCloseTime()){time=OrderCloseTime();lastlot=OrderLots();lastop=OrderType();prof=OrderProfit();}

}

if(prof < 0 && OrderMagicNumber() == Magic)lot=OrderLots();

return(lot * History_Multiplier); }

return(LastOrderTypeLots(type)*Lot_Multiplier);

}


 
Artyom Trishkin:
You don't see any problem in deleting existing charts and reopening them in the right order in case an EA or indicators are running on any of them?
So think about how you're going to do it, and you'll realise that the ID and the fact that you know it won't help you here.


Reflecting,

Regarding deletion

   long Chart_ID = ChartID();
   int i=0,limit=100;
   while(i<limit)
     {
    if(ChartNext(Chart_ID)<0) break;
      ChartClose(ChartNext(Chart_ID));
      i++;
     }