Calculate the everyday difference between the highest and lowest price - mql4

I have a simple task:
Calculate the daily difference between highest price and lowest difference and print the result in the console.
So far I can only successfully do:
void OnTick()
{
//---
SymbolInfoTick("EURUSD", tickInfo);
Print(tickInfo.last);
}
Can anybody give a sample code for this simple task?
Thanks!

try this abstract sql query
"select subract(Max_price, Min_price) from table_name group by date" if you are using database.

Related

Across multiple rows, for each weekday in-between two dates, calculate a value, then sum by week and group by team member's name

I'm working on a team workload tracker to prevent my coworker from being overloaded with work and help them prioritize.
For this task, I must use Google Sheets.
Explanation:
Peter, John and Harry are all team members. They handle user requests all day every day. When they receive a request, they must enter into a table that looks like the "sample data" tab:
the workload (in days) they think they'll need to address it;
the date they'll start working on it;
the date they must finish it by.
End goal:
This is my end goal. I would like to have one row per team member, and one column per week of the year that shows this team member's total weekly workload across all the requests he's handled that week.
Notes:
They can have concurrent requests.
Requests can span multiple workweeks.
They work Monday-Friday.
A request that takes, say, 2 days to complete does not have to be completed in the 2 days that follow its start date (because it might not be urgent). For instance, a 2-day request that a team member decides to do over a period of 10 working days will take them (2/10) = 0.2 workday per day every day for 10 days.
Each member can (but shouldn't) have a weekly workload equal or greater than 5.
What I've done:
I've messed around with Pivot Tables but couldn't get to my end goal.
I've done the day view. I think I shouldn't use a column per day and somehow need to do all the calculation in (array?) formulas to get to the desired end goal, but I can't figure it out.
Any help would be greatly appreciated!
use:
=ARRAYFORMULA(QUERY(IFERROR(SPLIT(FLATTEN(IF(SEQUENCE(1; MAX(E2:E10-D2:D10))<=E2:E10-D2:D10+1;
A2:A10&"×"&WEEKNUM(D2:D10+SEQUENCE(1; MAX(E2:E10-D2:D10); 0); 2)&"×"&
INDEX(SORT(QUERY(QUERY(SPLIT(FLATTEN(IF(SEQUENCE(1; MAX(E2:E10-D2:D10))<=E2:E10-D2:D10+1;
WEEKNUM(D2:D10+SEQUENCE(1; MAX(E2:E10-D2:D10); 0); 2)&"×"&C2:C10&TEXT(D2:D10+SEQUENCE(1;
MAX(E2:E10-D2:D10); 0); "×ddd×")&ROW(D2:D10); )); "×");
"where not Col3 matches '^$|sam.|dim.|53'"; );
"select Col2/count(Col1),Col4 group by Col2,Col4 label Col2/count(Col1)''"); 2; 1);; 1)&
TEXT(D2:D10+SEQUENCE(1; MAX(E2:E10-D2:D10); 0); "×ddd×"); )); "×"));
"select Col1,sum(Col3) where not Col1 matches '53|^$'
and not Col4 matches 'sam.|dim.' group by Col1 pivot Col2"))

Google Sheets: Average percentage using multiple conditions

I would like to get an average percentage out of my sample, however, I need to use several conditions. I tried to use the AVERAGE and AVERAGEIF together with FILTER but everything returns an error and I think I'm incorrectly "merging" formulas.
You can find my test sheet here.
The rules I need to apply:
The score for individual rows is possible to find in the "Data" sheet in cell N and the total results should be visible in the sheet "Calculation" cell E.
As the sample is huge in real life, I need to filter out several pieces of information and add conditions:
to filter out all items where the code/ID starts with 0: Data!A:A&"", "^0.+"
to filter out all items that are matching the date in the Calculation sheet: Data!C:C=$B3
to filter all items with the specific name: Data!B:B=$A3
Any idea how to get the average % out of items with specific filters?
UPDATE
Expected results: I want to see the total average for a specific date, name, and ID, and let's say I would use these filters, then I would see only the final average percentage.
Test =100%
Test = 0%
Test = 100%
Total Average %: 66.7%
Also, I think the best way would be to use AVERAGEIFS, but I'm getting the error "Array arguments to AVERAGEIFS are of different size".
=AVERAGEIFS(Data!N:N,Data!B:B=$A3,Data!C:C=$B3,Data!A:A&"", "^0.+")
=IFERROR(AVERAGEIFS(Data!N3:N,Data!B3:B,A3,Data!C3:C,B3,ARRAYFORMULA(if(LEN(Data!A3:A),REGEXMATCH(Data!A3:A,"^0.+"),"")),TRUE),"")
or
=IFERROR(AVERAGE(FILTER(Data!N3:N,Data!B3:B=A3,Data!C3:C=B3,REGEXMATCH(Data!A3:A,"^0.+"))),"")
or
=IFERROR(INDEX(QUERY({Data!A3:C,Data!N3:N},"select avg(Col4) where Col1 starts with '0' and Col2 = '"&A3&"' and Col3 = '"&B3&"'"),2,0),"")

How To Turn A Query / Filter Formula Into An Array Formula?

I've got a data range that keeps track of individuals who request tasks to complete, including their names, their progress etc.
So in order to not give new tasks to those with uncompleted previous batches, I've set up the following formula to "alert" me.
=iferror(query(filter($C$1:$E,$C:$C=$C3,D:D<30),"select Col2 LIMIT 1"))
Is there, however, a way to make this into an array formula instead of populating individual cells? I've tried wrapping it in "array formula" but nothing happens. (Is this unarray-able?)
Link to sheet:https://docs.google.com/spreadsheets/d/1wCAs9hkJeLmuUxwbxrosQlHwCw8DFPrigszz5cYYzyI/edit#gid=661764262
Thank you in advance!
Try with
=arrayformula(if(C3:C="","",iferror(VLOOKUP (C3:C, query(C3:D, "select C, Min(D) where D<30 group by C"), 2,false))))
Try
=ARRAYFORMULA(iferror(vlookup(C3:C30,query(C3:D,"select * where D<30 and D is not null"),2,0)))
the question is : do you need the minimum or the first qty ?

If two cells match/duplicates, return and calculate value from second

I have a database with various codes and costs allocated to each and looking for a formula to help calculate various costs if their codes match/duplicate.
If codes match/ duplicate in column A then their corresponding cost (column B, in the same row as code) returned in column C
The costs would need to add together, which is where I'm struggling
Can anyone help?
the easiest way would be to query it out:
=QUERY(A:B; "select A,sum(B) group by A"; 1)

Create array formula that calculates the top 20 values

I have a spreadsheet for calculating attendance statistics. Column I has the names of each of the members, and column H calculates the percentage of practices each member has attended. Here is the list of functions I use to calculate the top 20 people:
J2: =INDEX(I$2:I$23,MATCH(LARGE(H$2:H$23,1),H$2:H$23,0))
J3: =INDEX(I$2:I$23,MATCH(LARGE(H$2:H$23,2),H$2:H$23,0))
J4: =INDEX(I$2:I$23,MATCH(LARGE(H$2:H$23,3),H$2:H$23,0))
J5: =INDEX(I$2:I$23,MATCH(LARGE(H$2:H$23,4),H$2:H$23,0))
...
However, each time a new member joins the team, or an old member quits, I have to change each cell for 20 cells. This takes a long time to do.
Is there a way I can simplify this into one simple ARRAYFORMULA?
An alternative Query:
=query(H:I,"select I order by H desc limit 20")
Never mind. I solved my own problem! If anyone else there is struggling with this just as I have, put this:
=query(H2:I23, " select * where I<>'' order by H desc ")
It will create 2 columns of information, the first column contains the percentages, and the second column contains the names in order. If you don't want the percentages, then shrink the first column as small as it can.

Resources