I'm trying to create an order to enter long at the high of the previous bar if the previous bar was green. I do want to enter exactly at the previous bar's high though and so I thought I could do this using code such as this:
I tried 2 variations:
1. double entryPrice = Math.Min(High[1], GetCurrentAsk());
EnterLongStop(2, entryPrice, "GreenRatReversal");
2. double entryPrice = Math.Min(High[1], GetCurrentAsk());
EnterLongStopLimit(0, true, 2, entryPrice, (entryPrice - TickSize * 10), "GreenRatReversal");
However, both these orders seem to get canceled or rejected immediately. I also get errors such as:
2010-03-22 01:20:45:648 ERROR: A Buy order placed at '3/10/2010 4:00:00 AM' has been ignored since the stop price is less than or equal to the close price of the current bar. This is an invalid order and subsequent orders may also be ignored. Please fix your strategy.
OR
2010-03-22 01:24:09:807 (AMPforex) Cbi.OrderStatusEventArgs.Process: Order='eca9b52de8464e0db5cf82c886eb33e6/Sim101' Name='GreenRatReversal' New State=Rejected Instrument='$AUDJPY' Action=Buy Limit price=0 Stop price=82.62 Quantity=2 Type=Stop Filled=0 Fill price=0 Error=OrderRejected Native error='Buy stop or buy stop limit orders can't be placed below the market.'
2010-03-22 01:24:09:854 Strategy.StrategyBase.Process.CancelOrdersClosePos itions1: Order='1c92fb18a78f4b718632cbdfbec92c2c/Sim101' Name='GreenRatReversal' State=Rejected Instrument='$AUDJPY' Action=Buy Limit price=0 Stop price=82.62 Quantity=2 Strategy='TradeLikeARat' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='eca9b52de8464e0db5cf82c886eb33e6' Gtd='12/1/2099 12:00:00 AM'
2010-03-22 01:24:09:854 Strategy.StrategyBase.Process.CancelOrdersClosePos itions2: isTerminal=False
I somewhat understand these errors, but I'm not sure how I could change my implementation to avoid them. I would really appreciate some pointers.
Thanks,
N


Comment