Hi Fellow Members
I was trying to find the net open position profit for all open positions at any given bar using AddtoComposite and access it using Foreign function.
I run the code in exploration mode and it was working fine( able to see the composite symbol made). However i want to use this symbol in live trading and exit when the Net Profit is above a certain value.
However when i tried to use this value in the strategy the value always shows the open position profit for the chart in display( not the composite , but for single symbol).
Can we use the AddtoComposite's in live trading signals.
I know i can use mid/low level custom back-tester for this approach to find net unrealised profit but i dont want to go there. Any suggestions on how to find net open position profit for all the symbols using any method.
AddToComposite( IIf(bar_count>=1 , (entryprice-Close)*shares, 0), ~OpenPosProf", "V" , 1 + 2 + 8 + 16 +128); // bar_count variable stores number of bars since in positions
Open_posn_prof = foreign( "~OpenPosProf", "V" , True ); // access the foreign composite
if(Open_posn_prof >100000)
{
// sell code here
}