
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
First of all, it is not clear from your post whether variables are global or local.
Any loops that include closing trades should count down, not up. You should at least read every new post on this forum, then you would know that.
Your whole block of code hinges on this
So check that before executing the loop.
What is this meant to do?
TimeCurrent()>=trade_hour
It will always be true
What happened to tomorrow_midnight?
recommence_trading=today_midnight+trade_hour*3600;
Once you have sorted this, you should then code to check whether the OrderClose is successful or not. If not, then retry.
I see you are telling return(0) or return(1). That means that you are using functions to make your program; in that case, what we are seeing here is a part of a single function? If so why are you declaring all those variables inside that function? Some of them would normally be in the global space. That been said, there are many ways to write your software, but you have to keep in mind that engineering your idea is propably the most time consuming part of all the work that has to be done in order to complete your program (see: figure out how to do things).
Regarding your last post, it looks like there are not enough informations for us to help you out as the critical part should be what are you are doing with the value returned. I am assuming that return(0) will make something such as trade_disabled=true and return(1) will make a false. But you must work out - or post here some more code on how you are using trade_disabled
best regards
edit: GumRai, my post may seem out of space regarding your last post but i noticed the presense of it only after submitting mine - I was stuck in page 2 to be precise. Apologies for that :)
Hi,
Yet to read the answers. How about placing the order sending function in an "if" block checking for a flag. Then after closing all positions for the day, set the flag to false. Then, for every tick, check if the flag is false. If the flag is false, check what is current time. If the current time is the "next day pre-decided time", then the flag is set to true.
As I understand, once the advisor is activated, onTick function will be invoked until the advisor is deactivated.
Now, checking other replies from "Gurus". :)
Warm wishes
Amitabh.
Hello Programmer.im stuck with this code. i want to stop trading for the day and continue the next trading day if the sum of close loss and open loss reaches certain amount like say -$100.
Please edit your post and use the code button (Alt+S) when pasting code.
EDIT your original post, please do not just post the code correctly in a new post.