NexusFi: Find Your Edge


Home Menu

 





NT-script limit and stop entries


Discussion in NinjaTrader

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




 
Search this Thread

NT-script limit and stop entries

  #1 (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,

I want to ask about ideas how to do limit and stop entries in NinjaTrader when you work with NT Script Strategies. When one wants to run the script-strategy but to do the entry with a limit or stop price there must be a better solution than to edit the NT-script to write in the code the limit or stop price (that will often be a problem to do also during daytrading).

Thanks and best regards
Tony

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Are there any eval firms that allow you to sink to your …
Traders Hideout
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
ZombieSqueeze
Platforms and Indicators
Better Renko Gaps
The Elite Circle
 
  #2 (permalink)
 terratec 
Zurich Switzerland
 
Experience: Intermediate
Platform: NinjaTrader
Broker: IB
Trading: ES, 6E, CL
Posts: 403 since Sep 2009
Thanks Given: 64
Thanks Received: 515


tony2604 View Post
Hello,

I want to ask about ideas how to do limit and stop entries in NinjaTrader when you work with NT Script Strategies. When one wants to run the script-strategy but to do the entry with a limit or stop price there must be a better solution than to edit the NT-script to write in the code the limit or stop price (that will often be a problem to do also during daytrading).

Thanks and best regards
Tony

I don't know whether I see the point or not...

To switch from limit to stop, you could use a button.

This example is not a strategy, but it is the same. Have a look at the code. You chose the order type by button, then...:


 
Code
                                        if (btnType.Text == "STOP")
					{
						if (target1>entrylong && entrylong*TickSize>=GetCurrentAsk()) //long
						{
							Order o = a.CreateOrder(Instrument,OrderAction.Buy,OrderType.Stop,TimeInForce.Day,totSize,0,entrylong*TickSize,"","Buy"); o.Submit();
							entryshort=0;
						}
						else if (target1<entryshort && entryshort*TickSize<=GetCurrentBid()) //short
						{
							Order o = a.CreateOrder(Instrument,OrderAction.Sell,OrderType.Stop,TimeInForce.Day,totSize,0,entryshort*TickSize,"","Sell"); o.Submit();
							entrylong=0;
						}
					}
					else if (btnType.Text == "LIM")
					{
						if (target1>entrylong && entrylong*TickSize<=GetCurrentBid()) //long
						{
							Order o = a.CreateOrder(Instrument,OrderAction.Buy,OrderType.Limit,TimeInForce.Day,totSize,entrylong*TickSize,0,"","Buy"); o.Submit();
							entryshort=0;
						}
						else if (target1<entryshort && entryshort*TickSize>=GetCurrentAsk()) //short
						{
							Order o = a.CreateOrder(Instrument,OrderAction.Sell,OrderType.Limit,TimeInForce.Day,totSize,entryshort*TickSize,0,"","Sell"); o.Submit();
							entrylong=0;
						}
					}

Reply With Quote
Thanked by:
  #3 (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


Thank you for your reply.

How do you access the value? Markets are moving up you think for a limit-sell at a certain value at this moment of time. How do you "feed" the strategy with this value, which will be done as limit-order and then working within the NT-script?

Thanks
Tony



terratec View Post
I don't know whether I see the point or not...

To switch from limit to stop, you could use a button.

This example is not a strategy, but it is the same. Have a look at the code. You chose the order type by button, then...:


 
Code
                                        if (btnType.Text == "STOP")
					{
						if (target1>entrylong && entrylong*TickSize>=GetCurrentAsk()) //long
						{
							Order o = a.CreateOrder(Instrument,OrderAction.Buy,OrderType.Stop,TimeInForce.Day,totSize,0,entrylong*TickSize,"","Buy"); o.Submit();
							entryshort=0;
						}
						else if (target1<entryshort && entryshort*TickSize<=GetCurrentBid()) //short
						{
							Order o = a.CreateOrder(Instrument,OrderAction.Sell,OrderType.Stop,TimeInForce.Day,totSize,0,entryshort*TickSize,"","Sell"); o.Submit();
							entrylong=0;
						}
					}
					else if (btnType.Text == "LIM")
					{
						if (target1>entrylong && entrylong*TickSize<=GetCurrentBid()) //long
						{
							Order o = a.CreateOrder(Instrument,OrderAction.Buy,OrderType.Limit,TimeInForce.Day,totSize,entrylong*TickSize,0,"","Buy"); o.Submit();
							entryshort=0;
						}
						else if (target1<entryshort && entryshort*TickSize>=GetCurrentAsk()) //short
						{
							Order o = a.CreateOrder(Instrument,OrderAction.Sell,OrderType.Limit,TimeInForce.Day,totSize,entryshort*TickSize,0,"","Sell"); o.Submit();
							entrylong=0;
						}
					}


Started this thread Reply With Quote
  #4 (permalink)
 terratec 
Zurich Switzerland
 
Experience: Intermediate
Platform: NinjaTrader
Broker: IB
Trading: ES, 6E, CL
Posts: 403 since Sep 2009
Thanks Given: 64
Thanks Received: 515


tony2604 View Post
How do you access the value? Markets are moving up you think for a limit-sell at a certain value at this moment of time. How do you "feed" the strategy with this value, which will be done as limit-order and then working within the NT-script?

I don't know which value you are talking about. Entry price? If so:
Have a look a the whole thread (the link I posted). Most of the time I use lines (with the mouse) to place entry stop and targets, and then when I am confident, press a trade button. This is working nice with Indicators, but not with strategies as this fast drawing lines do not work there.

But you can also use something like one tick above/below actual or last bar, as I did in the last example (bTPAM), which is the only one that is an indicator that gives the commands to a strategy. There is a description in the tread. There are many ways to Rome. And for the first indy you can find a video on how this stuff works.

In most of the indicators I used stuff that is not officially supported. Only use such things if you know what you are about to do...
But you can see the principles and then code it your way. Take it as an inspiration to do better things.

Reply With Quote
Thanked by:
  #5 (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,

thank you again for your reply. I think I understand the idea now how you do manage this. But I´m not a programmer, I can not realize as you do. Have to think how I could get this working for me.

Thanks again.
Tony


terratec View Post
I don't know which value you are talking about. Entry price? If so:
Have a look a the whole thread (the link I posted). Most of the time I use lines (with the mouse) to place entry stop and targets, and then when I am confident, press a trade button. This is working nice with Indicators, but not with strategies as this fast drawing lines do not work there.

But you can also use something like one tick above/below actual or last bar, as I did in the last example (bTPAM), which is the only one that is an indicator that gives the commands to a strategy. There is a description in the tread. There are many ways to Rome. And for the first indy you can find a video on how this stuff works.

In most of the indicators I used stuff that is not officially supported. Only use such things if you know what you are about to do...
But you can see the principles and then code it your way. Take it as an inspiration to do better things.


Started this thread Reply With Quote




Last Updated on June 21, 2012


© 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