| / | Forum |
|
sasuke
2006.10.23 21:24
I'm trying to figure out how to get my EA to sleep for X amount of time after it
has made N number of losses and then continue to trade as usual when it wakes up.
Can anyone help me with this coding?
|
|
Video interview with Rashid Umarov The main conclusion is that it is insufficient to have a profitable strategy: it is necessary to strengthen its advantages and smooth its disadvantages. This is the point in money management: You should gain the largest profit from your approach, your Expert Advisor, your system with minimal risk and in maximal amounts, without being short of it. This is the most important thing, to my mind. |
|
oldman
2006.10.25 09:17
I would count each time it closed for a loss, put that in a global variable, check
that variable each tic and sleep(x) when var reaches your max losses..
You may have to run through your history to find the closed orders and see what profit they made, Set your terminal history for "last three days" (shouldn't use "today" ,.... might roll over and miss one) You might want to play with this to insure your trades are not gone from history before your max losses occur... ie, you lost one tuesday, one wednesday and one saturday... if you had last three days history only, then you would only retrieve one trade... for instance (and i am rough in this, bare with me) int losses,maxlosses,h,history; int x =milliseconds to sleep; int init() { history=HistoryTotal(); GlobalVariableSet("history",history); //// we reset these each time we start the ea. GlobalVariableSet("losses",0); //// We now know how many we have in history presently } init start() { h=HistoryTotal(); history=GlobalVariableGet("history",history); // we need to get this each tic if(h>history) { ///// we have a new addition to history, lets check if a loss. .... GlobalVariableGet("losses", losses); OrderSelect(h-1, SELECT_BY_POS, MODE_HISTORY); if(OrderProfit() < 0) { losses++; GlobalVariableSet("losses", losses); if(losses>maxlosses) { GlobalVariableSet("losses", 0); /// we found the number we were looking for so we reset this ///for next time sleep(x); } } GlobalVariableSet("history",h); /// reset the history to current trades when it wakes up. } } //// end of this little messed up script. I would not use it until someone a little more knowledgeable in this remarks on it... shouldn't be too long. |
|
sasuke
2006.10.25 19:53
oldman, Thanks for your help. I'll be waiting to see what others have to suggest.
|
|
oldman
2006.10.25 23:28
It appears from trial and error that historytotal() -1 is the last order closed.
. for some reason.
I modified the script above to reflect that. |
|
asmocon
2006.10.31 00:10
Hopefully this might be something useful. I know that you are wanting it to wait
for so long after "multiple losses," but the way we do it is to have
it wait after a single loss. And the wait time can easily be optimized because
it is based on the candles drawn. |