I have been working on a custom strategy for a few months now and need help from the experts.
Lets assume I want to place orders when the market price hits $.50 increments from the open market price. My strategy is a simple over/under that follows the Bars.Close() and reverses when those numbers are reached. I set limit orders and a stop order at each increment.
The only hurdle I have left is tracking my market position. I need my signal to wait for the market position to change (from one of the limit orders I placed), before it moves on and places new limit orders. Right now, there are instances when multiple criteria are met, and each places its own limit orders, which results in a new order being submitted and completed each bar.
I have tried the Trademanager example from the forums, but I believe it was either over my head, or if I was using it correctly, then it did not work for me.
I have used Environment.CalcReason, CalculationReason.MarketPositionChange, but recently found out it does not work with backtesting. Playback is a great tool, but much too slow.
I have also used a changing variable such as: (credit to Jos from Tradingcode.net for the idea)
Code: Select all
currentMP = StrategyInfo.MarketPosition
if(currentMP != prevMP){
code...
}
prevMP = currentMP
I have also tried to trap the code in a while loop such as:
Code: Select all
while(StrategyInfo.MarketPosition > 0)
{
output.writeline(example);
}
I am looking for a different way to go about this, or perhaps a better understanding of some of these strategies. Is there something in MC.net I have overlooked? Does anyone have any advice?
I will gladly provide more information if it makes things clearer.
Thank you