Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 1002

 
001:
This is the sequence number, not the value of the bar.
So, we can use the index to find out what we want))MQL4 Reference Guide / Predefined Variables
 

How to programmatically calculate profit/loss for SL/TP order in deposit currency (Rubles)?

I.e., I need to get exactly those profit figures that MT4 displays when hovering over the SL/TP line or dragging it with the mouse.

How about getting MODE_TICKVALUE and multiplying by the distance in pips to SL/TP? I tried it with EURUSD and it seems to be the same, but with other pairs at least a slight divergence appears. And in MT4 it's always more by at least some roubles. For example on GBPNZD.

 

I have made a simple EA which outputs information to the log when a new bar appears.

#property strict
//+------------------------------------------------------------------+
int OnInit()
  {
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
void OnTick()
  {
   if(IsNewBar(_Symbol,PERIOD_CURRENT)==true) Print("New bar!");
  }
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
  }
//=== Function
bool IsNewBar(string f_Symbol,      // symbol
              ENUM_TIMEFRAMES f_TF) // timeframe
  {
//---
   static datetime f_LastBar=0;
   datetime f_CurrentBar=iTime(f_Symbol,f_TF,0);
//---
   if(f_LastBar!=f_CurrentBar)
     {
      f_LastBar=f_CurrentBar; return(true);
     }
   else return(false);
  }

It works correctly, in the sense that on the first tick of a new bar a message appears. But for some reason the time of the message is related to the previous bar. I would like to attach a picture. The first one shows that the current time is 21:50:57 and there are only 2 new messages. On the 2nd fig. the current time 21:51:23, there is a 3rd record of a new bar AND saw that the message it appeared after 21:51:00 BUT time of recording in the log somehow that 20:50:47 (clearly, there is a difference of 1 hour between the server and my computer), that my time is not correct. Can you check yours? Is it the same for everyone or is it a glitch?



 

Your computer clock is a few seconds behind or the server clock is a little fast, or maybe both. Print() the current bar time.

if(IsNewBar(_Symbol,PERIOD_CURRENT)!=true) Print("New bar! ", Time[0]);

or both server and local time

 
Vadim_2015:
Well, we can use the index to find out what we want))MQL4 Reference / Predefined Variables

No, this is not the case. I asked: How do you know the value of a bar in an indicator according to its time( by bar time)? If we simply put in iBarShift a WANTED time of day (for example in TF H1, then we get shift on the chart D1, which always changes with each new day, ie every new bar will have the same thing.

 
001:

No, this is a bit different. I asked: How do you know the value of a bar(WANTED DAY) in an indicator by its time (by bar time)? If we simply put in iBarShift the time of a WANTED day (for example, on TF H1, we obtain the shift on the chart D1, which always changes with the arrival of a new day, i.e. every new bar will have the same value.


- How do we find the value in an indicator?

what is a "value" ?

- "If we're bluntly substituting."

If you don't understand the function, you'll get a "new" value, which means that every new bar will have the same value.

 

Good afternoon.

Faced with a problem when testing EAs. Everything was fine for a couple of months, I wrote several EAs that opened and closed orders according to my rules. One day another EA stopped testing. Regardless of the time set in the tester one month passes, it was always September 2014 and the test stopped. It took me a long time to dig it out, downloaded historical data, etc. Then I decided to reinstall MetaTrader. Then I decided to reinstall Meta Trader, uninstalled and reinstalled it. Now all available Expert Advisors in general do not work anymore. My orders are not opening. I have some historical data. When imaging is activated, the chart passes the required time period, but no trading is done. Please advise me at least in what direction to dig, all my ideas are over.

Many thanks in advance.

 
sergeev:

- How do we find the value in an indicator?

what is "value"?

- "If we just plug it in"

Show me this "dumb" code to have something to talk about. so far all we can see is your lack of understanding of how the function works.


I'm not even going to argue. I'm not very good at programming. I'm just an occasional one. Code later. "Value" is open.

 

Hi all, can you tell me how to plot a triangle and calculate the obtuse angle of a triangle?

 
Reason: