I have an idea to create a new volume indicator but I need help to develop it since I am not a programmer. I think that I have solved the formula, so I would only need help to write the code to create a Ninjatrader indicator.
I think that the idea is very simple but also very powerful.
It would be similar to the indicator volume up/down but plotting 2 volumes for each candle (1 for up and 1 for down).
The up volume and the down volume for each candle would be calculated from the percentage of the body candle.
In case that the bar is a perfect doji, and the opening price is the same as the closing price, up and down volumes would be 50% each.
In case that the body is 30% of the candle in an up bar, the up volume would be 65% of the total volume, calculated as 30 + (70/2) because the wicks would be 50% of the volume each (up/down).
I believe that the code would be something like this:
Input data: Volume, Open, High, Low & Close
Variables:
UpBar (Boolean)
Body (% of candle)= ((Open-Close) x 100) / (High – Low)
Wicks (% of candle) = 100 – “ Body”
IF (Open < Close){UpBar=True}
IF (UpBar=True) { UpVolume = (Body + (Wicks/2)) x (Volume /100) }
ELSE { UpVolume = (Wicks/2) x (Volume/100) }
DownVolume= Volume – UpVolume
UpVolume (Output this data)
DownVolume (Output this data)
Plot UpVolume and DownVolume
….
I think that this is the right formula but I am not completely sure, so is there anybody that could help me to write the code?
The goal is to create a new indicator with the outputs I propose here, similar to a MACD based on 3 volumes (total, up, and down)
Thanks!
Comment