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
***
However, my initial code opened several positions yearly as expected but its problem was just that when the last opened Buy position is in losses it fails to open a sell position as intended . Kindly have a look at the code:
***
I do not understand. Describe in other words.
And further:
Forum on trading, automated trading systems and testing trading strategies
How to start with MQL5
Vladimir Karputov, 2021.09.24 05:27
*** and add the code using the button ...
I do not understand. Describe in other words.
And further:
I meant when the last opened position is a Buy (with its Lot size being currently the highest and no opened position has equal Lot size) and the current market trend goes downwards thereby making this Buy position to lose minimum of 250 pips, that is not making profit, then the EA ought to open a Sell position with same Lot size as that Buy.
Thanks for your help.
I meant when the last opened position is a Buy (with its Lot size being currently the highest and no opened position has equal Lot size) and the current market trend goes downwards thereby making this Buy position to lose minimum of 250 pips, that is not making profit, then the EA ought to open a Sell position with same Lot size as that Buy.
Ok. Add code:
Forum on trading, automated trading systems and testing trading strategies
How to start with MQL5
Vladimir Karputov, 2021.09.24 05:27
*** and add the code using the button ...
I meant when the last opened position is a Buy (with its Lot size being currently the highest and no opened position has equal Lot size) and the current market trend goes downwards thereby making this Buy position to lose minimum of 250 pips, that is not making profit, then the EA ought to open a Sell position with same Lot size as that Buy.
Thanks for your help.
Your mistake: You remember the parameters of a certain position, but for some reason compare in the m_positions object:
Ok. Add code:
When the last opened position is a Buy (with its Lot size being currently the highest and no opened position has equal Lot size) and the current market trend goes downwards thereby making this Buy position to lose minimum of 250 pips, that is not making profit, then the EA should open a Sell position with same Lot size as that Buy and vice versa.
Kindly see my original code, before your proposed solution, below:
Your mistake: You remember the parameters of a certain position, but for some reason compare in the m_positions object:
Thanks for your response. Kindly confirm your proposed correction is:
Based on above, the complete code becomes thus:
However, when backtested from January to September 2021, only 2 positions were opened.
Thanks for your response. Kindly confirm your proposed correction is:
Based on above, the complete code becomes thus:
However, when backtested from January to September 2021, only 2 positions were opened.
Yes, now the train of thought is correct
Yes, now the train of thought is correct
Thanks for your reply. From year 2021 backtesting, EA opened last Buy position on 6th January 2021 and did not open any Sell after losing 250 pips and above till 23rd September 2021 when testing ended.
Maybe the train of thought I coded is incorrect with respect to what I intend to achieve.
In summary, I want the EA to function like this:
1. At start, EA to open 1 Buy and 1 Sell positions with 0.01 Lot size each
2. If last opened position is Buy and market trends up, allow current Buy to close with 250 pips take profit and open new Buy with double, 2 times, lot size of previous Buy.
3. If last opened position is Buy and market trends down, immediately current Buy loses 250 pips (makes no profit) open Sell with same, 1 times, lot size of previous Buy.
4. If last opened position is Sell and market trends down, allow current Sell to close with 250 pips take profit and open new Sell with double, 2 times, lot size of previous Sell.
5. If last opened position is Sell and market trends up, immediately current Sell loses 250 pips (makes no profit) open Buy with same, 1 times, lot size of the previous Sell.
6. Lastly, only 1 Buy and 1 Sell position can have similar (same) lot sizes,
Thanks a lot for assisting.
Thanks for your reply. From year 2021 backtesting, EA opened last Buy position on 6th January 2021 and did not open any Sell after losing 250 pips and above till 23rd September 2021 when testing ended.
Maybe the train of thought I coded is incorrect with respect to what I intend to achieve.
In summary, I want the EA to function like this:
1. At start, EA to open 1 Buy and 1 Sell positions with 0.01 Lot size each
2. If last opened position is Buy and market trends up, allow current Buy to close with 250 pips take profit and open new Buy with double, 2 times, lot size of previous Buy.
3. If last opened position is Buy and market trends down, immediately current Buy loses 250 pips (makes no profit) open Sell with same, 1 times, lot size of previous Buy.
4. If last opened position is Sell and market trends down, allow current Sell to close with 250 pips take profit and open new Sell with double, 2 times, lot size of previous Sell.
5. If last opened position is Sell and market trends up, immediately current Sell loses 250 pips (makes no profit) open Buy with same, 1 times, lot size of the previous Sell.
6. Lastly, only 1 Buy and 1 Sell position can have similar (same) lot sizes,
Thanks a lot for assisting.
I would work through OnTradeTransaction - I would catch the "EXIT" deal.
Thanks for your reply. From year 2021 backtesting, EA opened last Buy position on 6th January 2021 and did not open any Sell after losing 250 pips and above till 23rd September 2021 when testing ended.
Maybe the train of thought I coded is incorrect with respect to what I intend to achieve.
In summary, I want the EA to function like this:
1. At start, EA to open 1 Buy and 1 Sell positions with 0.01 Lot size each
2. If last opened position is Buy and market trends up, allow current Buy to close with 250 pips take profit and open new Buy with double, 2 times, lot size of previous Buy.
3. If last opened position is Buy and market trends down, immediately current Buy loses 250 pips (makes no profit) open Sell with same, 1 times, lot size of previous Buy.
4. If last opened position is Sell and market trends down, allow current Sell to close with 250 pips take profit and open new Sell with double, 2 times, lot size of previous Sell.
5. If last opened position is Sell and market trends up, immediately current Sell loses 250 pips (makes no profit) open Buy with same, 1 times, lot size of the previous Sell.
6. Lastly, only 1 Buy and 1 Sell position can have similar (same) lot sizes,
Thanks a lot for assisting.
New Project 'Andromeda Nebula'
How to join the project
In MetaEditor, in the "Tools" window, go to the "Public Projects" tab, in the "Name" column on the "AlligatorAndStochastic" project, right click and select the "Join" item