limit order problem if not based on main series

Questions about MultiCharts .NET and user contributed studies.
Ram
Posts: 90
Joined: 25 Nov 2014
Has thanked: 17 times
Been thanked: 5 times

limit order problem if not based on main series

Postby Ram » 03 Mar 2015

Hi,

EDIT: My data series' are based on IQFeed and my broker is IB

I have a problem when sending limit orders based on any series price that is not the main series just doesnt work..

For example, a workspace has two data series:
Image

Code example, Whenever the counter hit 60 it sends a limit order and moves it on every tick until the counter hit 120 and then all over again:

Code: Select all

Imports System
Imports System.Drawing
Imports System.Linq
Imports PowerLanguage
Imports PowerLanguage.Function
Imports PowerLanguage.Strategy
Imports ATCenterProxy.interop

Namespace PowerLanguage.Strategy
<IOGMode(IOGMode.Enabled)> <AllowSendOrdersAlways(True)> _
Public Class Ram_Temp
Inherits SignalObject

Public Sub New(ByVal _ctx As Object)
MyBase.New(_ctx)
End Sub

Private i as Integer
Private Buy_Lmt As IOrderPriced

Protected Overrides Sub CalcBar()
'run only at last bar
If Bars.LastBarOnChart Then
i = i+1
Output.WriteLine("Counter: " & i)
if i > 60 AndAlso i < 120 then
'Output.WriteLine(BarsOfData(2).Close(0) - 10)
Buy_Lmt.Send(BarsOfData(1).Close(0) - 10)
'Buy_Lmt.Send(BarsOfData(2).Close(0) - 10)
End If

If i > 120 then i = 0

End if
End Sub

Protected Overrides Sub Create()
Buy_Lmt = OrderCreator.Limit(new SOrderParameters(Contracts.Default, "Long Lmt", EOrderAction.Buy))
End Sub

Protected Overrides Sub StartCalc()
End Sub

End Class
End Namespace
It works well as long the the code is:

Code: Select all

Buy_Lmt.Send(BarsOfData(1).Close(0) - 10)
'Buy_Lmt.Send(BarsOfData(2).Close(0) - 10)
however, if ill change the order to be based on series 2 no order will be sent:

Code: Select all

'Buy_Lmt.Send(BarsOfData(1).Close(0) - 10)
Buy_Lmt.Send(BarsOfData(2).Close(0) - 10)
Even more than the above, if I try to restore to series 1 and only READ from data series 2 it doesn't work as well:

Code: Select all

Output.WriteLine(BarsOfData(2).Close(0) - 10)
Buy_Lmt.Send(BarsOfData(1).Close(0) - 10)
'Buy_Lmt.Send(BarsOfData(2).Close(0) - 10)
Please advice what is it I'm doing wrong here..
Thx much!
Best,
R.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: limit order problem if not based on main series

Postby Henry MultiСharts » 20 Mar 2015

Hello Ram,

Please make sure the Realtime-history matching option is disabled.


Return to “MultiCharts .NET”