PDA

View Full Version : Simulating TS entry / exits


mrlogik
09-28-2006, 03:13 AM
Ninjatrader.

Thanks for the reply. I don't always intend to use targets as exits. I have different indicators / criteria to exit based on market conditions. Can I just send an "EXIT" order for a certain quantity of the position?

Thanks, Anthony

//PREVIOUS PM

Anthony,

I would advise you to use the NT DLL interface for TradeStation. There are fuctions available for order placement such as NTSellLimit() that I would use for submitting the target orders. I would first of course submit your entry order, NTBuyMarket(), then once filled, check NTOrderStatus() or check for position NTMarketPosition(), then submit the targets. This is all documented here -

http://www.ninjatrader-support.com/HelpGuide/Functions.html

Please send follow up notes through the forum as I rarely check my forum mail.

Thanks.

Hey ninjatrader.

I'm interested in using NT5 to automate TS signals to my MB broker. In TS I currently have strategies which will simulate entrances and exits of multiple lots. For example, I have an entrance of 15 lots, and then I usually have 3 profit targets where I close out 5 lots each time a target is reached. Basically where I'm going with this is I understand how I have to enter the order through my EL code, but for exits I'm a little confused. I checked the documentation a few times and the forum with no luck.

Basically, my intentions are to have TS send the order entry, then send the exit orders (pyramiding out of the order, or all in one shot). All of the entrances / exit signals are computed 100% at TS, I simply need to send them to NT for procesing.

To make things easier on you in terms of explaining, I am a software engineer so I shouldn't have trouble understanding.

Thanks again for you help. I hope my explination is understandable, as I'm rushing this out at work.

Anthony

NinjaTrader_Ray
09-28-2006, 04:53 AM
Absolutely, just use any of the available functions from the DLL interface. Alternatively, if your TS strategy is already set up to enter and exit using native EL code, just use our mail based interface.

mrlogik
09-28-2006, 06:01 AM
ninja.

I've been looking through the function list and I don't see anything which explicitly talks of exits. I'm assuming that I would have to use NTCommand with the CLOSEPOSITION command, but the chart for appliciable fields has nothing for quantity. Can you give me the line of code I would use for this?

Thanks, Anthony

NinjaTrader_Ray
09-28-2006, 06:11 AM
Exit is relative.

Example purposes only:

variables: Success(0);

if Close > Open then
Success = NTBuyMarket("orderIdString", 1);

if NTMarketPosition("") > 0 then
Success = NTSellMarket("OrderIdString", 1); <----- Your exit order

mrlogik
09-28-2006, 06:39 AM
Ok, so let me get this straight...

//ENTER LONG

Success = NTBuyMarket("orderId", quantity);

//EXIT LONG

sucess = NTSellMarket("orderId", quantity);

//ENTER SHORT

sucess = NTSellMarket("orderId", quantity);

//EXIT SHORT

Success = NTBuyMarket("orderId", quantity);



Is that right? You just try to enter the opposite way?

TS has things like, buy, sell, buy to cover, etc...

Thanks.

NinjaTrader_Ray
09-28-2006, 07:07 AM
That is correct.