Hi
I read the documentation about the TradePrice function and I do some tests and I realize that the TradePrice function does not make the difference between an entry price and an exit price, is there a solution to remedy this problem?
For example on the documentation we can use the following code:
IF BARINDEX-TRADEINDEX(1)>5 ......
The problem is that if you use a filter to enter a trade after five candles then when you exit a trade you will also have to wait five candles to re-enter.
Other question: If I have for example a position with five different entries how can I allocate to five different variables (or more) the entry price to be able to use them in the future and reset them once I have exited my position completely (or partially to complicate things further)
Tks in advance for your light or you links,
Best Reguards,
ZeroCafeine
JSParticipant
Senior
Hi,
You can simply use…
If OnMarket then
myEntryPrice = TradePrice
EndIf
If NOT OnMarket then
myExitPrice=TradePrice
EndIf
tks you @JS
Do you have another idea if you have several inputs and several outputs and you don’t know the total number of trades in advance, also and you to reset them?
example with 3 entries and 2 exits?
I have to program something simple and put the code here
JSParticipant
Senior
Hi,
With multiple contracts you can use “CountOfPosition” to find out the total amount of contracts…
The average position price can be found with “PositionPrice”…
You can continue to follow the entry/exit price of the individual contracts with “TradePrice”…
now I’m using this :
MyFirstBuying = OnMarket AND Not OnMarket[1]
IF MyFirstBuying Then
myFirstEntryPrice = TradePrice
MyFirstBuyingTradeIndex = TRADEINDEX
ENDIF
MyLastBuying = ABS(CountOfPosition) > ABS(CountOfPosition[1])
IF MyLastBuying Then
MyLastBuyingPrice = TradePrice
MyLastBuyingTradeIndex = TRADEINDEX
ENDIF