Guys please take a look at this.
This line of code is supposed to count all the positions and return the number of open positions... It does so perfectly.
But then I added, if the number of positions is > 5 then don't open positions
stt = 5
The problem is that it just goes ahead to open multiple positions until I run out of money. What do you think? Perhaps my logic is flawed because I need it to open only 5 POSITIONS WHEN SET CONDITIONS ARE MET.
If you don't mind, please assist. Thank you!
Yes you are correct. Should I use a different event handler? But I would need it to constantly check how many trades are open.
No, the problem is PositionTotal() isn't update directly when you open a new trade. There is a delay which can be longer than receiving new tick(s).
Discussed many times on the forum, please do a search about it.
Guys please take a look at this.
This line of code is supposed to count all the positions and return the number of open positions... It does so perfectly.
But then I added, if the number of positions is > 5 then don't open positions
stt = 5
The problem is that it just goes ahead to open multiple positions until I run out of money. What do you think? Perhaps my logic is flawed because I need it to open only 5 POSITIONS WHEN SET CONDITIONS ARE MET.
If you don't mind, please assist. Thank you!
If the goal is OP (Open Position) as much as STT, why don't you simplify it by making a loop as much as STT?
like this:
for(int i=stt-1; i>=0; i--)
And leaves just one condition for OP:
if((p_close<p_open) trade.Sell(lotsize,NULL,Bid,0,0,NULL);
If there is no OP then you just check p_close and p_open value.
I hope this helps. Have a nice coding :-)
If the goal is OP (Open Position) as much as STT, why don't you simplify it by making a loop as much as STT?
like this:
And leaves just one condition for OP:
If there is no OP then you just check p_close and p_open value.
I hope this helps. Have a nice coding :-)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Guys please take a look at this.
This line of code is supposed to count all the positions and return the number of open positions... It does so perfectly.
But then I added, if the number of positions is > 5 then don't open positions
stt = 5
The problem is that it just goes ahead to open multiple positions until I run out of money. What do you think? Perhaps my logic is flawed because I need it to open only 5 POSITIONS WHEN SET CONDITIONS ARE MET.
If you don't mind, please assist. Thank you!