Trying to figure this out has got my brain in a bundle, lol, so my thinking would be to pull the trade information for the last 4 trades made and IF all of them resulted in loss, then SLEEP until the month = (currentmonth) + 1, would this work and anyone want to possibly offer a good structured code instead of my sloppiness? =D
- Stop trading after losses
- Trading with many multiple EAs
- Need help with coding
Here is the code so far, I'm trying to find a good way to calculate the time to sleep until end of month though:
int LosCount=0; // ,ProfCout=0; int OrdHistory=OrdersHistoryTotal(); if(OrdHistory>0 && OrderSymbol()==Symbol()) { for(int cntl=MaxLosses;cntl>=1;cntl--) { if(OrderSelect(OrdHistory-cntl,SELECT_BY_POS,MODE_HISTORY) && OrderProfit()>=0)LosCount=0;//ProfCout++; if(OrderSelect(OrdHistory-cntl,SELECT_BY_POS,MODE_HISTORY) && OrderProfit()<0)LosCount++; } } //Comment(LosCount); // check counter in live if(LosCount > MaxLosses) { Sleep(); }
if(OrdHistory>0 && OrderSymbol()==Symbol())
You have not selected an order yet so OrderSymbol() could be anything.
I your loop, you are assuming that the history is in a certain order. Also you are assuming that they are of the correct symbol
remix919: I'm trying to find a good way to calculate the time to sleep until end of month though:
Don't sleep, just ignore ticks | void OnTick(){ static int ignoreMonth = 0; if(Month() == ignoreMonth) return; ignoreMonth = 0; // Clear for next year. : if(condition){ ignoreMonth = Month(); return; } // Stop trading |
Slight issue with that code, or perhaps rather my original code. The problem is once next month hits, then it re-calculates how many trades lost in a row, but it still shows the same 4 from last month so it just doesn't trade at all =\ any ideas?
Fix your code. If the trades are not the current month/current year, why are you counting them?
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