PDA

View Full Version : why didn't this code work


HelloHello
08-28-2007, 10:12 AM
if NTMarketPosition("Uxxxxx") = 0 then
buy this bar on close;

NinjaTrader_Josh
08-28-2007, 10:18 AM
if NTMarketPosition("Uxxxxx") = 0 then begin
//buy this bar on close;

HelloHello
08-28-2007, 11:44 AM
thank you for your reply Josh, however I'm confused as to how I would enter an order then

if this is correct:
if NTMarketPosition("Uxxxxx") = 0 then begin
//buy this bar on close;

then would this work...
if NTMarketPosition("Uxxxxx") = 0 then
begin
if condition1 then
buy this bar on close;
end

2) Also, using the following functions that are in the NT DLL, will you get tradestation to successfully backtest it. Say that the following code

if condition1 then
buy this bar on close

if barssinceentry = 5 then
sell this bar on close
* say that the above code produces 50 trades on a tradestation backtest

now
if NTMarketPosition("Uxxxxx") = 0 then
begin
if condition1 then
buy this bar on close;
end

if NTMarketPosition("Uxxxxx") > 0 then
begin
if barssinceentry = 5 then
sell this bar on close;
end
?? would you get the 50 trades to show up on the tradestation backtest?

NinjaTrader_Josh
08-28-2007, 11:58 AM
1) buy this bar on close is not really code. To place orders you need to program the logic to send the order at the bar close and then you would use NTBuyMarket or any of the other functions listed here: http://www.ninjatrader-support.com/HelpGuideV6/helpguide.html?Functions.

if NTMarketPosition("Uxxxxx") = 0 then
begin
if condition1 then
buy this bar on close;
endYou would need two "end" to close both if statements.

2) Unfortunately I cannot provide guidance on TradeStation's backtesting, but I would assume the codes will work theoretically. Perhaps this sample code (http://www.ninjatrader-support.com/HelpGuideV6/helpguide.html?SanpleStrategy) will help you in programming ELDs that use NinjaTrader in TradeStation.

HelloHello
08-28-2007, 12:03 PM
ah,

that answers it perfectly. thank you very much