Basically what I’m trying to do is: If the current price goes above the previous bar’s high, then I want to want to place a buyLmt order at the previous bars High -5 Ticks; a buy a breakout on retracement strategy.
If someone can point out why the code below isn’t working, what I need to change or an alternative method of doing this I’d really appreciate it!
My code, error messages, & logs are below:
#region Variables
// Wizard generated variables
privateint lLmtTs = -5; // Default setting for LLmtTs
If conditions x y & z are met:
{
EnterLongStopLimit(DefaultQuantity, High[0] + LLmtTs * TickSize, High[0] + 1 * TickSize, "Enter Long on lmt ");
}
In Replay when the conditions are met I immediately get the following messages:
1) Strategy submitted an order that generated the following error ‘OrderRejected’. Strategy has sent cancel requests, attemted to close the position and terminated itself.
2) Limit price can’t be smaller than stop price. Affected Order: Buy 1 StopLimit @ 1215.5 x 1214
The log leading up to is as follows:
-3/21/2009 8:45:18 PM Default Simulation account 'Replay101' reset
-3/21/2009 8:45:22 PM Strategy Starting NinjaScript strategy 'RHK101fb/6c2a19cf42ee4b7197de2cd8fe4c1df0' : On starting a real-time strategy - StrategySync=SubmitLive EntryHandling=AllEntries EntriesPerDirection=1 StopTargetHandling=PerEntryExecution ErrorHandling=StopStrategyCancelOrdersClosePositio ns ExitOnClose=True/ triggering 60 before close Set order quantity by=Strategy
-3/21/2009 8:45:46 PM Order Order='231fc130099a4622b831286ea0913a1e/Replay101' Name='Enter Long on lmt ' New State=Rejected Instrument='NQ 06-09' Action=Buy Limit price=1214 Stop price=1215.5 Quantity=1 Type=StopLimit Filled=0 Fill price=0 Error=OrderRejected Native error='Limit price can't be smaller than stop price.'
-3/21/2009 8:45:46 PM Order Limit price can't be smaller than stop price. Affected Order: Buy 1 StopLimit @ 1215.5 x 1214
-3/21/2009 8:45:46 PM Strategy Strategy 'RHK101fb' submitted an order that generated the following error 'OrderRejected'. Strategy has sent cancel requests, attempted to close the position and terminated itself.
Comment