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
Crossing of two iMA 1.007
The option of lot selection is included: manual lot or percentage of risk
Thanks, that option is working perfectly fine
Terms and Conditions:
Hi everyone,
this is a brilliant initiative to share ideas, and I'm sure it'll be very helpful to anyone like me who is trying to put together his/her first EA.
The strategy that I'd like (and I'm trying) to translate into code is very simple:
1. Open a trade on a random position (Long or Short);
2. After 60 seconds check if this trade has reached TP or SL:
- if it did: close the current trade and open a new one of the same value of the first one but in the opposite direction (if the first one was Long, open a Short one and viceversa);
- if it didn't: let it run for 60 more seconds and perform the same check;
And so on. Keep it running like this. Once a trade is open, again point 2. . And again and again.
No index or any chart to take into account. I'd like to try it as they ask me to do it (I'm not asking myself if this is a good strategy, I'm just trying to code it).
Below I'm posting the code that I've been able to write so far.
Thank you to anyone who will take part in this.
E.
...
2. After 60 seconds check if this trade has reached TP or SL:
- if it did: close the current trade and open a new one of the same value of the first one but in the opposite direction (if the first one was Long, open a Short one and viceversa);
...
I do not quite understand: we do not care what worked - TP or Sl?
Added: if TP or SL works, it means that the position has already closed - that is, the position is no longer there.
Capturing trading events is very convenient in function OnTradeTransaction.
In OnTradeTransaction, we can determine the deal direction (ENUM_DEAL_ENTRY - we will only be interested in DEAL_ENTRY_OUT) and the deal type (ENUM_DEAL_TYPE - we will only be interested in DEAL_TYPE_BUY and DEAL_TYPE_SELL).
Hi everyone,
this is a brilliant initiative to share ideas, and I'm sure it'll be very helpful to anyone like me who is trying to put together his/her first EA.
The strategy that I'd like (and I'm trying) to translate into code is very simple:
1. Open a trade on a random position (Long or Short);
2. After 60 seconds check if this trade has reached TP or SL:
- if it did: close the current trade and open a new one of the same value of the first one but in the opposite direction (if the first one was Long, open a Short one and viceversa);
- if it didn't: let it run for 60 more seconds and perform the same check;
And so on. Keep it running like this. Once a trade is open, again point 2. . And again and again.
No index or any chart to take into account. I'd like to try it as they ask me to do it (I'm not asking myself if this is a good strategy, I'm just trying to code it).
Below I'm posting the code that I've been able to write so far.
Thank you to anyone who will take part in this.
E.
Here is the preliminary code:
I do not quite understand: we do not care what worked - TP or Sl?
Added: if TP or SL works, it means that the position has already closed - that is, the position is no longer there.
Exactly, either way (TP or SL) just close it and open a new one.
But if you tell me that once I set TP or SL, the buy function automatically closes it, it should open straight away the second trade: same value opposite direction.
Does it make sense? Sorry for not knowing these basic rules, but I'm new to all of this.
Thank you for helping out
Exactly, either way (TP or SL) just close it and open a new one.
But if you tell me that once I set TP or SL, the buy function automatically closes it, it should open straight away the second trade: same value opposite direction.
Does it make sense? Sorry for not knowing these basic rules, but I'm new to all of this.
Thank you for helping out
Then I remove the time interval check (60 seconds)?
Then I remove the time interval check (60 seconds)?
Actually yes. Cause at the 60 sec mark (if it didn't reach tp or sl) it'd keep it alive anyway.
The first version of the code includes the 60 sec check, right?
Actually yes. Cause at the 60 sec mark (if it didn't reach tp or sl) it'd keep it alive anyway.
The first version of the code includes the 60 sec check, right?
Yes, in post #66 code includes the 60 sec check.