in Search

moving avarages help

Last post 09-21-2006, 23:48 by sharezack. 7 replies.
Sort Posts: Previous Next
  •  09-19-2006, 23:34 20984

    moving avarages help

    Hi

    I am in the process of learning the metastock and i have written an exploration to find out the simple moving avarages of 3,9,12,20,50 and 200 Days the code is some what like this.

    Col A   Mov(CLOSE, 3, S)

    Col B   Mov(CLOSE, 9, S)

    Col C   Mov(CLOSE, 12, S)

    Col D   Mov(CLOSE, 20, S)

    Col E   Mov(CLOSE, 50, S)

    Col F   Mov(CLOSE, 200, S)

    Filter : colA or colB or colC or colD or colE or colF

    The problem is some of the securities might have been new listing and do not have traded for more than a week or more than a month or more than 6 months and hence they might not fulfill the critieria of calculating the specified moving avarage period for example if IBM was listed only 10days back it can calculate 3 and 9 day moving avarage but for rest it will fail. In my code securities which are not matching all the critieria are not being calculated.

    what i want is if the security fulfills colA critieria and fails to fullfill the rest of the colums even then i  should get the results for col A and for rest of the colums i should get 0 value. for exampls

    IMB listed 5 days back

    3Day   9Day   12Day   20Day   50Day   200Day

    20         0         0         0            0            0

    This is how it has to display instead of getting rejected in the computation. i tried to look at the filter command but not able to get the answer for this can some one help what i should be doing.

     

  •  09-20-2006, 4:12 20988 in reply to 20984

    Re: moving avarages help

    to fine tune my query if the stock fulfills even one criteria also this has to be displayed. what should be the filter for this
  •  09-20-2006, 6:28 20990 in reply to 20988

    Re: moving avarages help

    sharezak,

    Again this is a simple query that will be answered by reading the MS Users Manual and completing the Equis Formula Primer.  We understand that you are rushed to have your website completed, but I fail to see why we should be rushing to complete your coding projects for you.  If you needed to have your website up and running by a particular date then you should have started earlier; if the time is not an issue then why should we rush to build your code for you?  Take the time to learn to do it for yourself.

    Time management' is really a misnomer - the challenge is not to manage time, but to manage ourselves.


    The best way to get something done is to begin.



    In relation to your explorations:

    You do not need a filter criteria.  Leave the filter empty and every stock will be returned with values in Columns A to E.

    As for the moving averages, the short answer is you cannot replace on Undefined() data array with another array.  The IsDefined() and IsUndefined() functions were poorly implemented and are next to useless.  The only solution is to write another MS add-in that will accept to arguments, returning one array if the other is undefined.  I have one for personal use.


    wabbit Big Smile [:D]




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

  •  09-20-2006, 6:58 20993 in reply to 20990

    Re: moving avarages help

    hi wabbit

    see i have left the filter command empty and ran the exploration but some of the stocks were getting rejected like this. If you see ABAN it is fulfilling upto to colum E since the data range is not available for more than 50days it is getting discarded. where as i want the exploration to list upto column D as it fulfills the critieria and then for column E and F let it show what ever default it can show

    Security Name Reason for Rejection Location 
    ABAN OFFSHORE LTD. Error in column E: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    ADHUNIK METALIKS Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    AIA ENGINEERING Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    DECCAN AVIATION Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    ALLCARGO GLOBAL LOGISTICS Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    BAL PHARMA Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    BANK Nifty Error in column E: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    BARTRONICS Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    BL KASHYAP & SONS Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    BOMBAY RAYON FASHIONS Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    BENCHMARK SPLIT CAP FUND - BAL -  CLASS B Error in column B: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    CELEBRITY FASHIONS Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    CENTURY PLYBOARDS (I) Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    CHEMFAB ALKALIES Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    CNX 100 Error in column E: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    CNX IT Error in column E: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    CNX Midcap Error in column E: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    CNX Nifty Junior Error in column E: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    COMPULINK SYSTEMS Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    EDUCOMP SOLUTIONS Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    EVEREST KANTO CYLINDER Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    EMAMI LIMITED Error in column E: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    EMKAY SHARE & STOCK BROKERS Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    ENTERTAINMENT NETWORK Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    ERA CONSTRUCTIONS (I) Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    GALLANTT METAL Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    GITANJALI GEMS Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    GMR INFRASTRUCTURE LTD. Error in column E: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    GODAWARI POWER & ISPAT Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    GUJRAT STATE PETRONET Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    GTN TEXTILES Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    GVK POWER & INFRASTRUCTURE Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    INDO TECH TRANSFORMERS Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    INOX LEISURE Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    JAGRAN PRAKASHAN Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    JK CEMENT Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    KIRLOSKAR BROTHERS Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    KEC INTERNATIONAL Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    KEI INDUSTRIES Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    KERNEX MICROSYSTEMS Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    KAMDHENU ISPAT Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    KEWAL KIRAN CLOTHING Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    KOHINOOR FOODS LIMITED Error in column E: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    LOKESH MACHINES Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    MAHINDRA & MAHINDRA FINANCIAL SERVICES Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    MALU PAPER MILLS Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    MAWANA SUGARS LIMITED Error in column E: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    NANDAN EXIM Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    NAVA BHARAT VENTURES LIMI Error in column E: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    NITCO TILES Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    NITIN SPINNERS Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    NUMERIC POWER SYSTEMS Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    ORIENT ABRASIVES Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    PRIME FOCUS Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    PIONEER EMBROIDERIES Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    PIRAMYD RETAIL Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    PLETHICO PHARMACEUTICALS Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    PRATIBHA INDS Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    PUNJ LLOYD Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    PVR LTD Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    RR MOHOTA SPINNI Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    RATNAMANI METALS & TUBES Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    RELIANCE CAPITAL VENTURES Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    RELIANCE COMMUNICATIONS Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    RELIANCE ENERGY VENTURES Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    REPRO INDIA Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    RELIANCE NATURAL RESOURCES Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    ROHIT FERRO-TECH Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    ROYAL ORCHID HOTELS Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    RELIANCE PETROLEUM Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    R SYSTEMS INTL Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    S&P CNX 500 Error in column E: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    S&P CNX Defty Error in column E: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    S&P CNX Nifty Error in column E: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    SADBHAV ENGINEERING Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    SAKUMA EXPORTS Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    SANWARIA AGRO OILS Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    SHIVALIK GLOBAL Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    SIMBHOLI SUGAR Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    SOLAR EXPLOSIVES Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    SUNIL HITECH ENGINEERS Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    SUN TV Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    SURYAJYOTI SPINNING MILLS Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    TECH MAHINDRA LIMITED Error in column D: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    TULIP IT SERVICES Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    UNITY INFRAPROJECTS Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    UTTAM SUGAR MILLS Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    VAKRANGEE SOFTWARE Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    VIMTA LABS Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    VISA STEEL Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    WENDT (INDIA) LIMITED Error in column E: Period value out of valid range in Mov() function. D:\metadata\NSE2005 
    ZICOM ELECTRONIC SECURITY SYSTEMS Error in column F: Period value out of valid range in Mov() function. D:\metadata\NSE2005 

     

  •  09-20-2006, 7:13 20994 in reply to 20990

    Re: moving avarages help

    Wabbit buddy

    This would be last help i would require, i am really running short of time i would really be thankfull if you can give me the code. I promise there will be no more postings for code with out reading. even if i post you all can ignore it. request you to get me out of this fix and help me with the code for solving this problem

  •  09-20-2006, 8:14 20995 in reply to 20993

    Re: moving avarages help

    hi wabbit

    whats wromg with this code If(IsUndefined(Mov(C,200,S))=>1,0,Mov(CLOSE, 200,S))

    what i am trying to check is if all data necessary to calculate is available then it returns 0 which is less than 1 so it has to plot the moving avarage else if it is 1 then plot 0.

     

  •  09-20-2006, 18:39 21013 in reply to 20990

    Re: moving avarages help

    wabbit:
    As for the moving averages, the short answer is you cannot replace an Undefined() data array with another array.  The IsDefined() and IsUndefined() functions were poorly implemented and are next to useless.  The only solution is to write another MS add-in that will accept two arguments, returning one array if the other is undefined.  I have one for personal use.


    As much as the logic you used it is correct, you have still been Kyboshed by the implementaton of the functions in MS.

    You (like all of us) might think that

    If(IsUndefined(someDataArray)=False, thenUseSomeOtherDataArray, elseUseTheOriginalDataArray)

    or

    If(isDefined(someDataArray)=True,thenUseTheDataArray,elseUseAnotherDataArray)

    would work, but, it doesn't.

    Beacuse all the functions in MS are FULLY evaluated, MS sees a function which returns NA and therefore returns NA for that variable.

    There is no way around it in MS as it stands at the moment, you need to do the defined/undefined comparison externally and return the appropriate data array from outside of MS.  This requires an add-in .dll file.


    wabbit Big Smile [:D]



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

  •  09-21-2006, 23:48 21062 in reply to 21013

    Re: moving avarages help

    hi

    Here is the perfect solution for the query i had posted this gives the same results and also for the period where data is not there it gives me zero instead of rejecting in the filter.

    Col A:

    M:=Mov(C,LastValue(Min(3,Cum(1))),S);

    If(Cum(1)<3,0,M);

     

    Col B:

    M:=Mov(C,LastValue(Min(9,Cum(1))),S);

    If(Cum(1)<9,0,M);

     

    Col C:

    M:=Mov(C,LastValue(Min(12,Cum(1))),S);

    If(Cum(1)<12,0,M);

     

    Col D:

    M:=Mov(C,LastValue(Min(20,Cum(1))),S);

    If(Cum(1)<20,0,M);

     

    Col E:

    M:=Mov(C,LastValue(Min(50,Cum(1))),S);

    If(Cum(1)<50,0,M);

     

    Col F:

    M:=Mov(C,LastValue(Min(200,Cum(1))),S);

    If(Cum(1)<200,0,M);

      

    Filter enabled Yes

    Periodicity Daily

    Records required 250

     

View as RSS news feed in XML