Hi, any help will be dearly appreciated.
So I had tested a few strategies out which ran on a single Symbol, and analysed data only from a single Period.
It was coded so that positions can only be open when there is no open positions of that type already open.
when a position was successfully initiated OMNS5 would increase and no longer be less than T which is always '1'
Then, on the other end I reduced OMNS5 whenever a position was closed
but not when I brought the stop loss up to a few pips above (or in this case below) breakeven.
So to combat the problem of OMNS5 not decreasing in value when the Stop loss was moved to break even, and as one position was the maximum ever open at any time I could get around this problem through resetting OMNS5 to 0 whenever no positions were open like this;
Now I've reached a stage where I wish to compile together strategies unique to each timeframe into a single EA. The problem I am facing is that OMNS5 is no longer able to be reset to 0 as effectively because there is often another position open that was initiated by another timeframe strategy.
Whilst a position is open the reset function is ineffective at returning the OMNS5 to 0.
Now, to solve this solution I thought I could give OMNS5 a unique magicnumber.. but how then do i search through open orders to check none with this unique MN exists, and in that case then return the correlative OMNS5 to 0?
Equally, if I wanted to trade multiple strategies on the same Period, would it still be able to identify that no ticket number that correlates to a particular strategy is open (whilst others may be) and return a value of 0 its OMNS/B so that it would look for the conditions to open a position?
Anyway i try is just an intellectual abomination..
All help will be appreciated!
This is the abomination.. I just can't see how to condition it to realise the absence of a MagicNumber..
The problem remains that OMNS511 will only be reset when no other position is open..
Don't hard code the magic number, have it as an input and input a different number for each EA instance that is running.
Check if there is an order with the magic number not for orders without.
Use descriptive variable names, especially when you want others to comment on your code.
Ok, I won't hard code the final magic numbers, please excuse the non-descriptive variable names.
I'll try to check for the magic number, as I understand the folly in trying to identify an absent number..
Yet because other positions will be open I'm struggling to write the code to look for the magic number and achieve the desired outcome..
The problem is that I can't check if there is an order with the magic number and then reset if not.. I can't imagine how to put that down in code effectively.
Is there a way?
The best I come up with is something like this;
but that's almost as ineffective as the previous if(OrdersTotal == 0) function..
This probably isn't doing what you think it is:
You have written the same as:
I'm beginning to think it's not possible as every time it grabs a number with magic number 1 it then resets 2,3 and 4..
Every piece I write is ineffective.. just a rehash of the same nonsense.
Glad you got it sorted.
Just to reiterate my early post, don't do this:
It is not the same as:
Can also use a switch