I believe that an exploration using the code below should result in a listing of opening values for the current symbol and corresponding values for the other symbol (in my case, AAN). If I understand the mode parameter, there should always be a corresponding value for the other symbol as long as that value occurred some time prior to the occurrence of the current symbol's value. I am only getting corresponding values when the opening time of the current symbol's value corresponds to the opening time of the other symbol. I assume my syntax is wrong but I would appreciate any advice.
for( i = 1; i < BarCount - 1; i++ )
AddColumn(O,"Current Symbol Open",1.3);
AddColumn(currentValueOtherSymbol,"Other Symbol Open",1.3);
If you are saying:
If not mistaken, then you want to have Open of the current symbol and the Open of another symbol placed side-by-side. Right?
If that is the only requirement, then I do not see the need of using Lookup(). AFAIK your understanding for the Lookup() function is correct.
Below should do fine provided you have chosen "END time of interval" Timestamp of compressed intraday bars from Tools > Preferences > Intraday.
otherSymbolOpen = Foreign( "AAN", "O", True );
Filter = 1;
AddColumn( O, "Current Symbol Open", 1.3 );
AddColumn( otherSymbolOpen, "Other Symbol Open", 1.3 );
Thanks very much. I am going to use your coding.
I was originally using tick data and I wanted to find the most recent "foreign" price that occurred before the current price of the current symbol. With your recommendation, changing the third parameter in the foreign function to FALSE and using a short interval, I think I can accomplish pretty much the same thing.
See the comment under Foreign function documentation. It specifically described that Foreign does that kind of timestamp lookup automatically out-of-the-box so you don't need to do anything yourself.
Thanks very much. I had seen that comment.
The foreign symbol is exactly aligned with the current symbol but, if I understand it correctly, if you don't use padding, you can miss values of the foreign symbol. If you do use padding, you get padded values of the current symbol which are not easy to detect and ignore because the volume value of the current symbol is padded with a previous value. I am trying to discern actual trades of the current symbol and actual trades of the foreign symbol synced. If there are no corresponding trades of one symbol or the other, I would like that time period to be blank for the respective symbol. Without padding, I miss some trades of the foreign symbol. With padding, I cannot discern whether the current symbols values are the result of a trade or padding.
I cannot find an easy way to do this which shows actual rather than padded values without skipping some actual trades.
Somewhere else in the documentation, you (or someone else) suggest creating a composite of the sum of the volumes of the two symbols (without padding) as a way of discerning actual trades and I am working on that but, as you can see, I have very limited programming talent. I think it would be much easier if the volume value of the current symbol were padded with a zero or a null value but I assume there is a good reason for not doing that.
I have not looked carefully enough at the results yet but i think this is what I was looking for:
firstSymbolOpen = Foreign( "AAN", "O", FALSE );
secondSymbolOpen = Foreign( "AAC", "O", FALSE );
Filter = 1;
AddColumn( firstSymbolOpen, "First Symbol Open", 1.3 );
AddColumn( secondSymbolOpen, "Second Symbol Open", 1.3 );
I run a scan on a watchlist that just contains the two symbols. Then, I run an exploration on the ~cV symbol and I think I am getting the values I am looking for.