Darvas box theory is a trading strategy developed by Nicolas Darvas to target stocks using highs and volume as key indicators. Darvas developed his theory in the 1950s while travelling the world as a professional ballroom dancer. Darvas’ trading technique involves buying into stocks that are trading at new highs and drawing a box around the recent highs and lows to establish entry point and placement of the stop-loss order.
I was looking for Darvas’ box indicator, I managed to find the forum on the site with code exchanges for it.Not having found a provision in the library, I saw fit to share this code.
Thank you to “zen83” for its sharing
Here is the link to the discussions: https://www.prorealcode.com/topic/darvas-boxes-help/
//
//============================== Indicateur
if box=1 and (high>DownBoxe or low<UpBoxe) then
box=0
flag=0
endif
if box=0 and flag=0 and low>low[3] and low[1]>low[3] and low[2]>low[3] then
th=low[3]
flag=1
endif
if flag=1 and box=0 and low<th then
flag=0
endif
if flag=1 and box=0 and high<high[3] and high[1]<high[3] and high[2]<high[3] then
DownBoxe=high[3]
UpBoxe=th
box=1
endif
once DownBoxe=undefined
once UpBoxe=undefined
//============================== Fin
return UpBoxe style (point,3) as "UpBoxe",DownBoxe style (point,3) as "DownBoxe"