Valuewhen()

Optuma Forums Optuma Scripting Valuewhen()

  • This topic has 2 replies, 2 voices, and was last updated 4 months ago by AvatarMay.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #61801
    AvatarMay
    • Topics: 14
    • Replies: 18
    • Posts: 32

    Hi, I want to know the RSI value at the Swing end by using VALUEWHEN() function.  I expect the current RSI value is 52.19 but somehow it is not as attached. Just want to know which part of the script goes wrong:

    https://learn.optuma.com/course/advanced-scripting/?course_type=content&course_page=1&lecture=11
    https://help.optuma.com/kb/faq.php?id=1048

    //Gann Swings
    //Current Swing
    S0 = SWINGEND(GANNSWING(SWINGCOUNT=2, DEFAULT=SwingList, METHOD=Use Next Bar));

    //Corresponding RSI value of the Swings
    R0 = VALUEWHEN(RSI(BARS=14),S0);

    R0

    Attachments:
    #61827
    MathewMathew
    • Topics: 36
    • Replies: 1,806
    • Posts: 1,842

    Hi May,

    Have a look at this article on using swing charts in scripting https://www.optuma.com/swing-scripting-1/

    The issue is that SwingEnd() returns a swing list which does not line up with day by day bars. What you want to use is the following:

    Hope that helps

    Mathew

    #61829
    AvatarMay
    • Topics: 14
    • Replies: 18
    • Posts: 32

    Thanks Mathew!  It works fine on current swing.

    As I want to compare the corresponding RSI values at previous swing ends, I used the scripts below but did not work out (As attached, value of R1 in lower panel is the same as R0 in upper one somehow).

    I believe I should use the dot notation as recommended in the article for both current scanning and backtesting purposes.

    //Gann Swings
    //Current Swing
    S0 = SWINGEND(GANNSWING(SWINGCOUNT=2, DEFAULT=SwingList, METHOD=Use Next Bar));

    //Previous Swings
    S1 = OFFSET(S0, OFFSET=1);
    S2 = OFFSET(S0, OFFSET=2);

    //Swing Ends
    SE0 = S0.SWINGEND();
    SE1 = S1.SWINGEND();

    //Corresponding RSI value of the Swings
    R0 = VALUEWHEN(RSI(BARS=14),SE0);
    R1 = VALUEWHEN(RSI(BARS=14),SE1);

    R1

    Attachments:
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Pin It on Pinterest