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

 
Konstantin Nikitin:

Thank you. In words, what do we divide the profit in currency by?

.../(OrderSymbol()==Sy_1 ? tickValue_1 : tickValue_2));
   
Maxim Kuznetsov:
You cannot add up the points of two different instruments.

I understand that the point value is different, but it does not matter in this case.

 
PolarSeaman:

Thank you. In words, what do we divide the profit in currency by?

The point value in the currency of the deposit.
For me it would be more correct to write this function on 1 character

int Punkts_B(const string symbol="", const int _Mag=-1)
  {
   double profit = 0;
   for(int t=0;t<OrdersTotal();t++)
     {
      if( !OrderSelect(t,SELECT_BY_POS,MODE_TRADES) )  continue;
      if( OrderSymbol()!=symbol )                      continue;
      if( OrderMagicNumber()!=_Mag )                   continue;
      if( OrderType()!=OP_BUY && OrderType()!=OP_SELL) continue;

      profit+= OrderProfit()+OrderSwap()+OrderCommission();
     }
   return( (int)MathFloor(profit/SymbolInfoDouble(symbol, SYMBOL_TRADE_TICK_VALUE)) );
  }

int xxx = Punkts_B("EURUSD", 12345) + Punkts_B("GBPUSD", 12345);
And add up points if needed when calling.
 
Konstantin Nikitin:

Point value in the deposit currency.

How do the words(OrderSymbol()==Sy_1 ? tickValue_1 : tickValue_2); say?

Print(Punkts_B("GBPUSD", "AUDUSD",11151)) prints zero;

 
PolarSeaman:

As words expression(OrderSymbol()==Sy_1 ? tickValue_1 : tickValue_2));

Print(Punkts_B("GBPUSD", "AUDUSD",11151));

Conditional operator ?:

 
Konstantin Nikitin:

Conditional operator ?:

Thank you.

 

Colleagues, help me out.

I'm trying to figure out how to work with registry, I've made a simple Expert Advisor for the test. Reading data from system registry goes without problems, but there are problems with writing, MT and memory crashes... (((

Maybe my eye is already soaked and I don't see the obvious...

Files:
TestReg.mq5  25 kb
 

You need to place their names next to the ends of the curves in the separator window, which should be linked to them.

Please explain how to do this.

 
khorosh:

You need to place their name next to the ends of the curves in the separatist window, which should be linked to them.

Please explain how to do this.

Objects - they can be displayed in any window of the terminal and its subwindows.

 

Artyom Trishkin:

Objects - they can be output to any terminal window and its subwindows.

--------------------------------------------------------------------------------------------------------------------------------------

I tried it like this, but it doesn't work.

  if(ObjectFind("Spread")<0) 
    {
     ObjectCreate(1,"Spread", OBJ_TEXT, 0, Time[0],LevLabelSpread );
     ObjectSetText("Spread", "                    Spread", 10, "Arial", clrYellow);
    }
  else
    {
     ObjectMove(1,"Spread", 0, Time[0], LevLabelSpread);
    } 
Maybe it's something with the window numbering. If there is one separate window in the graph, its number ==1?
 
Kirill Belousov:

replace in your expressions - && with "AND AT THE SAME TIME", and replace || with "OR".

you should be able to read that and see how it works.


the first line will work with either magic =777 (when hand_orders=false) or magic = 0 (when hand_orders=true)

the second line ALWAYS works with majic=777, and with hand_orders=true works ADDITIONALLY with majic=0

Thank you!