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

 
MosheDayan:

Friends, how to get out of this situation correctly... The indicator draws two horizontal lines from CSV (Red - from the beginning of the day to the end of the day) Blue - Beam coming from the past days, at different price levels. But there are days when these levels have the same value/price. What is the right way out of this situation, so that when the lines coincide, the Ray(Blue) is displayed, and the Red line is not visible on the chart, but physically present... i.e., it is transparent.

Now - Draw_Level("Red", red, DRAW_NONE, STYLE_SOLID,0); it stops drawing the line, but the Ray is not visible from under it either. Thanks.

Pay attention to the sequence of object creation. And what is Draw_Level() Why mention a custom function if no one is familiar with it?

 
Artyom Trishkin:

Good afternoon. What exactly were you trying to do yourself? I only see the two codes attached. If you need someone to do everything for you, that's what freelancing is for.

And if you yourself are trying, then show me exactly what you're doing and where you don't understand.

Good afternoon, Artem! Correct remark. Yes, I am attaching the Wordovan file with the code. What I have added to my code from borrowed algorithm is marked in red. I cannot say for sure where I do not understand it yet because I cannot entirely understand the mechanism of code's work. But maybe you may be able to direct me in the right direction with your advice. I would be grateful to you.

 

Good day!
I will be opening an order on a different symbol from the chart where the Expert Advisor is attached. The question is, do I have to pre-check the correctness of Bid and how do I do that?

double Bid0= MarketInfo(OtherSymbol0,MODE_BID);
OrderSend(OtherSymbol0,OP_SELL,1,Bid0,3,stoploss,takeprofit,"My order",16384,0,clrGreen); 
 

Good afternoon.

Can you advise how to write the following time in the code: 23:59 of the first Friday of the month after the first Wednesday of this month? i.e. if the month started on Thursday then you need the time 23:59 of the second Friday...

Thank you.

 
MosheDayan:

Good afternoon.

Can you advise how to write the following time in the code: 23:59 of the first Friday of the month after the first Wednesday of this month? i.e. if the month started on Thursday then you need the time 23:59 of the second Friday...

Thank you.

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   int countWedn=0;
   int countFrid=0;
   if(TimeDayOfWeek(TimeCurrent())==5 && Hour()==23 && Minute()==59)
     {
      countWedn=0;
      countFrid=0;
      for(int i=0; i<=Day(); i++)
        {
         if(TimeMonth(iTime(Symbol(),PERIOD_D1,i))==TimeMonth(TimeCurrent()))
           {
            if(TimeDayOfWeek(iTime(Symbol(),PERIOD_D1,i))==3)countWedn++;
            if(TimeDayOfWeek(iTime(Symbol(),PERIOD_D1,i))==5)countFrid++;
           }
        }
     }
   if(countWedn==1 && countFrid==1)Print(" 23:59 первой пятницы месяца после первой среды этого месяца ");
  }
//+------------------------------------------------------------------+
 
Artyom Trishkin:

You can. And the direction of thought is correct. Can you show me how you tried to take the parameters?


Got it figured out. It's necessary to "bind" the graphical object to the corresponding class.

#include <ChartObjects\ChartObject.mqh>.

void OnStart()

{

CChartObject object;

string objName = "";

double price = 0;

datetime dt;

int NumTriangles = ObjectsTotal(ChartID(),0,OBJ_TRIANGLE);

for (int j=0;j<NumTriangles;j++){

objName = ObjectName(ChartID(),j);

object.Attach(ChartID(),objName,0,3);

for (int i=0;i<object.NumPoints();i++){

price = object.Price(i);

dt = object.Time(i);

Print("Pivot dot - ",IntegerToString(i)," Time = ",TimeToString(dt)," Price = ",DoubleToStr(price,4))

}

object.Detach();

}

 

Good afternoon everyone!

I have such a question, there is such a block:

opf_all=0;
  for(int is=OrdersHistoryTotal(); is>=0; is--)
   {
    if(OrderSelect(is, SELECT_BY_POS, MODE_HISTORY) && OrderSymbol()==Symbol() && OrderMagicNumber()==MN)
     {
      opf_all=opf_all+OrderProfit()+OrderCommission()+OrderSwap();
     }
   }

The variable opf_all should output the total profit for the whole period. But when you select the current day parameter in the account history tab of the terminal, this module shows the result

only for the current day, and when we select the entire period, this module shows for the entire period. This should not be the case. Regardless of the interval in the account history

the module should still show the total profit for the entire period. Maybe I do not understand something?

Is this problem solved somehow?

 
Valerius:

Good afternoon everyone!

I have such a question, there is such a block:

opf_all=0;
  for(int is=OrdersHistoryTotal(); is>=0; is--)
   {
    if(OrderSelect(is, SELECT_BY_POS, MODE_HISTORY) && OrderSymbol()==Symbol() && OrderMagicNumber()==MN)
     {
      opf_all=opf_all+OrderProfit()+OrderCommission()+OrderSwap();
     }
   }

The variable opf_all should output the total profit for the whole period. But when you select the current day parameter in the account history tab of the terminal, this module shows the result

only for the current day, and when we select the entire period, this module shows for the entire period. This should not be the case. Regardless of the interval selected in the account history

the module should still show the total profit for the entire period. Maybe I do not understand something?

Is this problem solved somehow?

No, it cannot be solved other than by selecting the size of the calculated history in the "Account history" tab

And please paste the code using the SRC button - it's right above the text entry field in the message formatting menu. I inserted your unreadable "spoilage" correctly.

 
Artyom Trishkin:

No, not solved other than by selecting the size of the calculated history in the Account History tab

And please paste the code using the SRC button - it's right above the text entry field in the post formatting menu. I pasted your unreadable "spoilage" correctly.

Thanks and apologies...

 

Hello.There is a button on the chart https://www.mql5.com/ru/code/19049 and it opens the website.I need to be able to enable the script through this button.can it be redone?.thanks.

Link
Link
  • votes: 11
  • 2017.09.01
  • Iurii Tokman
  • www.mql5.com
Индикатор создает графическую кнопку, при нажатии на которую открывается окно браузера с сайтом, заданным в настройках индикатора.
Reason: