PureBytes Links
Trading Reference Links
|
Dimitri,
I am not the author of the jscript code, But I don't remember who
has written it.
I give it only because I'll try to write it as a plugin dll as an
exercise to write a pattern dll in the next future.
stephane
> Stephane,
> What a nice example. Thank you.
> How about apply it to indicators ?
> A first attempt :
>
> X=StochD();
> L=LLV(X,3);H=HHV(X,5);C=MA(X,3);O=C;
> EnableScript ( "jscript" );
> <%
> Low = VBArray( AFL ("L" ) ).toArray();
> High = VBArray( AFL ("H") ).toArray();
> boxTopArr = new Array(); boxBotArr = new Array();
> stateArr = new Array();
> state = stateArr[0] = 1; boxStart = 0;
> boxTop = High[0]; boxBot = 0; swap=0;
> for (i=1; i<Low.length; i++) {
> if (state==5) {
> if (boxBot>Low[i] || boxTop<High[i]) {
> for (j=boxStart; j<i; j++) {
> boxTopArr[j] = swap ? boxTop : boxBot;
> boxBotArr[j] = swap ? boxBot : boxTop;
> }
> state = 1; swap = !swap;
> boxTop = High[i]; boxStart = i;
> }
> }
> else if (boxTop>High[i]) {
> if ((state<3) || (boxBot<Low[i]) ) state++;
> else state=3;
> if (state==3) boxBot=Low[i];
> }
> else {
> state=1; boxTop=High[i]; }
> stateArr[i] = state;
> }
>
> for (j=boxStart; j<Low.length; j++) {
> boxTopArr[j] = swap ? boxTop : boxBot;
> boxBotArr[j] = swap ? boxBot : boxTop;
> }
>
> AFL.Var("boxTop") = boxTopArr;
> AFL.Var("boxBot") = boxBotArr;
> AFL.Var("state") = stateArr;
> %>
> Plot(C, "", 1, 128);
> // plot(state, "", 2, 1);
> Plot(boxTop, "top", state+1,512);
> Plot(boxBot, "bot", state+1,512);
> Title= "DarvaBox for:"+Name() +" state("+WriteVal(state,1)+")"
> +" Bottom:"+WriteVal(Max(boxTop,boxBot), 1.2)
> +" Top:"+WriteVal(Min(boxBot,boxTop),1.2);
> If you use this technique, what is the trading meaning of "states"
> and the respective colours ?
> Dimitris Tsokakis
>
> --- In amibroker@xxxx, "nenapacwanfr" <nenapacwanfr@xxxx> wrote:
> > yes you can, example;
> >
> > EnableScript ( "jscript" );
> > <%
> > Low = VBArray( AFL ("L" ) ).toArray();
> > High = VBArray( AFL ("H") ).toArray();
> > boxTopArr = new Array(); boxBotArr = new Array();
> > stateArr = new Array();
> > state = stateArr[0] = 1; boxStart = 0;
> > boxTop = High[0]; boxBot = 0; swap=0;
> >
> > for (i=1; i<Low.length; i++) {
> > if (state==5) {
> > if (boxBot>Low[i] || boxTop<High[i]) {
> > for (j=boxStart; j<i; j++) {
> > boxTopArr[j] = swap ? boxTop : boxBot;
> > boxBotArr[j] = swap ? boxBot : boxTop;
> > }
> > state = 1; swap = !swap;
> > boxTop = High[i]; boxStart = i;
> > }
> > }
> > else if (boxTop>High[i]) {
> > if ((state<3) || (boxBot<Low[i]) ) state++;
> > else state=3;
> > if (state==3) boxBot=Low[i];
> > }
> > else {
> > state=1; boxTop=High[i]; }
> > stateArr[i] = state;
> > }
> >
> > for (j=boxStart; j<Low.length; j++) {
> > boxTopArr[j] = swap ? boxTop : boxBot;
> > boxBotArr[j] = swap ? boxBot : boxTop;
> > }
> >
> > AFL.Var("boxTop") = boxTopArr;
> > AFL.Var("boxBot") = boxBotArr;
> > AFL.Var("state") = stateArr;
> > %>
> >
> > Plot(C, "", 1, 128);
> > // plot(state, "", 2, 1);
> > Plot(boxTop, "top", state+1,512);
> > Plot(boxBot, "bot", state+1,512);
> >
> > Title= "DarvaBox for:"+Name() +" state("+WriteVal(state,1)+")"
> > +" Bottom:"+WriteVal(Max(boxTop,boxBot), 1.2)
> > +" Top:"+WriteVal(Min(boxBot,boxTop),1.2);
> >
> > >
> > > Does anyone know if AB allows jscript/vbscript/c++
> > > inside indicator builder? It seems to work only in
> > > Automatic Analysis but not in Indicator builder.
> > >
> > > Thanks.
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Yahoo! Health - your guide to health and wellness
> > > http://health.yahoo.com
|