Candlestick functions

I have been writing some candlestick functions, starting with some basics, more to come.

function openPosition(position):
openPosition = position + 1
openPosition

function greenCandle(position):
openPosition = position + 1
true if close[position]>open[openPosition] else false

function redCandle (position):
openPosition = position + 1
true if open[openPosition]>close[position] else false

function bodyRange(position):
openPosition = position + 1
bodyRange = open[openPosition]-close[position] if redCandle(position: position) else close[position]-open[openPosition]
bodyRange

function wickRange(position):
wickRange = high[position] - low[position]
wickRange

#long candle if body is 60% of wicks
function largeBody(position):
true if bodyRange(position: position)*100 /wickRange(position: position) >= 60 else false

#body is less than 1/3 of candle
function shortBody(position):
true if wickRange(position: position) > 3*bodyRange(position: position) else false

function longGreenCandle(position):
true if greenCandle(position: position) and largeBody(position: position) else false

function shortGreen(position):
true if greenCandle(position: position) and shortBody(position: position) else false

function longRed(position):
true if redCandle(position: position) and shortBody(position: position) else false

#difference in price open and close price is less than 0.05%(for stocks) try 0.02%( for forex)
function doji(position):
openPosition = position + 1
true if bodyRange(position: position) <= open[openPosition]*0.00005 else false

2 Likes

thats brill, let us know how it goes, it dose sound promising though!