NexusFi: Find Your Edge


Home Menu

 





Visual backtest in Ninja Trader


Discussion in NinjaTrader

Updated
    1. trending_up 5,064 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 10 posts
    2. attach_file 3 attachments




 
Search this Thread

Visual backtest in Ninja Trader

  #1 (permalink)
peglegtrading
ho chi minh city
 
Posts: 52 since Mar 2011
Thanks Given: 16
Thanks Received: 9

What is the best way to visually backtest an indicator? Is there some marking arrow function which will stamp the price on the chart? I know it's rather rudimentary but I have no programming skills to work with so this is the best I can do for now.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Futures True Range Report
The Elite Circle
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
Are there any eval firms that allow you to sink to your …
Traders Hideout
Deepmoney LLM
Elite Quantitative GenAI/LLM
NexusFi Journal Challenge - April 2024
Feedback and Announcements
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
59 thanks
Funded Trader platforms
38 thanks
NexusFi site changelog and issues/problem reporting
26 thanks
GFIs1 1 DAX trade per day journal
19 thanks
The Program
18 thanks
  #2 (permalink)
 
forrestang's Avatar
 forrestang 
Chicago IL
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
Posts: 1,329 since Jun 2010
Thanks Given: 354
Thanks Received: 1,047


peglegtrading View Post
What is the best way to visually backtest an indicator? Is there some marking arrow function which will stamp the price on the chart? I know it's rather rudimentary but I have no programming skills to work with so this is the best I can do for now.

Not sure how much of an explanation you wanted, but here is a very BASIC way to accomplish what you want and is a very simple example.

If you wanted to do this, you would need to create an arrow via NT script to plot based on some conditions you want to test. For example if you wanted to test a MACD crossing above 0, you would write a script with the following lines of code:
 
Code
if(  MACD(34,89,9).Value[0] > 0 &&  MACD(34,89,9).Value[1] < 0)
  {
      DrawArrowUp("arrow"+CurrentBar, true, 0, Low[0]-12*TickSize, Color.Green);
   }

That is just the entry. Say you wanted to exit when the MACD crosses back below 0. I like to plot a different chart marker for my exits so I use an opposing direction triangle. You would add this line of code:
 
Code
if(  MACD(34,89,9).Value[0] < 0 &&  MACD(34,89,9).Value[1] > 0)
  {
     DrawTriangleDown("arrow"+CurrentBar, true, 0, High[0]+12*TickSize, Color.Black);
   }
You could also print the closing price of the bar with the arrow there by appending the first statement above with this "DrawText" line to print the price so it will be easier to see:
 
Code
if(  MACD(34,89,9).Value[0] > 0 &&  MACD(34,89,9).Value[1] < 0)
  {
      DrawArrowUp("arrow"+CurrentBar, true, 0, Low[0]-12*TickSize, Color.Green);
      DrawText("text0"+CurrentBar, ""+Close.ToString(), 0, Low[0]-30*TickSize, Color.Black);
   }

You also want to set a flag so that your script knows weather or not a trade has been triggered.... but for the purposes of this example, since we are just using the 0 crossing of an oscillator, it knows long if above zero, and flat if below.

Attached is what that looks like on a chart.

Attached Thumbnails
Click image for larger version

Name:	Prime2011-09-23_052836.png
Views:	171
Size:	3.1 KB
ID:	50038  
Reply With Quote
  #3 (permalink)
peglegtrading
ho chi minh city
 
Posts: 52 since Mar 2011
Thanks Given: 16
Thanks Received: 9


Basically why I ask is that I want to create a visual backtest using the following indicators when they are in trend mode. The reason I ask just for a visual backtest is that I am not sure if the past two days are extremely trendy or if I found some really sweet combination of entries and exits.

JeffsADXv2
HeikenAshi
EMA_Colors_V3_No_Repaint_Bars

When they are all signalling together just follow the trend.

Huge results the past two days.

Reply With Quote
  #4 (permalink)
 
forrestang's Avatar
 forrestang 
Chicago IL
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
Posts: 1,329 since Jun 2010
Thanks Given: 354
Thanks Received: 1,047

Well, as far as programming this goes, you would have to be more specific on how you want these things to work.

Initially it sounded like you wanted explicit entry/exit signals painted on your chart?

It sounds like now what you are wanting is more of a 'trendMeter' of sorts based on those 3 indicators being up or down.

But at any rate, you would need to provide more definition on what conditions EACH of these 3 indicators would be displaying individually, that would make up the sum of your trend definition.

Reply With Quote
  #5 (permalink)
peglegtrading
ho chi minh city
 
Posts: 52 since Mar 2011
Thanks Given: 16
Thanks Received: 9


forrestang View Post
Well, as far as programming this goes, you would have to be more specific on how you want these things to work.

Initially it sounded like you wanted explicit entry/exit signals painted on your chart?

It sounds like now what you are wanting is more of a 'trendMeter' of sorts based on those 3 indicators being up or down.

But at any rate, you would need to provide more definition on what conditions EACH of these 3 indicators would be displaying individually, that would make up the sum of your trend definition.

Yes, it seems my original idea is much more about an indicator than a "backtest." Apologies for being so vague.

As you can see from the screenshot, if the heiken ashi bar is red, the adx indicator is blue and the ema slope bars are red, that would be a good time to short.

For long the Heiken Ashi would be Yellow, the Adx blue and the EMA Slope Green.

I actually tried to do this in strategy mode using the bool command (these are all true false conditions) but I got stopped at the beginning when it asked for the input series and I didn't know how to tell it what to do.

Anyways, I feel like I should pay someone to do this or at least find someone to pay to teach me, this seems like awfully tedious work for someone who actually knows how to program on ninjatrader.

Attached Thumbnails
Click image for larger version

Name:	TF 12-11 (8 Range)  9_23_2011 short.jpg
Views:	172
Size:	66.3 KB
ID:	50041   Click image for larger version

Name:	TF 12-11 (8 Range)  9_23_2011long.jpg
Views:	189
Size:	66.8 KB
ID:	50042  
Reply With Quote
  #6 (permalink)
 
forrestang's Avatar
 forrestang 
Chicago IL
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
Posts: 1,329 since Jun 2010
Thanks Given: 354
Thanks Received: 1,047


peglegtrading View Post
Yes, it seems my original idea is much more about an indicator than a "backtest." Apologies for being so vague.

As you can see from the screenshot, if the heiken ashi bar is red, the adx indicator is blue and the ema slope bars are red, that would be a good time to short.

For long the Heiken Ashi would be Yellow, the Adx blue and the EMA Slope Green.

I actually tried to do this in strategy mode using the bool command (these are all true false conditions) but I got stopped at the beginning when it asked for the input series and I didn't know how to tell it what to do.

Anyways, I feel like I should pay someone to do this or at least find someone to pay to teach me, this seems like awfully tedious work for someone who actually knows how to program on ninjatrader.

This isn't complicated at all to accomplish. Post the links to the indicators you are currently using so that I can download the ones you are using.

Reply With Quote
  #7 (permalink)
peglegtrading
ho chi minh city
 
Posts: 52 since Mar 2011
Thanks Given: 16
Thanks Received: 9


forrestang View Post
This isn't complicated at all to accomplish. Post the links to the indicators you are currently using so that I can download the ones you are using.

I have gone ahead and pm'd you the indicators as one of them cannot be found on the elite section but I am almost certain I found it there.

I think the big deal about this combination is that it has 2 indicators which deal with nothing but avoiding chop. Not that they avoid it but they seem to put the odds in your favor when you trade high volume times of day (or night in my case).

Also keep in mind that the signal for the bar must be in alignment with the trend. So if it's a buy signal the close of the signal bar should be bullish (a close higher than it opens) and reversed for a bearish signal. The OHLC bars are extremely useful for alerting us to this.

Although I am completely new to NinjaTrader I have been with Metatrader for more than 5 years so I have a pretty good idea about trading Forex. I am really tired of bad brokers though so I am trying to transition to a more open market, namely futures markets.

Reply With Quote
  #8 (permalink)
 
forrestang's Avatar
 forrestang 
Chicago IL
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
Posts: 1,329 since Jun 2010
Thanks Given: 354
Thanks Received: 1,047

So do you want an up arrow on the chart when all these conditions are true and vice versa for a short?

Or do you want a meter of sorts that for example is green when all of these conditions are true and red for short?

You have defined so far to trend states.... either up where all of these conditions are true, and dn when the reverse of these conditions are true.

If say two of 3 of these criteria are true, does this put it into a third state where say the trend meter would be yellow?

Do this, mark up a chart with these indicators of what you want to see on your chart with the indicators on them when your conditions are met.

Either you plot an arrow, or you just have a meter on the bottom of the price panel showing the color of your desired state.

Reply With Quote
  #9 (permalink)
cyberspy
Frankfurt/Main
 
Posts: 1 since Jun 2011
Thanks Given: 1
Thanks Received: 0

Thanks for your PM answer.

Reply With Quote
  #10 (permalink)
peglegtrading
ho chi minh city
 
Posts: 52 since Mar 2011
Thanks Given: 16
Thanks Received: 9



cyberspy View Post
Thanks for your PM answer.

I sent the PM to the wrong guy? Confused...

Reply With Quote




Last Updated on September 24, 2011


© 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