Theoretical Average Price of a Trade - need Help  [SOLVED]

Questions about MultiCharts and user contributed studies.
sptrader
Posts: 742
Joined: 09 Apr 2010
Location: Texas
Has thanked: 483 times
Been thanked: 274 times
Contact:

Theoretical Average Price of a Trade - need Help

Postby sptrader » 07 Jun 2018

Example Like this :
buy 1 at 100
buy 1 at 106
theoretical avg is 103
exit the 106 trade at 110 (+4 points profit reduces theoretical average entry price).
theoretical avg is 96 (trade at 106-4 pts profit = 102 and trade at 100-10 pts profit = 90 so (90+102)/2 = 96. Theoretical price to be plotted = 96.

I think this would be great to have it plotted on a chart with a dynamic line that shows the theoretical avg change as you trade. Right now I use MC's Chart Trader but it doesn't track the price change when profit is taken. (only the ave entry price).

Basically a Trade in, to trade out average price. (in real-time).

Has anyone tried to create this ? (or can get me started coding it).

Bookmap has this feature but I don't use Bookmap for Trading.

Jad
Posts: 92
Joined: 15 Jun 2014
Has thanked: 13 times
Been thanked: 21 times

Re: Theoretical Average Price of a Trade - need Help

Postby Jad » 08 Jun 2018

I'm not sure if I have fully understood you but if you're only interested in finding the 'average' of the open trades and then adjust that average if/when any of them are filled, then are you actually trying to establish the break-even price for those trades?

If so, then subtracting the profit/loss of the first fill from the remaining open trade's fill price will do that more simply.
e.g The 4 point profit of the filled trade subtracted from the 100 entry price of the remaining open trade also = 96.

If there is more than one open trade remaining, subtract the profit/ loss from the average entry price of those remaining open trades.

sptrader
Posts: 742
Joined: 09 Apr 2010
Location: Texas
Has thanked: 483 times
Been thanked: 274 times
Contact:

Re: Theoretical Average Price of a Trade - need Help

Postby sptrader » 08 Jun 2018

I'm not sure if I have fully understood you but if you're only interested in finding the 'average' of the open trades and then adjust that average if/when any of them are filled, then are you actually trying to establish the break-even price for those trades?

If so, then subtracting the profit/loss of the first fill from the remaining open trade's fill price will do that more simply.
e.g The 4 point profit of the filled trade subtracted from the 100 entry price of the remaining open trade also = 96.

If there is more than one open trade remaining, subtract the profit/ loss from the average entry price of those remaining open trades.
Yes, "I'm only interested in finding the 'average' of the open trades and then adjust that average if/when any of them are filled."
I'm trying to establish the break-even price for those trades, my reason for this is that I can adjust my stop to breakeven, after taking profit on part of my position.

I'm just not sure how to code it with the functions provided in MC, so that I can draw the breakeven price on MC, while using ChartTrader to enter and exit positions.

Jad
Posts: 92
Joined: 15 Jun 2014
Has thanked: 13 times
Been thanked: 21 times

Re: Theoretical Average Price of a Trade - need Help

Postby Jad » 08 Jun 2018

If you know the Fill prices when you enter and exit the trades (as per your example), then I don't see why you would need any special, MC provided functions.

Assuming EntryPrice1 = buy 1 @ 100 and EntryPrice2 = buy 1 @ 106

then (EntryPrice1 + EntryPrice2) / Number of Contracts will give you an initial average price plotted @ 103.

When one of the positions gets filled say, the trade which was entered @ 106 and exited @ 110 (ExitPrice2) then the new plot can be calculated as follows:

NewPlotValue = EntryPrice1 - (ExitPrice2 - EntryPrice2)

So, at that point, the values for the above will be.....
96 = 100 - ( 110 - 106 )
Last edited by Jad on 08 Jun 2018, edited 1 time in total.

sptrader
Posts: 742
Joined: 09 Apr 2010
Location: Texas
Has thanked: 483 times
Been thanked: 274 times
Contact:

Re: Theoretical Average Price of a Trade - need Help

Postby sptrader » 08 Jun 2018

If you know the Fill prices when you enter and exit the trades (as per your example), then I don't see why you would need any special, MC provided functions.

Assuming EntryPrice1 = buy 1 @ 100 and EntryPrice2 = buy 1 @ 106

then (EntryPrice1 + EntryPrice2) / Number of Contracts will give you an initial average price plotted @ 103.

When one of the positions gets filled say, the trade which was entered @ 106 and exited @ 110 (ExitPrice2) then the new plot can be calculated as follows:

NewPlotValue = EntryPrice1 - (ExitPrice2 - EntryPrice2)

So, at that point, the values for the above will be.....
96 = 100 - ( 110 - 106 )

I think you want me to manually enter all entry and exit prices, on a 5 or 10 lot that could get tedious in RT, I was hoping for an automated way.
That's why I thought it might take special functions or special programming to track each trade automatically. (BookMap does it automatically).
I could do it manually, if it's the only way. (would be easier to program it this way for sure).

Jad
Posts: 92
Joined: 15 Jun 2014
Has thanked: 13 times
Been thanked: 21 times

Re: Theoretical Average Price of a Trade - need Help

Postby Jad » 08 Jun 2018

Why do you think I'm asking you to enter anything manually?

The entry and exit prices are available to use in your code.

sptrader
Posts: 742
Joined: 09 Apr 2010
Location: Texas
Has thanked: 483 times
Been thanked: 274 times
Contact:

Re: Theoretical Average Price of a Trade - need Help

Postby sptrader » 08 Jun 2018

Why do you think I'm asking you to enter anything manually?

The entry and exit prices are available to use in your code.

I just tried a study (indicator) using "I_AvgEntryPrice" and "I_AvgEntryPrice_at_broker" and they don't output anything when used with ChartTrader and IB, with an open position. (Maybe I need different functions ?).

Jad
Posts: 92
Joined: 15 Jun 2014
Has thanked: 13 times
Been thanked: 21 times

Re: Theoretical Average Price of a Trade - need Help

Postby Jad » 08 Jun 2018

So, does your original question really relate to "How to get the actual entry and exit prices of trades"?

If so, then plugging that question into google followed by 'multicharts' would have pointed you in the right direction.

In particular, https://futures.io/easylanguage-program ... led-2.html provides information on how to do that from within indicators and/signals plus the requirements for using each option.

sptrader
Posts: 742
Joined: 09 Apr 2010
Location: Texas
Has thanked: 483 times
Been thanked: 274 times
Contact:

Re: Theoretical Average Price of a Trade - need Help

Postby sptrader » 08 Jun 2018

So, does your original question really relate to "How to get the actual entry and exit prices of trades"?

If so, then plugging that question into google followed by 'multicharts' would have pointed you in the right direction.

In particular, https://futures.io/easylanguage-program ... led-2.html provides information on how to do that from within indicators and/signals plus the requirements for using each option.
I'm having trouble getting the entry and exit prices of trades so I can create the ave trade price that I'm after.
If you notice the link you provided to the MC functions for trading entries and exits it says "This function can only be used in signals. ", I'm NOT using a signal, I'm using Chart Trader and manually trading.
I can't get the required entry and exit prices when using Chart Trader to build the theoretical ave price. The entry and exit functions don't seem to work with Chart Trader. (unless I'm doing something wrong).
The functions in MC that are used with signals don't seem to work when using Chart Trader, I don't know how to get around that.

Jad
Posts: 92
Joined: 15 Jun 2014
Has thanked: 13 times
Been thanked: 21 times

Re: Theoretical Average Price of a Trade - need Help

Postby Jad » 08 Jun 2018

If you notice the link you provided to the MC functions for trading entries and exits it says "This function can only be used in signals. ",
For I_AvgEntryPrice ??

I think you need to check again what it says
Last edited by Jad on 08 Jun 2018, edited 1 time in total.

sptrader
Posts: 742
Joined: 09 Apr 2010
Location: Texas
Has thanked: 483 times
Been thanked: 274 times
Contact:

Re: Theoretical Average Price of a Trade - need Help

Postby sptrader » 08 Jun 2018

If you notice the link you provided to the MC functions for trading entries and exits it says "This function can only be used in signals. ",
For I_AvgEntryPrice ??

I think you need to check again what says
I tried "I_AvgEntryPrice" and some other I_ functions designed for use with indicators but they don't seem to work with Chart Trader.

Jad
Posts: 92
Joined: 15 Jun 2014
Has thanked: 13 times
Been thanked: 21 times

Re: Theoretical Average Price of a Trade - need Help

Postby Jad » 08 Jun 2018

It's designed to work with studies and I thought you just wanted to plot a price level on a chart.

So, like any other plot, the value will be shown whether you're trading directly from a chart or not ..... but I think that's true only if you've satisfied ALL the conditions for its use as listed at that link.

sptrader
Posts: 742
Joined: 09 Apr 2010
Location: Texas
Has thanked: 483 times
Been thanked: 274 times
Contact:

Re: Theoretical Average Price of a Trade - need Help

Postby sptrader » 08 Jun 2018

It's designed to work with studies and I thought you just wanted to plot a price level on a chart.

So, like any other plot, the value will be shown whether you're trading directly from a chart or not ..... but I think that's true only if you've satisfied ALL the conditions for its use as listed at that link.
I DO want to plot a price level on the chart BUT the price level has to be derived from trades taken using Chart Trader, so far the studies I've tried, do NOT show entry or exit prices from chart Trader trades.
I'll keep looking at it this weekend.
Thanks for your suggestions.

Jad
Posts: 92
Joined: 15 Jun 2014
Has thanked: 13 times
Been thanked: 21 times

Re: Theoretical Average Price of a Trade - need Help

Postby Jad » 08 Jun 2018

You might want to start with looking again at what's written in that list.

e.g.
I_AvgEntryPrice can only be used in an indicator.
I_AvgEntryPrice will only return a value if a signal is applied to the same data.

sptrader
Posts: 742
Joined: 09 Apr 2010
Location: Texas
Has thanked: 483 times
Been thanked: 274 times
Contact:

Re: Theoretical Average Price of a Trade - need Help

Postby sptrader » 09 Jun 2018

You might want to start with looking again at what's written in that list.

e.g.
I_AvgEntryPrice can only be used in an indicator.
I_AvgEntryPrice will only return a value if a signal is applied to the same data.
As I stated many times, I don't use a signal for entry, just Chart Trader.
I guess no trade functions work with Chart Trader alone, that's very disappointing.
That means that I'm stuck with manual price entry, if I want to create the theoretical average price. (not very practical).

Jad
Posts: 92
Joined: 15 Jun 2014
Has thanked: 13 times
Been thanked: 21 times

Re: Theoretical Average Price of a Trade - need Help

Postby Jad » 09 Jun 2018

As I stated many times, I don't use a signal for entry
I know you have - but as I never said that you needed to use a signal for entry to be able to do what you need, your statement is irrelevant and its repetition doesn't change that.

OTOH, as I stated many times, try reading what is actually written in that list regarding I_AvgEntryPrice- and try to avoid being blinkered by what you 'assume' it restricts you to.

sptrader
Posts: 742
Joined: 09 Apr 2010
Location: Texas
Has thanked: 483 times
Been thanked: 274 times
Contact:

Re: Theoretical Average Price of a Trade - need Help  [SOLVED]

Postby sptrader » 09 Jun 2018

"I_AvgEntryPrice will only return a value --- if a signal is applied to the same data."
Since I don't use a signal, it apparently won't work.

Jad
Posts: 92
Joined: 15 Jun 2014
Has thanked: 13 times
Been thanked: 21 times

Re: Theoretical Average Price of a Trade - need Help

Postby Jad » 10 Aug 2018

Does it say anywhere that the signal has to be used to enter a trade before I_AvgEntryPrice will return a value?

In fact, does it say anywhere that it actually has to do anything - or does one just have to be there and be applied to the same data?

Did you try that?


Return to “MultiCharts”