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
Yes,with that function i am just trying to get the total amount lost for buy and sell, then add them together.
So if you had 5 losers at -10.00 and 3 winners at +3.00 you want to retrieve -10.00 (not -7.00)?
See if this makes sense:
See if this makes sense:
Not the "Right in front of my face" solution I expected.
I see my problem is understanding the count/addition part. Definitely something I need to work on.
Thank you very much!!
Well, there were quite a few issues with your other code. FWIW:
Be careful with your brackets.
I'm guessing you only want Long_Count++ to run if OrderType()==OP_BUY? That isn't the case with your code. You would need to do this:
More fundamentally, I'm not sure why you are adding 1 to Long_Count, and also setting the value of Long_Count to the price difference between OrderOpenPrice() and OrderClosePrice() each time? It seems to me you are mixing apples (the count) and oranges (the price difference). There is a big difference between:
and
Long_Count+=OrderOpenPrice()-OrderClosePrice();
A count should really be an integer or a long, not a double.
Also, if you subtract the prices from one another you're not taking into account your lot sizes. OrderProfit() seems more logical to me. It looks like you don't have any commission, but it is probably good practice to account for it (and swap).
HTH
Well, there were quite a few issues with your other code. FWIW:
Be careful with your brackets.
I'm guessing you only want Long_Count++ to run if OrderType()==OP_BUY? That isn't the case with your code. You would need to do this:
More fundamentally, I'm not sure why you are adding 1 to Long_Count, and also setting the value of Long_Count to the price difference between OrderOpenPrice() and OrderClosePrice() each time? It seems to me you are mixing apples (the count) and oranges (the price difference). There is a big difference between:
and
A count should really be an integer or a long, not a double.
Also, if you subtract the prices from one another you're not taking into account your lot sizes. OrderProfit() seems more logical to me. It looks like you don't have any commission, but it is probably good practice to account for it (and swap).
HTH
I see what you are talking about now.
At least some of the "Right in front of my face" showed up, Brackets. Using brackets to define exactly what I am looking for is something lack in doing sometimes, especially since I code more on paper than the computer, I tend to abbreviate everything down to its simplest form which is not always the correct way of doing things.
I am reading up Operators and Expressions right now, then I will go through your code,figure what I need to learn and how to apply it. I am glad to have the week off work now.
Your help is very much appreciated, Thank You.
My initial attempt.
Comments? Criticisms? Laughter?
Does it do what you want? That's the most important thing; the rest is academic.
Just some thoughts from quickly skimming through it:
You can save a line of code by checking OrderOpenTime() before testing the OrderType().
An order cannot be more than one type. So use an 'if / else if' statement:
It depends on how you want to deal with commission and swap (can the first 'if' criteria be met while the second 'if' statement fails?), but this may be simpler: