NexusFi: Find Your Edge


Home Menu

 





ADXVMA Questions


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Fat Tails with 12 posts (54 thanks)
    2. looks_two Big Mike with 8 posts (12 thanks)
    3. looks_3 syxforex with 7 posts (1 thanks)
    4. looks_4 Peter with 6 posts (7 thanks)
      Best Posters
    1. looks_one Fat Tails with 4.5 thanks per post
    2. looks_two RJay with 2.5 thanks per post
    3. looks_3 Big Mike with 1.5 thanks per post
    4. looks_4 Peter with 1.2 thanks per post
    1. trending_up 29,400 views
    2. thumb_up 88 thanks given
    3. group 16 followers
    1. forum 52 posts
    2. attach_file 12 attachments




 
Search this Thread

ADXVMA Questions

  #11 (permalink)
 zeller4 
Orlando Florida
 
Experience: Intermediate
Platform: NT8
Trading: CL, NQ, ES, RTY
Posts: 477 since Jun 2009
Thanks Given: 1,416
Thanks Received: 404

Peter,

Great detective work!

so what's the next step? If you change that line and recompile, does NT just put it back in as before?

up til now when I've had the problem, I just use the setting of 2 instead of 1.

It's appearance is slightly different but it appears to be working

Kirk

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Futures True Range Report
The Elite Circle
Online prop firm The Funded Trader (TFT) going under?
Traders Hideout
Exit Strategy
NinjaTrader
 
  #12 (permalink)
 
Peter's Avatar
 Peter 
Brisbane; Australia
 
Experience: Intermediate
Platform: NT
Broker: IB/TDA needing new broker
Trading: Futures, Forex, Stocks
Posts: 97 since Jun 2009
Thanks Given: 91
Thanks Received: 118

My way is just importing the ADXVMA via the JMAPaint.zip (to retain it for the future I saved that locally on a separate place). Apparently if I import it via that ZIP the ADXVMA does not recompile like when copying in only the .cs file and compile.
Don't ask me why ... but it works (for me). ADXVMA @2 is also a way.

My guess is that everybody who runs a new NT version and edit/compiles the ADXVMA will ruin his ADXVMA for use in DMAPaint @setting 1.
I think the working ADXVMA might just be a version from somebody who did not yet update to a newer NT version.

Anyway, I am glad I finally found a difference. As you can read in the DMAPaint thread it was bugging me seriously and driving me mad I couldn't find the cause. It didn't make sense.


I think that if this code change can be confirmed by more users is to ask NT if they changed anything in their compiler over the last NT version. But don't hold your breath. As ADXVMA is not a standard NT indicator they will probably not investigate.


Apparently I was not clear ... I added step by step to make it easier:
DO use .......Utilities..... Import NinjaScript.... find the JMAPaintBar.zip ... Open ... say 'Yes" to ADXVMA to replace existing file...(the others is your choice) ...then NT will start importing and you see the hour glass .... then NT says it successfully imported all indicators ..bla bla ... click OK

Addition: I now made a correct ADXVMAv3.ZIP which contains only a good ADXVMA (with RJay mod)
... see couple posts below


That is all ... you are ready ... Do NOT copy the ADXVMA.cs file in and compile. I don't know why it works via importing the ZIP but with me it does.

What I meant with saving the JMAPaint.zip somewhere locally, was to keep the JMAPaint.zip that is currently in the download section at a save place. In an update it might inadvertently be updated with an ADXVMA that you like less.

Reply With Quote
  #13 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,399 since Jun 2009
Thanks Given: 33,175
Thanks Received: 101,541



Peter View Post
The COBC is different but that is not the problem. As mentioned before my good ADXVMA gets problematic by just opening the indicator editor and then compiling (without any changes).


I just compared your ADXVMA with my good ADXVMA. Next to the COBC and version stuff I found a difference in the NT generated code.
It is the same difference that I also find (as only difference) after opening and closing my good ADXVMA that turns bad after opening&recompiling.

To be sure I replicated it again as follows:
I loaded again the good ADXVMA via ZIP from JPaint (and copied it to my desktop... it is the version in left top in the pic) and I checked that it worked with ADXVMA at 1 in the DMA.
I then opened this working ADXVMA indicator with the editor and closed without editing .... again I got a flatlline. I then opened this recompiled ADCVMA file in DiffDoc (left top of panel)

DiffDoc found a difference in the NT generated code. It is the only difference it found.

To me it looks again that NT itself is the culprit.

Peter, great job here. I am wondering if this phenomenon is self-contained to just your workstation, or others. Have you tried deleting your Ninja cache?

I suppose that there is really no point in further talking about ADXVMA. The answer seems clear. Since you know better than anyone, why don't you just go remove any instances of the "bad" ADXVMA from the forum, delete the attachments from the posts, etc, because clearly this has been a headache for you (and all of us). I would do this but I am afraid I would make things worse.

As for the files in the download section with the wrong version, if it is my stuff then you have permission to change out the file or if you'll tell me which ones are the offending ones I will do it.

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #14 (permalink)
 
vast's Avatar
 vast 
Australia
 
Experience: Intermediate
Platform: Ninja
Posts: 167 since Jun 2009
Thanks Given: 154
Thanks Received: 62

Thanks Peter for your guide.
Maybe once it is fixed, we should post a new thread with all the correct indicators in it. Maybe also name the indicators with a unique name and this will not cause it to over write the previous ones. Just a thought

Reply With Quote
  #15 (permalink)
 
Peter's Avatar
 Peter 
Brisbane; Australia
 
Experience: Intermediate
Platform: NT
Broker: IB/TDA needing new broker
Trading: Futures, Forex, Stocks
Posts: 97 since Jun 2009
Thanks Given: 91
Thanks Received: 118

Right, I finally succeeded tricking NT to export a good ADXVMA (edited outside NT in Notepad).
The trick:
If you need to edit this ADXVMA.... make a copy to your desktop ... edit that one in Notepad ... save in Notepad ....overwrite the original in the NT indicator directory .... immediately export to a ZIP .... and then import the ZIP and accept overwriting.
BTW Any editing of this ADXVMA and compile will on my system generate the code switch as shown before and cause flatlining.

The following ZIP contains only the ADXVMA
- I named it ADXVMA3.0 (shows up as such when adding indicators)
- I included the suggestion of RJay (see in this thread earlier)

In my system this ADXVMA will cure a flatline

Attached Files
Elite Membership required to download: ADVVMAv3.zip
Reply With Quote
  #16 (permalink)
 
Peter's Avatar
 Peter 
Brisbane; Australia
 
Experience: Intermediate
Platform: NT
Broker: IB/TDA needing new broker
Trading: Futures, Forex, Stocks
Posts: 97 since Jun 2009
Thanks Given: 91
Thanks Received: 118

Vast, it is a good idea to go for a special name, but then we also need to add that name to the DMAInternal.cs file of the DMA and DMAPaint ... otherwise you cannot use it via the pulldown list with MAs.
I might do that if this v3 proves to work with other people too.


I would like first to have some conformation that:
- they too see the code switch depicted earlier after opening/compiling
- and that this ADXVMAv3 will work for others to solve the flatline
So pls. .... some feedback

If it indeed works I'll remove/adapt the older files and file compilations.

Reply With Quote
Thanked by:
  #17 (permalink)
systrader
Rocky Mountains
 
Posts: 19 since Jun 2009
Thanks Given: 17
Thanks Received: 37


Peter View Post
Vast, it is a good idea to go for a special name, but then we also need to add that name to the DMAInternal.cs file of the DMA and DMAPaint ... otherwise you cannot use it via the pulldown list with MAs.
I might do that if this v3 proves to work with other people too.


I would like first to have some conformation that:
- they too see the code switch depicted earlier after opening/compiling
- and that this ADXVMAv3 will work for others to solve the flatline
So pls. .... some feedback

If it indeed works I'll remove/adapt the older files and file compilations.

Peter,

Your post really helped - thank you! While renaming the branch of indicators for Sharky I experienced the exact same thing as you. For some reason NT was compiling a renamed ADXVMA differently than the original (per your diff post). I edited the .cs file in notepad per your instructions and it worked. Not much to add other than your "fix" works and that I don't think this is machine dependent; eg. it's an internal issue w/ NT.

Reply With Quote
  #18 (permalink)
 
Peter's Avatar
 Peter 
Brisbane; Australia
 
Experience: Intermediate
Platform: NT
Broker: IB/TDA needing new broker
Trading: Futures, Forex, Stocks
Posts: 97 since Jun 2009
Thanks Given: 91
Thanks Received: 118

Thanks Systrader for confirming that the issue was not related to my machine.

Will ask NT if they are aware.

Reply With Quote
  #19 (permalink)
 
RJay's Avatar
 RJay 
Hartford, CT. USA
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG, Kinetick
Trading: RTY
Posts: 682 since Jun 2009
Thanks Given: 757
Thanks Received: 787

I have to ask, I noticed the following code,

----------------------------------------------------------------------

[Description("ADXVMA")]
[Gui.Design.DisplayName(
"ADXVMA")]
publicclass ADXVMA : Indicator
{
#region Variables
// Wizard generated variables
privateint aDXPeriod = 6;
// User defined variables (add any user defined variables below)
private DataSeries PDI;
private DataSeries PDM;
private DataSeries MDM;
private DataSeries MDI;
private DataSeries Out;
privatedouble WeightDM;
privatedouble WeightDI;
privatedouble WeightDX;
privatedouble ChandeEMA;
privatedouble HHV = double.MinValue;
privatedouble LLV = double.MaxValue;
#endregion

-----------------------------------------------------------

Why is HHV assigned MinValue and LLV Assigned Maxvalue???

Logically, shouldn't it be the other way around??

RJay

Reply With Quote
  #20 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


I am trying not create a new thread, as there are already lot of ADXVMA threads in that forum. Recycling this thread now.

I have had a look at the various ADXVMA indicators for NinjaTrader. All of them are coded in a very dirty and inconsistent way. Other than the false initialization already detected by @RJay, there are a number of other problems, which need to be fixed.

Also the try{} catch{} brackets show that the authors are not sure of what they are doing. The period for the indicator is stored 4 times in different redundant variables. Also the code contains a completely useless variable "i", which is set to 0 all the time. This variable points to the MetaTrader origin of the indicator, as it is required for MetaTrade code, if you want to shift the indicator. Ninjatrader does not require that approach and does not make sense to carry that "i" through OnBarUpdate().

Let us say that the code works, but it is clear that probably nobody ever had understood what it is actually doing.

Old ADXVMA code:
 
Code
try
{
	int i = 0;
	PDM.Set( 0 );
	MDM.Set( 0 );
	if(Close[i]>Close[i+1])
		PDM.Set( Close[i]-Close[i+1] );//This array is not displayed.
	else
		MDM.Set( Close[i+1]-Close[i] );//This array is not displayed.
	
	PDM.Set(((WeightDM-1)*PDM[i+1] + PDM[i])/WeightDM);//ema.
	MDM.Set(((WeightDM-1)*MDM[i+1] + MDM[i])/WeightDM);//ema.
	
	double TR=PDM[i]+MDM[i];
	
	if (TR>0)
	{
		PDI.Set(PDM[i]/TR);
		MDI.Set(MDM[i]/TR);
	}//Avoid division by zero. Minimum step size is one unnormalized price pip.
	else
	{
		PDI.Set(0);
		MDI.Set(0);
	}
	
	PDI.Set(((WeightDI-1)*PDI[i+1] + PDI[i])/WeightDI);//ema.
	MDI.Set(((WeightDI-1)*MDI[i+1] + MDI[i])/WeightDI);//ema.
		double DI_Diff=PDI[i]-MDI[i];  
	if (DI_Diff<0)
		DI_Diff= -DI_Diff;//Only positive momentum signals are used.
	double DI_Sum=PDI[i]+MDI[i];
	double DI_Factor=0;//Zero case, DI_Diff will also be zero when DI_Sum is zero.
	if (DI_Sum>0)
		Out.Set(DI_Diff/DI_Sum);//Factional, near zero when PDM==MDM (horizonal), near 1 for laddering.
	else
		Out.Set(0);
			  Out.Set(((WeightDX-1)*Out[i+1] + Out[i])/WeightDX);
	
	if (Out[i]>Out[i+1])
	{
		HHV=Out[i];
		LLV=Out[i+1];
	}
	else
	{
		HHV=Out[i+1];
		LLV=Out[i];
	}
	for(int j=1;j<Math.Min(ADXPeriod,CurrentBar);j++)
	{
		if(Out[i+j+1]>HHV)HHV=Out[i+j+1];
		if(Out[i+j+1]<LLV)LLV=Out[i+j+1];
	}
	
	
	double diff = HHV - LLV;//Veriable reference scale, adapts to recent activity level, unnormalized.
	double VI=0;//Zero case. This fixes the output at its historical level. 
	if (diff>0)
		VI=(Out[i]-LLV)/diff;//Normalized, 0-1 scale.
	
	  
							
	ADXVMAPlot.Set(((ChandeEMA-VI)*ADXVMAPlot[i+1]+VI*Close[i])/ChandeEMA);//Chande VMA formula with ema built in.
}
catch( Exception ex )
{
	Print( ex.ToString() );
}

Recoded (basic version):
 
Code
double currentUp = Math.Max(Input[0] - Input[1], 0);
double currentDown = Math.Max(Input[1] - Input[0], 0);
up.Set ((1-k)*up[1] + k*currentUp);
down.Set((1-k)*down[1] + k*currentDown);
double sum = up[0] + down[0];
double fractionUp = 0.0;
double fractionDown = 0.0;
if(sum > double.Epsilon)
{
	fractionUp = up[0]/sum;
	fractionDown = down[0]/sum;
}
ups.Set((1-k)*ups[1] + k*fractionUp);
downs.Set((1-k)*downs[1] + k*fractionDown);

double normDiff = Math.Abs(ups[0] - downs[0]);
double normSum = ups[0] + downs[0];
double normFraction = 0.0;
if(normSum > double.Epsilon)
	normFraction = normDiff/normSum;
index.Set((1-k)*index[1] + k*normFraction);

hhv = MAX(index,period+1)[0];
llv = MIN(index,period+1)[0];
double vDiff = hhv-llv;
double vIndex = 0;
if(vDiff > double.Epsilon)
	vIndex = (index[0] - llv)/vDiff;
ADXVMA.Set((1 - k*vIndex)*ADXVMA[1] + k*vIndex*Input[0]);

I have then added a feature to color the moving average and added paint bars. The direction of the ADXVMA (up, down, neutral) is exposed and can be accessed by other indicators as a trendfilter. The indicator can also applied to any other input series.


The indicator can be downloaded here:





Reply With Quote




Last Updated on October 2, 2013


© 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