Profile Picture

StopLoss in the same bar?

Posted By pavan074 4 Years Ago
Message
Posted Thursday January 03 2013
I've read other posts but i don't understend yet! Sorry...

I'm trying to execute the StopLoss in the same bar where I've an OpenPosition (MarketOnOpen).
But the stop loss will only work in the next bar or at the end of the same bar (if close < stoploss i image).
How can i obtain the stop loss in the same bar where i open a position?
Here's the settings of my OpenPosition:

PositionSettings settings = new PositionSettings();      
      settings.OrderType = OrderType.MarketOnOpen;
      settings.PositionType = PositionType.Long;      
      settings.Size = 0;   
      settings.StopLoss = this.Low.Current;
      settings.StopLossType = TargetPriceType.AbsolutePrice;


OpenPosition(settings );


Thank you very mutch.

Massimo
phg
Supreme Being (46,735 reputation)Supreme Being (46,735 reputation)Supreme Being (46,735 reputation)Supreme Being (46,735 reputation)Supreme Being (46,735 reputation)Supreme Being (46,735 reputation)Supreme Being (46,735 reputation)Supreme Being (46,735 reputation)Supreme Being (46,735 reputation)
Posted Thursday January 03 2013
If your code is operating under 'New Bar' theoretically all trading is completed for that bar by the time your code receives control. New orders can only be acted upon in the context of subsequent bars. Your questions suggest you are interested in finer control. You should study more closely the facilities RE provides for handling tiks (ticks). There is an event for handling tiks and RE will even generate tiks from historical bars if you wish. Handling tiks is more realistic as this is the level at which fills occur in a live account. I recommend studing the documentation in this regard and reviewing some of the sample strategies provided when RE is installed.

-Pete

See also Yahoo group about applying RE.

Posted Friday January 04 2013
I'm very sorry Pete but i don't understand.
I've open a long position in NewBar() method, infact in the next bar RE open a long position as you can see in the picture below.
In the settings of open position i've set the stop loss too, but it seems to ignore the stop loss and close the position on close prise (in other example if close>stoploss it close next bar as you know).
I need it close on stop loss price and in the same bar where i've opened long position.
Why i've to use tick timeframe?

[url=http://www.bgbweston.com/img/StopLoss.jpg][/url]


Thank you for your efforts.

Massimo
phg
Supreme Being (46,735 reputation)Supreme Being (46,735 reputation)Supreme Being (46,735 reputation)Supreme Being (46,735 reputation)Supreme Being (46,735 reputation)Supreme Being (46,735 reputation)Supreme Being (46,735 reputation)Supreme Being (46,735 reputation)Supreme Being (46,735 reputation)
Posted Saturday January 05 2013
Massimo,

This would work as you expect, mostly, in real trading. It will never work in simulation entirely right. That is partly because of some limitations of simulators and partly because the nature of the data the simulator is given.

RE works with events. 'New Bar' is an event but not fine-grained enough for the two (sequential) actions you want (actually 3 since there is a fill that must occur). A bar is made up of many ticks, and thus many events (sequentially), and so RE can process several actions within one bar. That's what you want. However, if your data feed is bars and RE is 'generating' ticks from bars, you still will not see quite the behavior you want. But you will be closer.

Things will work better when you move to ticks. Your understanding of the sequence of events will be much better if you include "OutputMessage" liberally in your code.

-Pete

See also Yahoo group about applying RE.



Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems