in Search

Problem with barssince() and valuewhen()

Last post 02-13-2009, 7:26 by FoxerFX. 2 replies.
Sort Posts: Previous Next
  •  02-13-2009, 2:46 28889

    Problem with barssince() and valuewhen()

    Guys, please help to solve the following problem:

    if today for example mov(close,10,S)>mov(close,15,S) then

    barssince(mov(close,10,S)>mov(close,15,S)) will return 0 as distance in bars to last occurence of such event when it was true, but how can I get distance in bars to previous occurence of the event mov(close,10,S)>mov(close,15,S) before today?

    Thanks

  •  02-13-2009, 3:17 28892 in reply to 28889

    Re: Problem with barssince() and valuewhen()

    Hi Foxer,

    Welcome to the forum.

    Have a read of the MS User Manual, then attempt all of the programming exercises in the free Equis Formula Primer (available for free download from the files section of the forum).   These will give you the programming skills you need to be able to perform these programming tasks for yourself.  Also, have a good peruse through the forum as it already contains many questions just like yours which have been answered; sometimes there are many different ways to achieve an objective and the knowledgable forum members have shown these so you can choose a method which best suits you.

    I don't quite understand what it is you're looking for, so this code might be not the exact answer to your problem, but I do hope it gives you some inspiration to try some different approaches.


    event:=Mov(CLOSE,10,S)>Mov(CLOSE,15,S);
    counter:=BarsSince(event);
    If(event,Ref(counter,-1)+1,counter)


    Are you sure you're looking for the "greater than " event and not a "crossing" event?


    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 & MDK
    For custom MetaStock programming : http://www.wabbit.com.au
    My SkyPE status :
    My SkyPE account : wabbit.com.au

  •  02-13-2009, 7:26 28899 in reply to 28892

    Re: Problem with barssince() and valuewhen()

    Hi Wabbit,

     

    Thank you for your help and suggestions, I will try suggested by you approach.

    Concerning your question about  "greater than " event or "crossing" event, it does not matter for my case, I have used greater than for example. The  main question for me is a method to get distance in bars to previous occurence of the event which is true today.

    Thanks & Best regards,

    FoxerFX 

View as RSS news feed in XML