![]() |
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Junior Member
Join Date: May 2009
Posts: 14
Thanks: 0
Thanked 0 times in 0 posts
|
Hi,
I'm having a very simple scalping strategy and on signal I execute the following code: Code:
EnterShort(Lot,"LNG");
SetProfitTarget("LNG", CalculationMode.Ticks, TakeProfit*TickSize);
SetStopLoss("LNG", CalculationMode.Ticks, StopLoss*TickSize, true);
Here is the trace: 7/8/2011 2:29:47 PM Entered internal PlaceOrder() method at 7/8/2011 2:29:47 PM: BarsInProgress=1 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='SHRT' FromEntrySignal='' 7/8/2011 2:29:47 PM Entered internal SetStopTarget() method: Type=Target FromEntrySignal='SHRT' Mode=Ticks Value=0.0002 Currency=0 Simulated=False 7/8/2011 2:29:47 PM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='SHRT' Mode=Ticks Value=0.0004 Currency=0 Simulated=True 7/8/2011 2:29:47 PM Cancelled pending exit order, since associated position is closed: Order='NT-00002/Backtest' Name='Profit target' State=Working Instrument='6E 09-11' Action=Sell Limit price=1.4219 Stop price=0 Quantity=1 Strategy='Scalper' Type=Limit Tif=Gtc Oco='NT-00000-454' Filled=0 Fill price=0 Token='9a318e0d13624113b97b6b85c9bb479a' Gtd='12/1/2099 12:00:00 AM' 7/8/2011 2:29:47 PM Cancelled OCO paired order: BarsInProgress=0: Order='NT-00002/Backtest' Name='Profit target' State=Cancelled Instrument='6E 09-11' Action=Sell Limit price=1.4219 Stop price=0 Quantity=1 Strategy='Scalper' Type=Limit Tif=Gtc Oco='NT-00000-454' Filled=0 Fill price=0 Token='9a318e0d13624113b97b6b85c9bb479a' Gtd='12/1/2099 12:00:00 AM' 7/8/2011 2:30:00 PM Entered internal PlaceOrder() method at 7/8/2011 2:30:00 PM: BarsInProgress=1 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='LNG' FromEntrySignal='' 7/8/2011 2:30:00 PM Entered internal SetStopTarget() method: Type=Target FromEntrySignal='LNG' Mode=Ticks Value=0.0002 Currency=0 Simulated=False 7/8/2011 2:30:00 PM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='LNG' Mode=Ticks Value=0.0004 Currency=0 Simulated=True 7/8/2011 2:30:00 PM Cancelled pending exit order, since associated position is closed: Order='NT-00005/Backtest' Name='Profit target' State=Working Instrument='6E 09-11' Action=BuyToCover Limit price=1.4229 Stop price=0 Quantity=1 Strategy='Scalper' Type=Limit Tif=Gtc Oco='NT-00002-454' Filled=0 Fill price=0 Token='ce2a098eb5d547728e0037ad1b784226' Gtd='12/1/2099 12:00:00 AM' 7/8/2011 2:30:00 PM Cancelled OCO paired order: BarsInProgress=0: Order='NT-00005/Backtest' Name='Profit target' State=Cancelled Instrument='6E 09-11' Action=BuyToCover Limit price=1.4229 Stop price=0 Quantity=1 Strategy='Scalper' Type=Limit Tif=Gtc Oco='NT-00002-454' Filled=0 Fill price=0 Token='ce2a098eb5d547728e0037ad1b784226' Gtd='12/1/2099 12:00:00 AM' Anyone could help me please? |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 90 times in 82 posts
|
svlad, what values are you using for TakeProfit and StopLoss?
Austin
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: May 2009
Posts: 14
Thanks: 0
Thanked 0 times in 0 posts
|
Takeprofit - 2 and stoploss - 4. you can see it from traces.
but it closes exactly at opening price, so Profit is always 0 |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 90 times in 82 posts
|
Thanks, svlad. What sort of timeframe are you running this on? If an order is filled in the backtester and the bar is taller than the stop/target, the stop/target will be executed immediately on that bar.
Austin
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Junior Member
Join Date: May 2009
Posts: 14
Thanks: 0
Thanked 0 times in 0 posts
|
Im running this on 1Tick bars as the main DataSeries, so it shouldnt give this problem.
do you have any other ideas? |
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,569
Thanks: 262
Thanked 1,018 times in 999 posts
|
Do you set those stoplosses and targets from the Initialize() or OnBarUpdate()?
If OnBarUpdate() please try setting them before executing your entry and then recheck.
Bertrand
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| ATM StopLoss executed after session close | Camdo | Version 7 Beta General Questions & Bug Reports | 6 | 03-08-2010 01:53 PM |
| IB CL StopLoss not being executed | Bluepoint | Automated Trading | 1 | 02-02-2010 07:34 AM |
| How do I know when a stoploss was executed? | Beauregard | Strategy Development | 1 | 01-10-2010 10:44 AM |
| stoploss not executed | Beauregard | Strategy Analyzer | 2 | 01-03-2010 10:28 AM |
| Checking if Stoploss is executed? | darckeen | Strategy Development | 1 | 04-14-2009 04:39 AM |