Download MetaTrader 5
To add comments, please log in or register
Create interesting Forum topics concerning the automated trading!
Luciano Ola
996
Luciano Ola 2014.05.29 22:01 

I was just wondering if it was possible to do so because I have been having trouble with it.

 

Nvm, the problem persists.

Luciano Ola
996
Luciano Ola 2014.05.29 22:19  
Looks like I needed to class a variable as a static one to solve the issue.
Keith Watford
Moderator
7887
Keith Watford 2014.05.29 23:06  

I often use for loops in Init - no problem

Can you give an example of how you are having a problem?

Luciano Ola
996
Luciano Ola 2014.05.30 00:56  
GumRai:

I often use for loops in Init - no problem

Can you give an example of how you are having a problem?


Yes of course, although I've fixed the code, fixing the code was a pain because I lost track of what I was doing when I was fixing a minor issue and that it spiraled out, I'm also in the midst of demo trading so as you can imagine  recompiling had some trading effects.

 

I've been trying to construct some initiation code so that my EA is not too greatly effected if I ever have to restart my computer for software upgrades ect, I've coded my EA so that it has some "learning" functionality, however that learning functionality hinges on past performances.

 

Here is some  code for the most recent losses, I have tried to make it so that it selects the most recent loss of the chart symbol and uses that as part of its assessment for future trading.

This is suppose to be the fix

static int LoopT=1;

for(int slp=OrdersHistoryTotal()-1;slp>=0;slp--)
          {
          if(OrderSelect(slp,SELECT_BY_POS,MODE_HISTORY) && OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
             {
              if(OrderType()==OP_BUY||OrderType()==OP_SELL)
              {
              if(OrderCloseTime()>LoopT){LoopT=OrderCloseTime();}if(OrderCloseTime()==LoopT && OrderProfit()+OrderCommission()+OrderSwap()<0)Stage=2;else Stage=1;
              }
             }
             
          }

 

Stage two is an assessment stage, stage one is regular trading based on past assessment results, I  put the "else stage=1;" in there because I thought that the EA was picking up on losses that were not the most recent as it worked it's way through previously closed trades; the modification seems to have fixed the issue.

I'm not entirely sure where I went wrong because I simply constructed these lines by looking at some of my other lines,  I suppose the "else stage=1;" must have been quite important, I closed quite trades early because of this mess, it's going to effect short term assessments -________- !!

/
To add comments, please log in or register