NexusFi: Find Your Edge


Home Menu

 





Finding real price of current and past ADXVMA bar


Discussion in NinjaTrader

Updated
    1. trending_up 4,661 views
    2. thumb_up 1 thanks given
    3. group 3 followers
    1. forum 10 posts
    2. attach_file 4 attachments




 
Search this Thread

Finding real price of current and past ADXVMA bar

  #1 (permalink)
 
SolubleFish's Avatar
 SolubleFish 
Chapel Hill, NC
 
Experience: Intermediate
Platform: NinjaTrader
Broker: NinjaTrader
Trading: Futures
Posts: 6 since Apr 2015
Thanks Given: 1
Thanks Received: 0

I would like to find the value of anaADXVMA for a futures contract's current and past bar. I have worked on this code, but I'm not getting the right values to get the comparison right. I want to identify chop areas. When ADXVMA looks flat, there is usually a lot of chop. So, here's what I have, but the values are not coming out right. If the current bar's ADXVMA is equal to the previous bar's ADXvma, then we have flattened. Visually, it makes sense. Mathematically, I'm not able to zero in on it due to variances between ticks and actual real value. The instrument I'm using is ZB.

protected override void OnBarUpdate()
{
decimals = Math.Log10(1/Instrument.MasterInstrument.TickSize);
Print("TickSize for " + Instrument + " is " + Instrument.MasterInstrument.TickSize + " and has " + decimals + " decimal places");
Print (" ----------------------------");
adxvmaNow = anaADXVMA(8).ADXVMA[0];
roundedNow = Instrument.MasterInstrument.Round2TickSize(Close[0]);
rounded2decimals0 = Math.Round(roundedNow,2);

//
adxvmaBefore = anaADXVMA(8).ADXVMA[1];
roundedBefore = Instrument.MasterInstrument.Round2TickSize(Close[0]);
rounded2decimals1 = Math.Round(roundedBefore,2);

Attached Thumbnails
Click image for larger version

Name:	ZB ADXVMA 10min.JPG
Views:	225
Size:	74.6 KB
ID:	208722  
Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
REcommedations for programming help
Sierra Chart
Better Renko Gaps
The Elite Circle
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
How to apply profiles
Traders Hideout
MC PL editor upgrade
MultiCharts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
23 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #3 (permalink)
 
rleplae's Avatar
 rleplae 
Gits (Hooglede) Belgium
Legendary Market Wizard
 
Experience: Master
Platform: NinjaTrader, Proprietary,
Broker: Ninjabrokerage/IQfeed + Synthetic datafeed
Trading: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
Posts: 3,003 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,863


What are the values your are getting, can you print them both rounded and not rounded
with Print(..) ?

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #4 (permalink)
 
SolubleFish's Avatar
 SolubleFish 
Chapel Hill, NC
 
Experience: Intermediate
Platform: NinjaTrader
Broker: NinjaTrader
Trading: Futures
Posts: 6 since Apr 2015
Thanks Given: 1
Thanks Received: 0

Here's some output on the printouts I'm getting. Notice that current and previous bar are the same price.

Thanks
------
TickSize for ZB 06-16 Globex is 0.03125 and has 1.50514997831991 decimal places
----------------------------
5/18/2016 4:00:00 PM - Close of Bar - 163.65625
5/18/2016 4:00:00 PM - ADXVMA Now for ZB 06-16 Globex is: 163.839854496411
5/18/2016 4:00:00 PM - ADXVMA Before for ZB 06-16 Globex is: 163.864920513144
5/18/2016 4:00:00 PM - ADXVMA Level0 for ZB 06-16 Globex is: 163.65625
........
5/18/2016 4:00:00 PM - ADXVMA Now real ZB 06-16 Globex is: 163.65625
5/18/2016 4:00:00 PM - ADXVMA Before real ZB 06-16 Globex is: 163.65625
........
5/18/2016 4:00:00 PM - ADXVMA Now rounded for ZB 06-16 Globex is: 163.66
5/18/2016 4:00:00 PM - ADXVMA Before rounded for ZB 06-16 Globex is: 163.66
-------
TickSize for ZB 06-16 Globex is 0.03125 and has 1.50514997831991 decimal places
----------------------------
5/18/2016 4:10:00 PM - Close of Bar - 163.8125
5/18/2016 4:10:00 PM - ADXVMA Now for ZB 06-16 Globex is: 163.837111570806
5/18/2016 4:10:00 PM - ADXVMA Before for ZB 06-16 Globex is: 163.839854496411
5/18/2016 4:10:00 PM - ADXVMA Level0 for ZB 06-16 Globex is: 163.8125
........
5/18/2016 4:10:00 PM - ADXVMA Now real ZB 06-16 Globex is: 163.8125
5/18/2016 4:10:00 PM - ADXVMA Before real ZB 06-16 Globex is: 163.8125
........
5/18/2016 4:10:00 PM - ADXVMA Now rounded for ZB 06-16 Globex is: 163.81
5/18/2016 4:10:00 PM - ADXVMA Before rounded for ZB 06-16 Globex is: 163.81
-------
TickSize for ZB 06-16 Globex is 0.03125 and has 1.50514997831991 decimal places
----------------------------
5/18/2016 4:20:00 PM - Close of Bar - 163.75
5/18/2016 4:20:00 PM - ADXVMA Now for ZB 06-16 Globex is: 163.83211698193
5/18/2016 4:20:00 PM - ADXVMA Before for ZB 06-16 Globex is: 163.837111570806
5/18/2016 4:20:00 PM - ADXVMA Level0 for ZB 06-16 Globex is: 163.75
........
5/18/2016 4:20:00 PM - ADXVMA Now real ZB 06-16 Globex is: 163.75
5/18/2016 4:20:00 PM - ADXVMA Before real ZB 06-16 Globex is: 163.75
........
5/18/2016 4:20:00 PM - ADXVMA Now rounded for ZB 06-16 Globex is: 163.75
5/18/2016 4:20:00 PM - ADXVMA Before rounded for ZB 06-16 Globex is: 163.75
-------
TickSize for ZB 06-16 Globex is 0.03125 and has 1.50514997831991 decimal places
----------------------------
5/18/2016 4:30:00 PM - Close of Bar - 163.75
5/18/2016 4:30:00 PM - ADXVMA Now for ZB 06-16 Globex is: 163.83211698193
5/18/2016 4:30:00 PM - ADXVMA Before for ZB 06-16 Globex is: 163.83211698193
5/18/2016 4:30:00 PM - ADXVMA Level0 for ZB 06-16 Globex is: 163.75
........
5/18/2016 4:30:00 PM - ADXVMA Now real ZB 06-16 Globex is: 163.75
5/18/2016 4:30:00 PM - ADXVMA Before real ZB 06-16 Globex is: 163.75
........

Started this thread Reply With Quote
  #5 (permalink)
 
rleplae's Avatar
 rleplae 
Gits (Hooglede) Belgium
Legendary Market Wizard
 
Experience: Master
Platform: NinjaTrader, Proprietary,
Broker: Ninjabrokerage/IQfeed + Synthetic datafeed
Trading: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
Posts: 3,003 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,863

use this for decimal places :

 
Code
public static class MathDecimals
{
    public static int GetDecimalPlaces(decimal n)
    {
        n = Math.Abs(n); //make sure it is positive.
        n -= (int)n;     //remove the integer part of the number.
        var decimalPlaces = 0;
        while (n > 0)
        {
            decimalPlaces++;
            n *= 10;
            n -= (int)n;
        }
        return decimalPlaces;
    }
}
1. Some indicators don't give you the previous value (if not exposed), you can verify this by
opening the databox on the chart and going over with your mouse

2. In that case, the work around could be to memorize the previous value, like

oldADXVMA = anaADXVMA(8).ADXVMA[0] at the end of your check
so at every bar, you have the old value at the beginning of your OnBarUpdae

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #6 (permalink)
 
SolubleFish's Avatar
 SolubleFish 
Chapel Hill, NC
 
Experience: Intermediate
Platform: NinjaTrader
Broker: NinjaTrader
Trading: Futures
Posts: 6 since Apr 2015
Thanks Given: 1
Thanks Received: 0

Thanks. Will try that. Your code is much more elegant than what I stitched together.

Started this thread Reply With Quote
  #7 (permalink)
 
SolubleFish's Avatar
 SolubleFish 
Chapel Hill, NC
 
Experience: Intermediate
Platform: NinjaTrader
Broker: NinjaTrader
Trading: Futures
Posts: 6 since Apr 2015
Thanks Given: 1
Thanks Received: 0

Thanks for the help. After getting it coded it turns out what 'looks' to the eye as a neutral or choppy area, the underlying math says otherwise. So, what I really would like to know if there is a way to access the Pos, Neg, Neutral trend state in anaADXVMA indicator from the code. I can see that the series is exposed (Bloodhound can see the trend series), but I don't know how to access them from ninjascript. I could use some help there if it is possible.

Thanks!

Started this thread Reply With Quote
  #8 (permalink)
 
rleplae's Avatar
 rleplae 
Gits (Hooglede) Belgium
Legendary Market Wizard
 
Experience: Master
Platform: NinjaTrader, Proprietary,
Broker: Ninjabrokerage/IQfeed + Synthetic datafeed
Trading: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
Posts: 3,003 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,863


SolubleFish View Post
Thanks for the help. After getting it coded it turns out what 'looks' to the eye as a neutral or choppy area, the underlying math says otherwise. So, what I really would like to know if there is a way to access the Pos, Neg, Neutral trend state in anaADXVMA indicator from the code. I can see that the series is exposed (Bloodhound can see the trend series), but I don't know how to access them from ninjascript. I could use some help there if it is possible.

Thanks!

If you open the databox, and you scroll over the chart, do you see the variables ?
what is their name ?
can you post a screenshot ?

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #9 (permalink)
 
SolubleFish's Avatar
 SolubleFish 
Chapel Hill, NC
 
Experience: Intermediate
Platform: NinjaTrader
Broker: NinjaTrader
Trading: Futures
Posts: 6 since Apr 2015
Thanks Given: 1
Thanks Received: 0

Here are a couple; one for a neutral and one for a trending. The names are not different, just colors are different. I'm also including a screenshot from what Bloodhound Sees. Thanks for the help.

Attached Thumbnails
Click image for larger version

Name:	anaADXVMA_Bloodhound Exposed.JPG
Views:	188
Size:	44.4 KB
ID:	208856   Click image for larger version

Name:	anaADXVMA_TrendingJPG.JPG
Views:	210
Size:	41.1 KB
ID:	208857   Click image for larger version

Name:	anaADXVMA_Neutral.JPG
Views:	174
Size:	46.4 KB
ID:	208858  
Started this thread Reply With Quote
  #10 (permalink)
 
rleplae's Avatar
 rleplae 
Gits (Hooglede) Belgium
Legendary Market Wizard
 
Experience: Master
Platform: NinjaTrader, Proprietary,
Broker: Ninjabrokerage/IQfeed + Synthetic datafeed
Trading: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
Posts: 3,003 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,863



SolubleFish View Post
Here are a couple; one for a neutral and one for a trending. The names are not different, just colors are different. I'm also including a screenshot from what Bloodhound Sees. Thanks for the help.

do you have the source code of that adxvma ?

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote




Last Updated on May 20, 2016


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts