
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Function WritingLineInFile().
I've rewritten this function the other day, added the parameter fs, which is responsible for writing the first line of the file, which is different from other lines, for example, the header of the table. The first line will be written to the file only if two conditions are met simultaneously: the length of the line is greater than zero and the file size is zero. And in order to maintain compatibility with the previous version, the new parameter has been made optional.
Parameters of the WritingLineInFile() function:
ZS. Attached is a script to test function.
DateBeginQuarter
first of all I'm trying to understand the lines:
By default nq = 0, so it is not clear what we get from MathMod(nq/4) expression, as the result will always be 0. Also the second line is not clear, as 0/4 has no remainder, please clarify.
Thank you, Natasha, for your question. Thanks to you, I rechecked the function and found the error. In the line
I need to replace the minus sign with a plus sign.
And now to the substance of your question. nq is not always equal to zero. There can be any integer values, including negative ones. These lines work when nq is a multiple of 4, i.e. when you need to add or subtract 4 quarters (year).
Thank you, Natasha, for your question. Thanks to you, I rechecked the function and found the error. In the line
I need to replace the minus sign with a plus sign.
And now to the substance of your question. nq is not always equal to zero. There can be any integer values, including negative ones. The lines you have specified work in cases where nq is a multiple of 4, i.e. when you need to add or subtract 4 quarters (year).
Thanks for your reply, Igor.... it took me longer than usual to deal with the function, but I still figured it out))))))) in the same function, it seems to me that I don't need to decrease the year in the expression:
then it will be correct.
...in the same function, I don't think you need to reduce the year in the expression...
GetDrawdownOpenPosInPoint() function
Well, I've finished thorough testing of this function. I've taken into account the spread where necessary, tried to optimize it... The function returns the maximal drawdown of the currently opened positions in pips. Traditionally, you can pass parameters to the function and thus filter out positions you need for analysis:
SZZ. Attached is a script for testing the function GetDrawdownOpenPosInPoint().
Justify, Natasha, why not? On the contrary, it seems logical to me to decrease the year after closing the monthly circle in the opposite direction. Reducing the year in the expression you just mentioned is the same as moving the hour hand back one hour after the minute hand has been wound back a full circle. Give us your version of the function, and we'll discuss it... Maybe your version will be more successful than mine.
I reasoned like this: let's say we need to determine the start of Q7 in past and future, then nq= -7 and nq=7 respectively. Mathfloor will return -2 for the past and +1 for the future (judging from the function description in the documentation), hence for the situation in the past we will subtract one more year than we add in the future..... if we continue further calculations for the past, we will have to reduce the year again and we will end up at 2009.....
Unfortunately due to lack of time (I barely have time to read the site page), I can not provide the code I think is correct, but I think if necessary, it will not be difficult to correct it.
I reasoned like this: let's say we need to determine the start of Q7 in past and future, then nq= -7 and nq=7 respectively. Mathfloor will return -2 for the past and +1 for the future (judging from the description of the function in the documentation), hence for the situation in the past we will subtract one more year than we add in the future..... if we continue further calculations for the past we will have to reduce the year again and we will end up in 2009...
I agree with your reasoning, but you are forgetting about the data types involved in the operations. MathFloor() can be omitted altogether. See the result of the script in the attachment.