EA based on multiple indicators

To add comments, please log in or register
Mark
249
Mark  

I'm writing an EA that's based on several indicators, now am I best writing it like this


if(IndicatorA>=x && indicatorB=y && indicatorC<=z)

{

OrderSend(Symbol(),OP_BUY,Lots,Ask,Slip,Ask-SL,Ask+TP,NULL,16180,0,Green)

}


Or the other way I though was


int BuySignal=0;


if(ImdicatorA>=x)

{

BuySignal=BuySignal+1

}

if(ImdicatorB=y)

{

BuySignal=BuySignal+1

}

if(ImdicatorC<=z)

{

BuySignal=BuySignal+1

}

If(BuySignal=3)

{

OrderSend(Symbol(),OP_BUY,Lots,Ask,Slip,Ask-SL,Ask+TP,NULL,16180,0,Green)

}


Obviously having different combinations of indicators and settings for buy, sell and close/modify orders. I've got a working version based on the first idea, which either trades far too often or not at all, but I'm thinking the second idea would allow me more control over when I trade and with what Lot size to choose. Has anyone designed a working EA that uses multiple indicators and if so what way is best? Or are there more efficient methods?

blogzr3
505
blogzr3  
if(IndicatorA>=x && indicatorB=y && indicatorC<=z)

Evaluate subsequent indicators only if the one before is satisfied. That way you avoid unnecessary computations and EAs that gobbles CPU.


if(IndicatorA()>=x)

if (indicatorB()=y)

if (indicatorC()<=z)


Use functions which only get evaluated if they get to that point, rather than variables which are precomputed whether they are required or not.


For the buy signals, try something like this the following. Use parameters which you can vary during testing to find the optimum. You may find that some indicators carry more weight. And depending on what the total weighting is, you may want to vary the lots. Again the thresholds are parameters you can test to find the optimum.

if(ImdicatorA>=x)

{

BuySignal=BuySignal+Weighting1

}

if(ImdicatorB=y)

{

BuySignal=BuySignal+Weighting2

}

if(ImdicatorC<=z)

{

BuySignal=BuySignal+Weighting3

}

If(BuySignal>ThresholdBig) ... // buy big lots

else If(BuySignal>ThresholdMedium) ...//buy medium lots

else If(BuySignal>ThresholdSmall) ...//buy small lots


Mark
249
Mark  
Thanks for the advice, have started to implement it now with promising results, computation time is down a lot and im hitting more profitable trades, just need to tweak some of the weightings so it picks up more trades.
To add comments, please log in or register