NexusFi: Find Your Edge


Home Menu

 





Open ChartTrader with Strategy


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one ThatManFromTexas with 7 posts (9 thanks)
    2. looks_two lolu with 4 posts (2 thanks)
    3. looks_3 askerix with 3 posts (0 thanks)
    4. looks_4 nailz420 with 1 posts (3 thanks)
    1. trending_up 7,394 views
    2. thumb_up 14 thanks given
    3. group 10 followers
    1. forum 18 posts
    2. attach_file 1 attachments




 
Search this Thread

Open ChartTrader with Strategy

  #11 (permalink)
 askerix 
Zurich Switzerland
 
Experience: None
Platform: NT
Trading: Ukulele
Frequency: Never
Duration: Never
Posts: 60 since Mar 2011
Thanks Given: 554
Thanks Received: 62

TMFT,

great idea to create a strategyobject within the indicator. I've worked around that charttrader/strategy-issue before with a separate window for my strategy buttons - but that opens a lot new possibilities.

I tried to test it with a dummy strategy but failed with the integration into the indicator.
It would be great if you can share a code sample which
  • creates the object (skip that - you've done already)
  • defines the used account (do you have to set the enable property of the strategy object to false while adjusting the Account?)
  • other preparations necessary to use the strategy
another question: How long is the object instantiated? will you destroy it after each use or do you create it once and just call the order-functions when needed?

thank you very much
askerix

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Futures True Range Report
The Elite Circle
Deepmoney LLM
Elite Quantitative GenAI/LLM
ZombieSqueeze
Platforms and Indicators
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
Build trailing stop for micro index(s)
Psychology and Money Management
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
60 thanks
Funded Trader platforms
43 thanks
NexusFi site changelog and issues/problem reporting
24 thanks
GFIs1 1 DAX trade per day journal
22 thanks
The Program
19 thanks
  #12 (permalink)
 
ThatManFromTexas's Avatar
 ThatManFromTexas 
Houston,Tx
 
Experience: Advanced
Platform: NinjaTrader
Broker: Mirus Futures/Zen-Fire
Trading: TF
Posts: 2,265 since Feb 2010
Thanks Given: 1,206
Thanks Received: 4,348


askerix View Post
TMFT,

great idea to create a strategyobject within the indicator. I've worked around that charttrader/strategy-issue before with a separate window for my strategy buttons - but that opens a lot new possibilities.

I tried to test it with a dummy strategy but failed with the integration into the indicator.
It would be great if you can share a code sample which
  • creates the object (skip that - you've done already)
  • defines the used account (do you have to set the enable property of the strategy object to false while adjusting the Account?)
  • other preparations necessary to use the strategy
another question: How long is the object instantiated? will you destroy it after each use or do you create it once and just call the order-functions when needed?

thank you very much
askerix

@askerix

I use it simply to place orders for me when I push a button.

I press the Buy Range Button; the indicator calls the strategy (created earlier as you normally would), passes the order information to it, the strategy creates the order from the received info and places a stop limit order 1 tick above the projected end of the bar.

If price moves away, I press the Close Button and the order is cancelled.

If it gets filled the ATM strategy takes over. At that point I can drag the stops and targets without an issue.

There is no enable/disable with the strategy.

To use this for a regular strategy I suppose you would have to write all the conditions in the indicator and when the conditions were met, instead of plotting something, it would pass the order info to the strategy which would generate the order.

A professional programmer could pass info both directions. But I'm not a programmer. I cobble stuff together and hack on it until it works. If we were talking about cars I would be a Shade Tree Mechanic.

Hope that helps.

I'm just a simple man trading a simple plan.

My daddy always said, "Every day above ground is a good day!"
Reply With Quote
  #13 (permalink)
 askerix 
Zurich Switzerland
 
Experience: None
Platform: NT
Trading: Ukulele
Frequency: Never
Duration: Never
Posts: 60 since Mar 2011
Thanks Given: 554
Thanks Received: 62



ThatManFromTexas View Post
@ askerix

I use it simply to place orders for me when I push a button.

I press the Buy Range Button; the indicator calls the strategy (created earlier as you normally would), passes the order information to it, the strategy creates the order from the received info and places a stop limit order 1 tick above the projected end of the bar.

If price moves away, I press the Close Button and the order is cancelled.

If it gets filled the ATM strategy takes over. At that point I can drag the stops and targets without an issue.

There is no enable/disable with the strategy.

I want to use it in the exact same way - also searching for a possibility to enter StopLimits over a Chart Trader button.
I tried to call my test strategy - it's working ( i can do a print-statement within) but the AtmStrategyCreate fails with the error "Object reference not set to an instance of an object.". so something still wrong within the strategy.
If you could help with a short code example it would save me several evenings digging into that

askerix

Reply With Quote
  #14 (permalink)
 
ThatManFromTexas's Avatar
 ThatManFromTexas 
Houston,Tx
 
Experience: Advanced
Platform: NinjaTrader
Broker: Mirus Futures/Zen-Fire
Trading: TF
Posts: 2,265 since Feb 2010
Thanks Given: 1,206
Thanks Received: 4,348


askerix View Post
I want to use it in the exact same way - also searching for a possibility to enter StopLimits over a Chart Trader button.
I tried to call my test strategy - it's working ( i can do a print-statement within) but the AtmStrategyCreate fails with the error "Object reference not set to an instance of an object.". so something still wrong within the strategy.
If you could help with a short code example it would save me several evenings digging into that

askerix

@askerix

The ATM....


 
Code
  #region Variables
		private string	atmStrategyId		= string.Empty;
		private string	orderId				= string.Empty;
		private int atmname_i = 11; // Default setting for Atmname
		private string	type				= string.Empty;
		private string atmname = "";
		
        #endregion

        /// <summary>
        /// This method is used to configure the strategy and is called once before any strategy method is called.
        /// </summary>
        protected override void Initialize()
        {
            CalculateOnBarClose = false;
            atmname = "tmft" + Convert.ToString (atmname_i);
			EntriesPerDirection = 1;
    		EntryHandling = EntryHandling.AllEntries;
        }

        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
			
			
        }

       

        public void EnterPosition(OrderAction way, OrderType oType, int quantity, double entry, double target, double stop, Button btnCallback)
        {
            

            switch (way)
            {	
                case OrderAction.Buy:
                    switch (oType)
                    {	
						
                        case OrderType.Stop:
							string[] entryOrder = GetAtmStrategyEntryOrderStatus(orderId);
                            atmStrategyId = GetAtmStrategyUniqueId();
							orderId = GetAtmStrategyUniqueId();
							AtmStrategyCreate(Cbi.OrderAction.Buy, OrderType.Stop, 0, entry,
							TimeInForce.Day, orderId, atmname, atmStrategyId);
                            break;

There is some more info here....



NinjaTrader Chart Trader Indicator

dsChartTrader - [AUTOLINK]NinjaTrader[/AUTOLINK] Strategy

Tools and indicators for NinjaTrader

I'm just a simple man trading a simple plan.

My daddy always said, "Every day above ground is a good day!"
Reply With Quote
Thanked by:
  #15 (permalink)
 
monpere's Avatar
 monpere 
Bala, PA, USA
 
Experience: Intermediate
Platform: NinjaTrader
Broker: Mirus, IB
Trading: SPY, Oil, Euro
Posts: 1,854 since Jul 2010
Thanks Given: 300
Thanks Received: 3,371


askerix View Post
I want to use it in the exact same way - also searching for a possibility to enter StopLimits over a Chart Trader button.
I tried to call my test strategy - it's working ( i can do a print-statement within) but the AtmStrategyCreate fails with the error "Object reference not set to an instance of an object.". so something still wrong within the strategy.
If you could help with a short code example it would save me several evenings digging into that

askerix

"Object reference not set to an instance of an object." Make sure you initialize every varialbe when your declare it. Ex:

int i = 0;
string text = "";
double d = 0;

Reply With Quote
  #16 (permalink)
 
ThatManFromTexas's Avatar
 ThatManFromTexas 
Houston,Tx
 
Experience: Advanced
Platform: NinjaTrader
Broker: Mirus Futures/Zen-Fire
Trading: TF
Posts: 2,265 since Feb 2010
Thanks Given: 1,206
Thanks Received: 4,348


askerix View Post
I want to use it in the exact same way - also searching for a possibility to enter StopLimits over a Chart Trader button.
I tried to call my test strategy - it's working ( i can do a print-statement within) but the AtmStrategyCreate fails with the error "Object reference not set to an instance of an object.". so something still wrong within the strategy.
If you could help with a short code example it would save me several evenings digging into that

askerix

@askerix

Check the download section, posted by Bukkan


I'm just a simple man trading a simple plan.

My daddy always said, "Every day above ground is a good day!"
Reply With Quote
  #17 (permalink)
 askerix 
Zurich Switzerland
 
Experience: None
Platform: NT
Trading: Ukulele
Frequency: Never
Duration: Never
Posts: 60 since Mar 2011
Thanks Given: 554
Thanks Received: 62

@ TMFT, @ monpere

thanks for your support. I've tested further and identified where the Object error comes from - all Strategy related Properties lie TickSize or Instrument raises that error.
It seems to me, that the Strategy object is not properly instanciated with that code
 
Code
private NinjaTrader.Strategy.TMFTGuidedStrategy trader;   
trader = new NinjaTrader.Strategy.TMFTGuidedStrategy();

void OnBuy(object sender, System.EventArgs e)                      
{                         
 trader.EnterPosition(OrderAction.Buy,OrderType.Stop, 1, rangeHi, 0, 0, buyRange);                      
}
I placed debug output in several methods like initialize - it's not called only if I build my call to initialize within the class on my own.

if I assign
trader.Account = <TheCharttraderAccount> - then I can query the Account within the strategy otherwise it's empty... .

probably you have further hints

regarding the links - I've read them all, since I'm following the topic since TMFT started his first indicator search on that.

thanks
askerix

Reply With Quote
  #18 (permalink)
 tony2604 
Europe
 
Experience: Intermediate
Platform: NinjaTrader, CQG Trader
Broker: Mirus
Trading: currency futures, forex
Posts: 79 since Apr 2010
Thanks Given: 39
Thanks Received: 42

Hello,

thanks for sharing this. But I´ve got a problem. When I add this to the OnBarUpdate and when I want to enable my strategy after checking/enabling its immediately again unchecked and disabled.

Did you change or add anything else too?

Thanks
Tony



nailz420 View Post
Hi,

I found how to make enable chart trade while running a strategy on the chart. I put this code in the OnBarUpdate method:
 
Code
        ChartControl.ChartTraderEnabled = true;
	ChartControl.Controls["pnlChartTrader"].Enabled = true;
	ChartControl.Controls["pnlChartTrader"].Visible = true;	
	ChartControl.Controls["pnlChartTrader"].Controls["ctrChartTraderControl"].Enabled = true;
	ChartControl.Controls["pnlChartTrader"].Controls["ctrChartTraderControl"].Visible = true;
This code opens the chart trader panel and allows you to place orders and shows the current pnl. However it does not enable to context menu order placement options or the on-chart order and avg price markers. Any idea how that can be enabled as well?

Thanks,
Tim


Reply With Quote
  #19 (permalink)
 TradeGamer 
Germany
 
Experience: Beginner
Platform: NinjaTrader
Trading: Futures
Posts: 15 since Jan 2013
Thanks Given: 4
Thanks Received: 1

Why NinjaTrader doesn´t allowed to use both? ChartTrader and Strategy together?
What was the intention to avoid the simultaneously usage?

Some people need the strategy calculations to obtain signals and the chart trader to execute them.

Reply With Quote




Last Updated on March 27, 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