Assistance with a script

Optuma Forums Optuma Scripting Assistance with a script

This topic contains 3 replies, has 3 voices, and was last updated by Avatar Karen 3 months, 2 weeks ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #54107
    Avatar
    Karen
    • Topics: 9
    • Replies: 18
    • Posts: 27

    The below script isn’t working for me and I cannot work out why after hours of trying. Can someone please assist. Thanks.

    // Selling volume shown with red Divisor =5;

    Mid= (High()+Low())/2;

    High1= HIGH(OFFSET=1);

    Low1= LOW(OFFSET=1);

    Mid1= (High1-Low1)/2;

    V1 = Mid1 + (High1-Low1)/5;

    V2 = Mid1 – (High1-Low1)/5;

    VolumeA = MA(VOL(), BARS= 50, STYLE=Simple);

    Range = HIGH() – LOW();

    RangeAvg= MA(Range, BARS= 50, STYLE=Simple);

     

    //Red color volume bar

    RedEnabled1 = (Range > RangeAvg) and (Close() < V2);

    RedEnabled2 = Close() < Mid1;

    if((RedEnabled1) or (RedEnabled2),1,0)

    #54109
    Darren
    Darren
    • Topics: 43
    • Replies: 299
    • Posts: 342

    Hi Karen

    I think the Mid1 variable should be  (High1+Low1)/2, not minus.

    Also, the last line can just be RedEbabled1 or RedEnabled2 – no need for the ‘If’ statement.

    #54111
    Avatar
    Trevor R
    • Topics: 56
    • Replies: 178
    • Posts: 234

    Hi Karen,

    Your problem lies in the relationships between the values you are comparing. I’ve rearranged your script a little to make it easier for me to follow when trying to analyse what is going on and I’ve commented out lines that are not being used in the SHOWPLOT lines in the following screenshot. The SHOWPLOT lines are:

    • Close(0):   Green
    • V2:    Blue
    • Mid1:   Red
    • Range0:   Orange
    • RangeAvg:   Lime

    20190722 Karen's Script, Ticket #54107

    As you can see from the above screenshot:

    • Close(0) (Green) is never less than V2 (Blue), so “Close(0) < V2” will always result in FALSE (=0)
    • Close(0) (Green) is never less than Mid1 (Red), so “Close(0) < Mid1” will always result in FALSE (=0)
    • Range0 (Orange) oscillates above and below RangeAvg (Lime), so “Range0 > RangeAvg” will offer TRUE (=1) results.

    Given the foregoing results, RedEnabled 1 and RedEnable2 will always return a FALSE result.

    Here is the script as I’ve modified it:

    // Selling volume shown with red Divisor =5

    Mid0= (High(0)+Low(0))/2;

    Range0 = HIGH(0) – LOW(0);

    RangeAvg= MA(Range0, BARS= 50, STYLE=Simple);

    High1= HIGH(1); Low1= LOW(1);

    Mid1= (High1 – Low1)/2;

    //V1 = Mid1 + (High1-Low1)/5;

    V2 = Mid1 – (High1 – Low1)/5;

    //VolumeAvg = MA(VOL(0), BARS= 50, STYLE=Simple);

    //Red color volume bar

    //RedEnabled1 = (Range0 > RangeAvg) and (Close(0) < V2);

    //RedEnabled2 = Close(0) < Mid1;

    //if((RedEnabled1) or (RedEnabled2),1,0);

    //

    Plot1=Close(0);

    Plot1.Colour = Green;

    //

    Plot2 = v2;

    Plot2.Colour = Blue;

    //

    Plot3 = Mid1;

    Plot3.Colour = Red;

    //

    Plot4 = Range0;

    Plot4.Colour = Orange;

    //

    Plot5 = RangeAvg;

    Plot5.Colour = Lime;

    I haven’t really discerned exactly what you are trying to achieve with your script, but I hope this explanation of what is happening within your script and demonstrating a way to show the intermediate results will assist you in achieving your aim.

    Cheers

    Trevor

    The Auld Tyma at

    Auld Tyma Data Logo with URL 1 cm

    #54157
    Avatar
    Karen
    • Topics: 9
    • Replies: 18
    • Posts: 27

    Great thanks for your assistance.

    Kind regards,

    Karen

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

Pin It on Pinterest

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close