EA N7S_AO_772012 - page 23

 

Now a little bit about the flags that are not included in the FLG function as themselves are independent.

A) Flg is an initialisation flag, it is needed to avoid opening the pose after a failure or start of operation, if there is an input signal (this signal is long-lasting), because it may be too late. The logic is as follows, if VSR!=0 i.e. there is a signal, then set Flg=false; as soon as the signal disappears the flag is reset

if (!Flg){if (VSR () ==0) {Flg=true; return (0);}}

B) Flq - interesting flag, prohibiting to open a second position on the same bar. At first I wanted to prohibit opening of a position at a loss on one bar but I will implement it when I finish with my function BuSll which will make it easy. For now, there is such a variant.

It is set at position opening

{if (Trd_Up_X && VSR() > 0 && bu <HM_Up_X ) {

if (MOS( 0, lots, sl, tp, WindowExpertName(), mn)>=1) {Flq=false;}}

if (Trd_Dn_Y && VSR() < 0 && sll<HM_Dn_Y ) {

if (MOS( 1, lots, sl, tp, WindowExpertName(), mn)>=1) {Flq=false;}}

By the way, I wrote earlier about the fix in this function.

It resets every 4 hours. If you think this is too much for some pairs, you can add to the function H1() reset the flag every hour for all but some pairs if (Symbol()!="GBPJPY" || Symbol()!="USDCHF"){ Flq = true ; }

 
WitoHOH писал(а) >>

Something about the latest version doesn't work.

The optimiser doesn't even open a single trade at the first stage.

The tester with parameters optimised for the previous EA works the same way.

Have you figured out why it is not optimized?

 
SHOOTER777 писал(а) >>

Have you worked out why it didn't optimise?

No.

Didn't have much time.

Last time there was a problem because of the lack of history.

I'm just getting the history back up and running.

I'll let you know in the morning.

 
SHOOTER777 писал(а) >>

Have you figured out why it didn't optimise?

It doesn't want to optimise.

The seventh version is optimised on the same historical data.

The latest one won't.

Everywhere result is 0.

 

Reposted the expert. Probably a corrupted version. Forum was freezing.

And pay attention to these lines in Expert Advisor

initial balance, minimum and maximum, when Expert Advisor is trading.

//------------------------------------------------------------------//
bool TrBlnc = true; int StrtBlnc = 3000; int DBlnc = 1500; int UBlnc = 4000;
//------------------------------------------------------------------//

The ban is implemented in function bool FLG (int cs )

Files:
 

A little more on the logic of the advisor.

There is a problem - frequent gaps. During gaps the optimized parameters and conditions of market entries are unsynchronized, because indicator values and prices become torn. It takes time to recover. For the AO I've defined 12 hours, and I consider a significant gap as a price change by more than 20 standard points (for some pairs there can and should be other values).

Thus, what we have done:

At first we determined if there was a gap

string dttm = StringConcatenate (Year(),".",Month(),".",Day());
datetime smtm=StrToTime(dttm);
bool Gp;
int shft = iBarShift(NULL,0,smtm);
double iOpn = iOpen (NULL,0,shft); double iCls = iClose (NULL,0,shft+1);
double dOC = MathAbs ((iOpn - iCls)/(Point*10)) ;
if (dOC>20) Gp = true ;

If it was and Gp = true, then the condition for the banning is

((DayOfWeek( ) == 1 && Hour( ) <14) && Gp))

Although I have some doubts that the function

iBarShift (NULL,0,smtm);

perhaps it would be better written in the following way

iBarShift (NULL,60,smtm,true); but no, the last default parameter is still false ?

I am waiting for your thoughts and suggestions.

 
SHOOTER777 >> :

Also pay attention to these lines in the EA

initial balance, minimum and maximum, when the EA is trading.

//------------------------------------------------------------------//
bool TrBlnc = true; int StrtBlnc = 3000; int DBlnc = 1500; int UBlnc = 4000;
//------------------------------------------------------------------//

This prohibition is implemented in function bool FLG (int cs )

Why do you need such restrictions?

 
capellini писал(а) >>

Why do you need such restrictions?

If you don't need it, don't use it! I am preparing the EA for real and as a multi-currency EA. In the future, it will be a fork, where the EA will not be allowed to trade from the bottom, so as not to loose everything at a force majeure situation, as well as from above - a bird in the hand is better than a crane))) MM however

 

And now news from the field or from the front))

Last weekend, I did not have time to prepare set files for the L9 version, I finished work on it late plus the holidays))))

Therefore decided to put the experiment. I put the version of L9 with sets from last week and from another version.

What we have at the end of two days: balance -$70 Equity +$420 Good move!

 
SHOOTER777 писал(а) >>

So if you are testing or optimising, ensure that the Equity is within the range set in the parameters

bool TrBlnc = true; int StrtBlnc = 3000; int DBlnc = 1500; int UBlnc = 4000;

or add to int init() line if ( IsOptimization( ) ) TrBlnc = false;//if ( IsTesting() ) TrBlnc = false;

It worked.

The optimization is on.

Perhaps such variables should be moved outside the code?

It would be easier during optimization and in real work, too.

The Expert Advisor will not have to be recompiled every time the balance is changed.