# Assistance with a script

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)

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.

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

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