NexusFi: Find Your Edge


Home Menu

 





executing strategy in backtesting


Discussion in NinjaTrader

Updated
    1. trending_up 6,329 views
    2. thumb_up 2 thanks given
    3. group 2 followers
    1. forum 11 posts
    2. attach_file 2 attachments




 
Search this Thread

executing strategy in backtesting

  #11 (permalink)
 
redratsal's Avatar
 redratsal 
Milan (I)
 
Experience: Advanced
Platform: Ninjatrader
Broker: Kinetick
Trading: FDAX,6E,CL,YM,NQ,ES
Posts: 1,648 since Oct 2010
Thanks Given: 1,215
Thanks Received: 2,090


cicondo View Post
Hi Mike,

now I have a really simple projekt, but it shows the same problems. Please have a look at the attached both files.
Hope you can see the fault, otherwise it is a bug to report to NT.

Cheers
Markus

Hi Markus,

The indy is not plotting the EMA's and the crossabove/below are made with variables which are doing nothing and or I don't understand. I marked in yellow my version with print to debug (for the crossabove condition) to be used with the NT output window(your former print was of no help printing repeatedly the same message.



 
Code
protected override void OnBarUpdate()
        {
            // Use this method for calculating your indicator values. Assign a value to each
            // plot below by replacing 'Close[0]' with your own formula.
            Print("EMA"+period14+"="+EMA(Close, period14)[0]);
			Print("EMA"+period7+"="+EMA(Close, period7)[0]);
            if (CrossAbove(EMA(period7), EMA(period14), 1))

            {
                if (OnFireCrossUp != null)
                    OnFireCrossUp(this, Close[0]);
				
 


            }
            if (CrossBelow(EMA7, EMA14, 1))
            {
                if (OnFireCrossDown != null)
                    OnFireCrossDown(this, Close[0]);
            }
        }

Visit my NexusFi Trade Journal Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Strategy stop orders partially filled
EasyLanguage Programming
Cheap historycal L1 data for stocks
Stocks and ETFs
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
ZombieSqueeze
Platforms and Indicators
What broker to use for trading palladium futures
Commodities
 
  #12 (permalink)
cicondo
Munich
 
Posts: 6 since Apr 2011
Thanks Given: 1
Thanks Received: 1


redratsal View Post
Hi Markus,

The indy is not plotting the EMA's and the crossabove/below are made with variables which are doing nothing and or I don't understand. I marked in yellow my version with print to debug (for the crossabove condition) to be used with the NT output window(your former print was of no help printing repeatedly the same message.



 
Code
protected override void OnBarUpdate()
        {
            // Use this method for calculating your indicator values. Assign a value to each
            // plot below by replacing 'Close[0]' with your own formula.
            Print("EMA"+period14+"="+EMA(Close, period14)[0]);
			Print("EMA"+period7+"="+EMA(Close, period7)[0]);
            if (CrossAbove(EMA(period7), EMA(period14), 1))

            {
                if (OnFireCrossUp != null)
                    OnFireCrossUp(this, Close[0]);
				
 


            }
            if (CrossBelow(EMA7, EMA14, 1))
            {
                if (OnFireCrossDown != null)
                    OnFireCrossDown(this, Close[0]);
            }
        }

Hi thx for your replay,

you're right the problem is, that the indicator OnBarUpdate() method will not be called. I usually dont use print statements because I debug the system with Visual Studio directly (keeps code clean).

I mention that the problem is using events with an indicator will not work properly. My question on that thread is for any help about that. Maybe there is one other NT developer who had the same problem.

Markus

Reply With Quote




Last Updated on May 5, 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