Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
I'm attempting to make a filter for identifying a number of bars since a pivot high or low. I have provided the code below. The issue is that currently I have not figured out the logic that properly identifies the pivot high or pivot low and to start counting from that pivot high or pivot low. Any suggestions?
Vars
private int BarsSinceHigh = 0;
private int BarsSinceLow = 0;
private bool BarCount1 = true;
private bool BarCount2 = true;
OBU()
if(MIN(Low,16)[0] < Low[0]) //How do instead create a condition to identify the pivot low?
{
BarsSinceLow=0;
BarCount1=false;
}
else BarsSinceLow++;
if(BarsSinceLow >= 8)
BarCount1 = true;
if(MAX(High,16)[0] > High[0]) How do instead create a condition to identify the pivot High?
{
BarsSinceHigh=0;
BarCount2=false;
}
else BarsSinceHigh++;
if(BarsSinceHigh >= 8)
BarCount2 = true;
Can you help answer these questions from other members on NexusFi?
There are basically two methods of identifying highs and lows. One is based on the lookback period, the other one on the minimum deviation.
Lookback period: A pivot of strength 8 would be a candle with a higher high than the 8 preceding and 8 following candles. The pivot high or low would be unconfirmed, if such a candle has just plotted. Confirmation of the pivot high or low will be 8 bars later, if the provisory piovt high or low has not been taken out. I would mark that high or low already when a new candle has a higher high or lower low than the 8 preceding bars. Then keep it, if it is confirmed. To count the candles that have passed from this pivot just collect the CurrentBar, when the pivot is identified. Store the value somewhere. N bars later, you can call CurrentBar again and compare it with the stored value. The difference will be N.
Zigzag : A more elegant way to identify highs and lows is a zigzag indicator which is based on a minimum deviation. You can for example use the zigzag indicator of NinjaTrader and simply access the highs and lows.