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
Could you help me further because it is still opening position at the same price. My tick0 would like to be the price where not to open another position at. My buy condition will be something like:
I tried to search on forums but still with no results.
Thank you in advance,
Never compare doubles with == or != (exception is usually 0). If I really must compare prices with the == sign then I first convert it to integer. Every coder here have a different flavor of that function. Example of mines can be found here. I use a function called p2i (price to integer). You cannot see the floating point value in the 20th place for example.
1.12345000000000000001 vs 1.12345000000000000009. When you use Print commands, it'll say something like 1.123450000 and 1.123450000. But the above 2 values are not equal.
Additional reading.
It is possible that Bid != tick0 even if Bid is equal to tick0 . . . read this thread: Can price != price ?
Could you help me with this one? Because I can not find my mistake, or if I did something wrong (since I write that line **). I read the topics that you suggested but I am stuck here.
Could you help me with this one? Because I can not find my mistake, or if I did something wrong (since I write that line **). I read the topics that you suggested but I am stuck here.
Your loop is wrong, why are you executing the loop if total equals 0 ? i.e. if you have no open orders ? if you fix your loop and you have no open orders then there is no way that your OrderSend() can ever be executed . . .
When you write code you need to read it and execute it in your mind, line by line, to see if it makes sense and works. So start at the beginning, there are no open orders, total equals 0 what happens ?
But you are not checking if a trade was opened at the current price, isn't that what you wanted to do ? you need to check for this inside the loop, if there is a trade at current price then remember this fact by setting a bool variable to true, then outside the loop check this variable and if false you can place your trade.
Your loop is wrong, why are you executing the loop if total equals 0 ? i.e. if you have no open orders ? if you fix your loop and you have no open orders then there is no way that your OrderSend() can ever be executed . . .
When you write code you need to read it and execute it in your mind, line by line, to see if it makes sense and works. So start at the beginning, there are no open orders, total equals 0 what happens ?
But you are not checking if a trade was opened at the current price, isn't that what you wanted to do ? you need to check for this inside the loop, if there is a trade at current price then remember this fact by setting a bool variable to true, then outside the loop check this variable and if false you can place your trade.
I tried this way but still open double position... I think my boll is wrong placed , and my check open position is that compare double ... is that one right?
What function is this code in ?
This suggests it returns a bool . . .
yet this suggests it returns an int ?
Why is your OrderSend() still within the loop ? where does OpenPrice come from ?