in Search

Avoid recalculation of indicators

Last post 11-10-2008, 0:03 by mkine. 4 replies.
Sort Posts: Previous Next
  •  10-29-2008, 0:58 28100

    Avoid recalculation of indicators

    I'm new for MSX programming and have no idea on the following issue, hope someone can help:
     
    I wanted to write 2 indicators, named A and B, while both these indicators need to refer to another 2 indicators Y and Z 
     
    For example:
    (assume all are written using VC6 and included in the same DLL)
    Y is 10 days moving average, Z is RSI
    A is having close lower than 10 MA + RSI above 70 + current bar is a black candle then return true
    B return true when a Bearish MACD Crossover happen above 10 MA and with RSI below 30
     
    When i call A and B in Metastock, is that possible for me to reuse the data array calculated in Y and Z in order to avoid any reculcalation?
     
    Appreciated for the help in advance. Thx.
     
    MK
  •  10-29-2008, 1:53 28101 in reply to 28100

    Re: Avoid recalculation of indicators

    MK,

    It sounds like you are trying to do something very obscure??  Anyway....

    If my understanding is correct, then if you pass the output of the first calls to the .dll as arguments to the subsequent calls, there wont be any recomputation:
    Code:

    myMov:=extfml("mydll.myMovingAverage",CLOSE,10); {Y}
    myRSI:=extfml("mydll.myRSI",CLOSE,14); {Z}

    conditionA:=extfml("mydll.myConditionA",myMov, myRSI); {pass the previous results as arguments}
    conditionB:=extfml("mydll.myConditionB",MACD(), myMov, myRSI); {pass the previous results as arguments}

    {plot}
    myMov; {this has already been calculated and wont be done again}

    or something along those lines...

    All of what you are attempting is more easily done in the native MSFL, but you might be using it as a learning exercise?

    Hope this helps.


    wabbit Big Smile [:D]


    "The question of whether a computer can think is no more interesting than the question of whether a submarine can swim."
    Edsgar W. Dijkstra

     

    MS: 6.52 EOD, 7.x EOD, 8.0 PRO, 9.2 PRO w/QC, 10 PRO w/QC C, 11 PRO w/QC & MDK
    For custom MetaStock programming : http://www.wabbit.com.au
    My SkyPE status :
    My SkyPE account : wabbit.com.au

  •  10-31-2008, 9:25 28113 in reply to 28101

    Re: Avoid recalculation of indicators

    Many thanks wabbit, but is that possible i can use some variable (e.g. static) / function to avoid passing the calculated value to and from Metastock?
     
    Is that you mean the MSFL will be the solution? Appreciated if you can give me more information on this.
     
    Thanks again.
     
    MK
  •  10-31-2008, 18:52 28115 in reply to 28100

    Re: Avoid recalculation of indicators

    mkine:
    Y is 10 days moving average, Z is RSI
    A is having close lower than 10 MA + RSI above 70 + current bar is a black candle then return true
    B return true when a Bearish MACD Crossover happen above 10 MA and with RSI below 30


    Something like this?

    Code:

    Y:=mov(CLOSE,10,e);
    Z:=RSI(CLOSE,14);

    A:=CLOSE<Y and Z>70 and black();
    B:={provide more definition here for bearish MACD cross above 10MA} and Z<30;

    {return}
    A;
    B;


    I don't think there is any need for MSX programming here?  If you want to use MSX, then just do the whole computation in one function:

    extfml("mydll.myfunction"); {no arguments}

    in the MSX: compute the MA, RSI, Black() and MACD, and do all the comparisons required to return one value.  Otherwise, if you need to "remember" previous value for the current chart, you will need some structure that will contain all the information to identify THIS chart and its timeframe, and store all the relevant deatils; you might save a millisecond on computation(?) but it is going to cost memory, and depending on the speed of your RAM this may be slower than the CPU calculation?



    wabbit Big Smile [:D]


    "The question of whether a computer can think is no more interesting than the question of whether a submarine can swim."
    Edsgar W. Dijkstra

     

    MS: 6.52 EOD, 7.x EOD, 8.0 PRO, 9.2 PRO w/QC, 10 PRO w/QC C, 11 PRO w/QC & MDK
    For custom MetaStock programming : http://www.wabbit.com.au
    My SkyPE status :
    My SkyPE account : wabbit.com.au

  •  11-10-2008, 0:03 28165 in reply to 28115

    Re: Avoid recalculation of indicators

    many thanks wabbit
View as RSS news feed in XML