Active Trades List

Questions about MultiCharts .NET and user contributed studies.
User avatar
Analyst
Posts: 19
Joined: 09 Jul 2013
Has thanked: 3 times
Been thanked: 2 times

Active Trades List

Postby Analyst » 25 Jul 2013

I wanted a way to manage exits from a number of trades entered via the same order object, so I coded my own active trades queue. PL.NET seems to exit all trades at once, if they come from the same IOrderMarket object. There is probably an approved technique for this, or you may use mine:

Code: Select all

public class Entry
{
public Entry(int Bar, int Lots, bool Long)
{
this.Bar = Bar;
this.Lots = Lots;
this.Long = Long;
}
public int Bar;
public int Lots;
public bool Long;
}
private Queue<Entry> entries;
private Entry temp;
Queue is great for this, because it implements FIFO methods. Obviously, you can add whatever you like to my Entry class. Every time you place an order, make an Entry object and place it on the queue:

Code: Select all

RankDV_LE.Send();
temp = new Entry(Bars.CurrentBar, 100 * (int)Math.Truncate(dollars / Bars.Close[0] / 100), true);
entries.Enqueue(temp);
You could create the Entry right on the queue. I use “temp” so I can see its attributes in the debugger. When it’s time to exit, you remove the oldest Entry from the queue:

Code: Select all

temp = entries.Dequeue();
RankDV_LX.Send(temp.Lots);
Dequeue reads and removes the first Entry. When you are out of all trades, the queue is empty.

Return to “MultiCharts .NET”