Help to upgrade to MetaTrader 5 without loss - page 20

 
vspexp:
I found it here, see if it works for you, it has all currencies in the dollar index.
It is an incorrect calculation with a peek into the future on all bars except the last one.
 

Good afternoon. Two years ago I wrote an indicator for mt4, now I am using mt5 and I cannot translate these lines to mql5. I cannot translate these lines to mql5.

#property indicator_chart_window



int init()

  {

   return(0);

  }

int start()

  {

int t=OrdersTotal();

int th=OrdersHistoryTotal();

int a,day;

double p=0;

double profit=0;

double spread=MarketInfo(Symbol(),MODE_SPREAD);

if(DayOfWeek()==1)day = DayOfYear()-1;

if(DayOfWeek()==2)day = DayOfYear()-2;

if(DayOfWeek()==3)day = DayOfYear()-3;

if(DayOfWeek()==4)day = DayOfYear()-4;

if(DayOfWeek()==5)day = DayOfYear()-5;

for(a=th-1;a>=0;a--)

 {

  OrderSelect(a,SELECT_BY_POS,MODE_HISTORY);

  if(TimeDayOfYear (OrderCloseTime ()) > day)

   {profit+=OrderProfit () + OrderCommission () + OrderSwap ();}else{continue ;}

  if((Symbol() == OrderSymbol()) && (TimeDayOfYear (OrderCloseTime ()) > day))

   {p+=OrderProfit () + OrderCommission () + OrderSwap ();}else{continue ;}

 }



Comment("СПРЕД = ",spread,"\n","НЕДЕЛЬНАЯ ПРИБЫЛЬ по текущему инструменту = ",p,"\n","ОБЩАЯ ПРИБЫЛЬ за неделю = ",profit+"\n"+

        "Стоимость пункта = "+MarketInfo(Symbol(),MODE_TICKVALUE));

   return(0);

  }
 
zlodei:

Good afternoon. I wrote an indicator for mt4 2 years ago, now I am using mt5 and I cannot translate these lines to mql5 in any way. Please, help me.

If you are going to code in MQL5 in future, I recommend "Orders, Positions and Trades in MetaTrader 5" article. There you will see how conceptually the system of working with orders in MT4 differs from MT5.

SZY. And the code should be inserted through the SRC button at the top of the window in which you write your comment...

Ордерa, позиции и сделки в MetaTrader 5
Ордерa, позиции и сделки в MetaTrader 5
  • 2011.01.05
  • MetaQuotes Software Corp.
  • www.mql5.com
Надежный торговый робот не может быть создан без понимания механизмов работы торговой системы MetaTrader 5. Клиентский терминал получает от торгового сервера информацию о позициях, ордерах и сделках. Чтобы правильно обработать эти данные средствами MQL5 необходимо хорошо представлять как происходит взаимодействие mql5-программы и среды исполнения терминала.
 
denkir:

Evilman, if you are going to code in MQL5 in the future, I recommend the article "Orders, Positions and Trades in MetaTrader 5". There you will see the conceptual difference between the order handling system in MT4 and MT5.

About the SRC, I corrected it.

If there was a problem with positions )))) so I can'ttranslate DayOfWeek(), the article https://www.mql5.com/ru/articles/81 saved me in many ways, but not this time.(((

Переход с MQL4 на MQL5
Переход с MQL4 на MQL5
  • 2010.05.11
  • Sergey Pavlov
  • www.mql5.com
Данная статья, построенная в форме справочника по функциям MQL4, призвана помочь переходу с MQL4 на MQL5. Для каждой функции языка MQL4 приведено описание и представлен способ ее реализации на MQL5, что позволит вам значительно ускорить перевод своих программ с MQL4 на MQL5. Для удобства функции разбиты на группы, как в документации по MQL4.
 
zlodei:

About SRC - corrected.

If there was a problem with positions )))) so I can'ttranslate DayOfWeek(), the article https://www.mql5.com/ru/articles/81 saved me a lot, but not this time.(((

https://www.mql5.com/ru/docs/constants/structures/mqldatetime
Документация по MQL5: Стандартные константы, перечисления и структуры / Структуры данных / Структура даты
Документация по MQL5: Стандартные константы, перечисления и структуры / Структуры данных / Структура даты
  • www.mql5.com
Стандартные константы, перечисления и структуры / Структуры данных / Структура даты - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Thanks, I've already read this........
 
zlodei:
Thanks, I've already read this........

И? What's wrong with the example?

   datetime date1=D'2008.03.01';
 
   MqlDateTime str1;
   TimeToStruct(date1,str1);

   printf("day of week= ",str1.day_of_week);
 
Help translate a great indicator into MQL5, without it you'd have no hands...))
Files:
 
BilliGordon:
Help translate a great indicator into MQL5, without it you'd have no hands...))
Files:
DayOfWeek.ex5  5 kb
 

Hello All!

I trade with one TS and I'm going to switch to MT5

If anyone is able to remake it for MT5 I would be very grateful!

Files:
81l.zip  67 kb
Reason: