Profile Picture

Stop and Reverse Sample

Posted By kaizen 8 Years Ago
Message
Posted Saturday July 11 2009
Do you have a stop and reverse sample system somewhere?

I had a look in the sample directory and could not see one.

I 'think' I have it working correctly but want to check if I have done it how you would have done it or there is a better way.


Posted Sunday July 12 2009
There is one in the trading systems section of the web site. You can download it from here.

kaizen (7/11/2009)
Do you have a stop and reverse sample system somewhere?

I had a look in the sample directory and could not see one.

I 'think' I have it working correctly but want to check if I have done it how you would have done it or there is a better way.
Posted Sunday July 12 2009
Also note that it is out of date so it will need to be modified to work with the current version of RightEdge. But it should be a good reference, and if you need help feel free to ask us.

Thanks,
Daniel
Posted Saturday July 18 2009
I had a play with this and had no luck getting it to convert to the current version (1or2)

Are you able to have a look and if possible convert to RE ED 1? From there I can convert to ED 2.

Thanks.


Posted Sunday July 19 2009
I posted a new Stop and Reverse trading system to the trading systems section.
Posted Sunday July 19 2009
Using RE V2 Beta build 12.

I get this error: Any ideas?


RightEdge.Common.PluginException: The service plugin PaperBroker.PaperTrader threw an exception of type RightEdge.Common.RightEdgeError ---> RightEdge.Common.RightEdgeError: Unknown target price type: -1 ---> RightEdge.Common.RightEdgeError: Unknown target price type: -1
at RightEdge.Common.PositionManager.CreateSpecialOrder(PositionData pos, TradeType type)
at RightEdge.Common.PositionManager.UpdateSpecialOrder(PositionData pos, TradeType type)
at RightEdge.Common.PositionManager.SetProfitTarget(String PosID, Double target, TargetPriceType targetType)
at SystemMain.PositionReversed(Object sender, PositionOverfilledEventArgs e) in C:\Documents and Settings\jramsay\Desktop\StopAndReverse.vb:line 28
at RightEdge.Common.PositionManager.HandlePositionOverfilled(PositionData pos, PositionState posState, BrokerOrder order, Fill fill, TradeType tradeType, String description)
at RightEdge.Common.PositionManager.PositionOrderFilled(PositionData pos, PositionState posState, BrokerOrder order, Fill fill, TradeType tradeType, String description, Boolean sendUpdate)
at RightEdge.Common.PositionManager.OnOrderFilled(BrokerOrder order, Fill fill, PositionData pos, PositionState posState, TradeOrder tradeOrder)
at RightEdge.Common.PositionManager.broker_OrderUpdated(BrokerOrder brokerOrder, Fill fill, String information)
at RightEdge.Shared.BrokerWrapper.<>c__DisplayClass3.b__0(Object )
at RightEdge.Shared.CallbackStub.DoCallback()
--- End of inner exception stack trace ---
at RightEdge.Shared.SystemWrapper.b__0(Object sender, ExceptionEventArgs args)
at RightEdge.Shared.CallbackStub.DoCallback()
at RightEdge.Shared.MarshalledSynchronizationContext.Post(SendOrPostCallback d, Object state)
at RightEdge.Shared.BrokerWrapper.broker_orderUpdated(BrokerOrder order, Fill fill, String information)
at PaperBroker.PaperTrader.OnOrderUpdated(BrokerOrder order, Fill fill, String information)
at PaperBroker.PaperTrader.ProcessOrder(BrokerOrder order, Double bidPrice, Double askPrice, DateTime tickTime, Boolean bGap, Boolean bClose)
at PaperBroker.PaperTrader.SimTick(Symbol symbol, TickData tick)
at RightEdge.Shared.BrokerWrapper.SimTick(Symbol symbol, TickData tick)
--- End of inner exception stack trace ---
at RightEdge.Shared.ServiceWrapper.DoError(Exception e)
at RightEdge.Shared.BrokerWrapper.SimTick(Symbol symbol, TickData tick)
at RightEdge.Common.Internal.SystemRunner.ProcessTickInPaperBroker(Symbol symbol, TickData tick)
at RightEdge.Common.FrequencyManager.x3fd1cdb5e353e534()
at RightEdge.Common.FrequencyManager.xfc18b789d02886f4(DateTime xb21f13a9707ad954)
at RightEdge.Common.FrequencyManager.ProcessTick(Symbol symbol, TickData tick)
at RightEdge.Common.Internal.SystemRunner._tickGenerator_NewTick(Object sender, NewTickEventArgs e)
at RightEdge.Common.TickGenerator.ProcessBar(NewBarEventArgs args)
at RightEdge.Common.Internal.SystemRunner.ProcessBar(NewBarEventArgs newBars)
at RightEdge.Shared.SystemWrapper.RunSystem(SystemData systemData, SystemRunData runData, ServiceFactory brokerFactory)
at RightEdge.Shared.SystemWrapper.RunSystem(DateTime start, String filename, ServiceFactory brokerFactory, PluginReference dataStore)
at RightEdge.Shared.SystemWrapper.RunSystem(DateTime start, String filename, ServiceFactory brokerFactory, PluginReference dataStore)
at RightEdge.Shared.TradingModuleWrapper.RunSystem(SystemRunData systemRunData, ServiceAppDomainFactory brokerFactoryFactory, PluginReference dataStore)
at RightEdge.SystemProgress.InitAndRunSystem()



Also
Dim pending As List(Of Position) = PositionManager.GetPendingPositions()

Needs to be updated to:
Dim pending As IList(Of Position) = PositionManager.GetPendingPositions()


Posted Monday July 20 2009
Ya, check the value of the target value before it goes to SetProfitTarget. For some reason it's -1, which is invalid. The previous versions of RE may not have checked for this. I would say if it's -1 and there's a good reason for it (i.e. it couldn't be calculated at this time), to put an 'if' around it.

kaizen (7/19/2009)
Using RE V2 Beta build 12.

I get this error: Any ideas?


RightEdge.Common.PluginException: The service plugin PaperBroker.PaperTrader threw an exception of type RightEdge.Common.RightEdgeError ---> RightEdge.Common.RightEdgeError: Unknown target price type: -1 ---> RightEdge.Common.RightEdgeError: Unknown target price type: -1
at RightEdge.Common.PositionManager.CreateSpecialOrder(PositionData pos, TradeType type)
at RightEdge.Common.PositionManager.UpdateSpecialOrder(PositionData pos, TradeType type)
at RightEdge.Common.PositionManager.SetProfitTarget(String PosID, Double target, TargetPriceType targetType)
at SystemMain.PositionReversed(Object sender, PositionOverfilledEventArgs e) in C:\Documents and Settings\jramsay\Desktop\StopAndReverse.vb:line 28
at RightEdge.Common.PositionManager.HandlePositionOverfilled(PositionData pos, PositionState posState, BrokerOrder order, Fill fill, TradeType tradeType, String description)
at RightEdge.Common.PositionManager.PositionOrderFilled(PositionData pos, PositionState posState, BrokerOrder order, Fill fill, TradeType tradeType, String description, Boolean sendUpdate)
at RightEdge.Common.PositionManager.OnOrderFilled(BrokerOrder order, Fill fill, PositionData pos, PositionState posState, TradeOrder tradeOrder)
at RightEdge.Common.PositionManager.broker_OrderUpdated(BrokerOrder brokerOrder, Fill fill, String information)
at RightEdge.Shared.BrokerWrapper.<>c__DisplayClass3.b__0(Object )
at RightEdge.Shared.CallbackStub.DoCallback()
--- End of inner exception stack trace ---
at RightEdge.Shared.SystemWrapper.b__0(Object sender, ExceptionEventArgs args)
at RightEdge.Shared.CallbackStub.DoCallback()
at RightEdge.Shared.MarshalledSynchronizationContext.Post(SendOrPostCallback d, Object state)
at RightEdge.Shared.BrokerWrapper.broker_orderUpdated(BrokerOrder order, Fill fill, String information)
at PaperBroker.PaperTrader.OnOrderUpdated(BrokerOrder order, Fill fill, String information)
at PaperBroker.PaperTrader.ProcessOrder(BrokerOrder order, Double bidPrice, Double askPrice, DateTime tickTime, Boolean bGap, Boolean bClose)
at PaperBroker.PaperTrader.SimTick(Symbol symbol, TickData tick)
at RightEdge.Shared.BrokerWrapper.SimTick(Symbol symbol, TickData tick)
--- End of inner exception stack trace ---
at RightEdge.Shared.ServiceWrapper.DoError(Exception e)
at RightEdge.Shared.BrokerWrapper.SimTick(Symbol symbol, TickData tick)
at RightEdge.Common.Internal.SystemRunner.ProcessTickInPaperBroker(Symbol symbol, TickData tick)
at RightEdge.Common.FrequencyManager.x3fd1cdb5e353e534()
at RightEdge.Common.FrequencyManager.xfc18b789d02886f4(DateTime xb21f13a9707ad954)
at RightEdge.Common.FrequencyManager.ProcessTick(Symbol symbol, TickData tick)
at RightEdge.Common.Internal.SystemRunner._tickGenerator_NewTick(Object sender, NewTickEventArgs e)
at RightEdge.Common.TickGenerator.ProcessBar(NewBarEventArgs args)
at RightEdge.Common.Internal.SystemRunner.ProcessBar(NewBarEventArgs newBars)
at RightEdge.Shared.SystemWrapper.RunSystem(SystemData systemData, SystemRunData runData, ServiceFactory brokerFactory)
at RightEdge.Shared.SystemWrapper.RunSystem(DateTime start, String filename, ServiceFactory brokerFactory, PluginReference dataStore)
at RightEdge.Shared.SystemWrapper.RunSystem(DateTime start, String filename, ServiceFactory brokerFactory, PluginReference dataStore)
at RightEdge.Shared.TradingModuleWrapper.RunSystem(SystemRunData systemRunData, ServiceAppDomainFactory brokerFactoryFactory, PluginReference dataStore)
at RightEdge.SystemProgress.InitAndRunSystem()



Also
Dim pending As List(Of Position) = PositionManager.GetPendingPositions()

Needs to be updated to:
Dim pending As IList(Of Position) = PositionManager.GetPendingPositions()
Posted Friday August 14 2009
Updated S and R system attached.

I finally had time to have a look and figured out why it never worked. Mine or yours. We need to set myOrder.BarsValid = -1; The orders were being canceled after each bar so it never hit the stop order... Easy once I figured it out but not so obvious at first.

And PositionManager.SetProfitTarget(e.OpenedPosition.ID, PositionManager.ProfitTarget, TargetPriceType.Price); had to be up updated to fix the error above.





Attachments
Stop and Reverse.cs (315 views, 4.00 KB)


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems