in Search

Please help me find a way to fix this code ;)

Last post 07-07-2009, 12:27 by Arash. 2 replies.
Sort Posts: Previous Next
  •  07-07-2009, 2:18 30067

    Please help me find a way to fix this code ;)

    I am trying to write a code to calculate the total up move on a series of back to back up bars (or total down move on a series of back to back down bars...(this is only part of the code because I have to take into consideration the case when ROC(C,1,$)=0 which I have done in part of a code thats not below...)

    A:= BarsSince(ROC(C,1,$)>0);

    B:= BarsSince(ROC(C,1,$)<0);

    If(ROC(C,1,$)<0,

       If(Ref(ROC(C,1,$),-1)>0,ROC(C,1,$), ROC(C,A,$)),

       If(Ref(ROC(C,1,$),-1)<0,ROC(C,1,$),ROC(C,B ,$)))


    but I keep in getting an error that I can only use a constant inside the ROC function.

    In other words if  I have 5 back to back up bars then I would find 5 by
    BarsSince(ROC(C,1,$)<0)-->which should give you 5
    Then I would want to calculate
    ROC(C,BarsSince(ROC(C,1,$)<0,$)
    to find the total up move from the 5th up bar to the very start of the up move of the 5 series up bars. but metastock is not allowing me to put the barssince function inside of Roc or Ref function

    So what do I do? How can I go around this? Any ideas would be very appreciated?

    Thank you
  •  07-07-2009, 7:04 30071 in reply to 30067

    Re: Please help me find a way to fix this code ;)

    Hi Arash,

    Welcome to the Forum.

    As it seems you have most of the code sorted out for what I think you are trying to achieve, I wont distract you with other possibilities, except to suggest you download the free forum.dll from the files section as this contains a variable ROC indicator where the lookback periods does not have to be a static integer value.


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

  •  07-07-2009, 12:27 30075 in reply to 30071

    Re: Please help me find a way to fix this code ;)

    Thank you for your help. Thats exactly what I needed...I guess I was not the only person in need of a variable ROC, LOL

    Thank you!
View as RSS news feed in XML