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
Thanks for your input I appreciate that, firstly I will try and print it out as you have suggested, have tried the Getlasterror function before but it doesn't bring out any error, I will make use of your advice now
So you have no other OrderClose() feature other then sl and tp ?
No OrderCloseBy() or anything just sl tp only ?
What happens when the indicator moves in the opposite direction ? Do you just let it ride until it hits the sl ? Regardless of the reversal of the indicator ?
Please confirm again that you have no other OrderClose() in your code and only way the OrderClose() is when sl and tp ONLY ?
Can you not post the entire code ? Use the (Alt+S) OR Code feature of the forum that is specifically for posting your code to this forum ?
We need to see it.
Additionally we need to see your logs in the terminal. What does the terminal say when the Order is closed and why ? Does it say that it's closed due to sl or tp ? OR something else ?
We need to see this too.
Then don't forget to Print("k =", k); This will return k for your to see in your terminal every time Buy, and Sell k will be true or false.
The using the Print call to return things in your terminal will tell you a lot so you can see what is happening.
Not at all, I don't have any other functions to close trade except for the Sl and TP.
So what does the terminal say is the reason for the trade being closed ?
Does it say Sell Order opened then show you that SL was hit or does it say there was an error opening the trades ?
Can you post a snip of your terminal output from the "Experts" Tab ?
This tab should tell you why the orders are opening and closing etc.
bool k =OrderSend() in your code
According to the docs OrderSend() is an int type.
So you might change this to
int k=OrderSend()
Otherwise you will get an error in the terminal expressing to check your return code.
You need to do this and test in the tester or in your demo account and read the terminal outputs.
You have an error with opening orders.
Some sell orders are opening and being terminated by sl or tp but others are simply errors.
The error ones that you see on your chart or tester will say "closed by tester"
When the market data feed opens tomorrow I'll test in the demo some more.
I edited your code this way to get error returns.
Only sell orders with sl and tp but not buying.
I'll let it run on the demo over night which seems to be working without errors now, but the tester shows only buys and no sells. I am not sure why yet, but will mess it some more tomorrow to learn from this myself.
However, the demo seems to be selling.
So what does the terminal say is the reason for the trade being closed ?
Does it say Sell Order opened then show you that SL was hit or does it say there was an error opening the trades ?
Can you post a snip of your terminal output from the "Experts" Tab ?
This tab should tell you why the orders are opening and closing etc.
Hi,
yes it close trades due to stoploss and takeprofit
Another problem with your code is the variable type
bool k =OrderSend() in your code
According to the docs OrderSend() is an int type.
So you might change this to
int k=OrderSend()
Otherwise you will get an error in the terminal expressing to check your return code.
You need to do this and test in the tester or in your demo account and read the terminal outputs.
You have an error with opening orders.
Some sell orders are opening and being terminated by sl or tp but others are simply errors.
The error ones that you see on your chart or tester will say "closed by tester"
When the market data feed opens tomorrow I'll test in the demo some more.
I edited your code this way to get error returns.
I tried to print out the error to, I have same results 0
I think 0 means no error, so if that we no error with our ordersend
I made some edits and there are no buy/sell errors in the tester.
I'll let it run on the demo over night which seems to be working without errors now, but the tester shows only buys and no sells. I am not sure why yet, but will mess it some more tomorrow to learn from this myself.
However, the demo seems to be selling.
The reason why you have no sell here is "retun"
I made some edits and there are no buy/sell errors in the tester.
I'll let it run on the demo over night which seems to be working without errors now, but the tester shows only buys and no sells. I am not sure why yet, but will mess it some more tomorrow to learn from this myself.
However, the demo seems to be selling.
Not at all, I don't have any other functions to close trade except for the Sl and TP.
Somehow the Print function is getting suppressed so I can't diagnose this any further.
Your iCustom comparisons are always true that much I know.
I'm not sure if this is why there is some conflict in milliseconds for the Print function that is not being read by the terminal or something else.
I can comment/omit your comparisons and Print function calls anything I want as it should, but when inserting your code only a few lines of Print calls can be read, and NO print calls withing the code block comparison are being read not even the GetLastError.
GetLastError does read in the tester but not the print calls. I'm not sure why.