[amibroker] Multiplexor2 function for optimizer

 

Just to give thanks for your awesome help I wanted to share my humble Multiplexor2 code. Most already know that it comes from computer chip/electronic engineering and is a little box (chip) many possible operations selcted using a selector value. Here we combine a few Multiplexors so Instead of using typical EMA crossovers with some RSI confirmation (or whatever, it is just an example). We let the optimizer choose very particular logical organizations that are not easy to design initially.



function MUX2(a,b,S)
{
    result= iif(S==1,a AND b, IIf( S==2, a AND NOT b , IIf(S==3,NOT a AND b, IIf(S==4,a OR b, IIf(S==5,a OR NOT b, IIf(S==6,NOT a OR b,IIf(S==7,NOT a AND NOT b,NOT a OR NOT b)))) )));
    return result;

}

OptimizerSetEngine("cmae");

selector1=Optimize("selector1",1,1,8,1);
selector2=Optimize("selector2",1,1,8,1);
selector3=Optimize("selector3",1,1,8,1);

condition1=RSI(14)>70;
condition2=RSI(14)<30;
condition3=EMA(C,23)>EMA(C,34);
condition4=EMA(C,45)<EMA(C,56);

/*this could be converted into a multiplexor of 4 entries aswell*/
sig=Mux2(Mux2(condition1,condition2, selector1), Mux2(condition1,condition2,selector2),selector3);

Buy =sig;
Sell=NOT sig;


/*After optimizing for some time we find that for Instruement whatever he did choose Selector1=6, Selector2=7 and Selector3=2
that probably is something that is not normally designed */

/*Of course once you have found an interesting logical approach you can simply remove the multiplexor and use the logical conditions for clarity, but the idea is that the Mux selector mixing can find interesting designs*/

__._,_.___

Posted by: dpellon@gmail.com
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (1)
**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/


.

__,_._,___


EmoticonEmoticon