It is probably best not to assume that OrdersHistory Total-1 is the last closed trade. Check the close time.
Why all the sleeps?
The first 2 minute sleep makes it likely that you will miss the window when Minute equals 0
if (OrdersTotal()==0 && Minute()==00) { OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS); if (OrderProfit()>0 && OrderType()==OP_BUY) { OrderSend(Symbol(),OP_BUY,0.01,MarketInfo(Symbol(),MODE_ASK),2,Bid-SL*Point,Bid+TP*Point,"buy",MagicNumber_101,0,CLR_NONE); } Sleep(120000); }
If minute equals 0 for the first if and conditions are not satisfied, the 2 minute sleep will guarantee that minute will not equal 0 for the following 3 "ifs"
jimbofx7:
Have a loop to count open positions and have your condition to be done next there. Can be done quite easy.
I just want to avoid more than one open position and had bad experience without sleep-function.
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
Hi all,
I try to code an EA that handle with d'alembert progression (for all that don´t know progression d'alembert: http://www.bettingexpert.com/casino/roulette/strategy/d%E2%80%99alembert-system )
The plan is to start with 0.01 lots and SL 13 pips / TP 14 pips.
Each time a trade close with a loss, a new trade open immediately with additional 0.01 lots and after a win trade next trade open immediately with 0.01 lots less than the lotsize before until we arrive at 0.01 lots.
Example:
1. trade 0.01 lots loss
2. trade 0.02 lots loss
3. trade 0.03 lots loss
4. trade 0.04 lots loss
5. trade 0.05 lots win
6. trade 0.04 lots win
7. trade 0.03 lots win
8. trade 0.02 lots win
9. trade 0.01 lots win
So here is my first code try but it doesn´t work in the startegy tester. :-(
Who can help?
Please no comments like "Blow your account away...blabla"
Just sharing a trading strategy.
Regards.