Help with a Price/Volume Study

P

PocketsofTime

New member
I'm new here and have done some basic think script coding but nothing to this extent and this is just a bit (read A LOT) over my head.

I am looking to write a study that works in any time frame (if one has to be chosen - 2M) and will put an arrow under a green candle (when it closes) if it exceeds the height of the previous red candle (no matter how far back it is) and the green candle has a volume higher than the previous volume bar.

Would also like to include the premarket and aftermarket but not essential and repaint.

Hope this is clear and thanks for any help you can provide.
 
inthefutures

inthefutures

Active member
(no matter how far back it is) What this this part mean?
 
P

PocketsofTime

New member
Need to compare to the last negative price bar - whether it is the previous one or 3,4,5 etc. bars back.
 
M

mashume

Active member
VIP
Perhaps something like this:
Code:
declare upper;

def red_height = if close[1] < open[1]
                then (high[1] - low[1])
                else red_height[1];
def volume_signal = if VOLUME > VOLUME[1] then 1 else double.nan;

plot GO = if (high - low) > red_height and close > open and volume_signal == 1 then low else double.nan;

GO.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
Happy Trading,
Mashume
 
P

PocketsofTime

New member
Mashume,

Thank you.

It seems to work perfectly, just one thing I did not think of in the beginning, eliminating the wicks of the green bar, just measuring the body.

Trying to learn so here is what I tried:

plot GO = if BodyHeight () > red_height and close > open and volume_signal == 1 then low else double.nan

I assume this will measure the body height of the current candle but not sure if this is right because how does it know if it was green.
 
M

mashume

Active member
VIP
Code:
declare upper;

def red_height = if close[1] < open[1]
                then (high[1] - low[1])
                else red_height[1];
                
def green_body = if close > open then close - open else 0;

def volume_signal = if VOLUME > VOLUME[1] then 1 else double.nan;

plot GO = if green_body > red_height and close > open and volume_signal == 1 then low else double.nan;

GO.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
Maybe.
 

Similar threads

Top