Check - what have I done wrong? - page 7

 
Natalya Smirnova #:

Please advise how to write it nicely. So as not to duplicate code arrays.
The Expert Advisor uses 2 indicators.
and conditions for order opening look like this now:


But I would like to add filter
Use or not use 1 or 2 indicators
Only I don't know how to implement it more correctly.
It would look like this:

That I can disable 1 indicator or a second indicator in the settings.
Can't figure out how to do it without copying a lot of code.....


extern bool ind1=true;
extern bool ind2=true;

void OnTick(){

        bool buy1=true;
        bool sell=true;
        if(ind1){
                buy1=...
                sell2=...
        }

        bool buy1=true;
        bool sell=true;
        if(ind2){
                buy2=...
                sell2=...
        }       


        bool buy=buy1&&buy2;
        bool sell=sell1&&sell2;
}

One disadvantage - if all indicators are disabled, the signals always exist. If it is important, you can make check in inite and prohibit start of expert. But more often there is one indicator that is not disabled, so there are no problems.

 
Dmitry Fedoseev #:


One disadvantage - if all indicators are disabled, there are always signals. If it is important, you can do a check in the inite and disable the EA. But more often there is one indicator that is not disabled, so there are no problems.


It is solved by initialisation of variables buy1, sell1, buy2, sell2

extern bool ind1 = true;
extern bool ind2 = true;

void OnTick() {

        bool buy1 = ind1 || ind2;
        bool sell1 = ind1 || ind2;
        if( ind1 ) {
                buy1 = ...
                sell2 = ...
        }

        bool buy2 = ind1 || ind2;
        bool sell2 = ind1 || ind2;
        if( ind2 ) {
                buy2 = ...
                sell2 = ...
        }       


        bool buy = buy1 && buy2;
        bool sell = sell1 && sell2;
}
 

This is all a kind of eloquence.

First you have to have a successful trading system, and then, if you don't have anything to do, you can make it nice and tidy ... if you want to...

How many attempts will be made - thousands, tens of thousands, as luck would have it...

But it is far from certain that it will happen.

That is why "nice" brain load at the initial stage of developing a trading system is of no use at all.

And eloquent comments, without any successful trading, on the subject of "do as I do" or "look how I can program" are nothing more than flirting that has absolutely no value in the financial market.

;)

Reason: