Hi Howard,
I have used the valuewhen function but the output data is disorganized and sometimes incorrect. I am using the following AFL code with the Explore utility:
Code:Filter=1; AddColumn(O,"Open", 1.6); AddColumn(H,"High", 1.6); AddColumn(L,"Low", 1.6); AddColumn(C,"Close", 1.6); /*AddColumn(V,"Volume",1.0); AddColumn(OI,"Open Interest",1.0); */ AddColumn(TimeFrameGetPrice("H",inDaily,0), "HHV", 1.6); AddColumn(ValueWhen(TimeFrameGetPrice("H",inDaily,0)==H, DateTime()), "Date/Time", formatDateTime);
The have set the Explore utility on a 5-min periodicity under 'General settings' as I want the result to return which 5 min bar the daily high had occurred on.
This is an example of the output data:
View attachment 61235
From the example above, it seems as though the DateTime() function is waiting for the Explore utility to actually reach the correct bar before it prints the correct data. I am not sure why it is doing this when it should already have the correct data when it compared the High array to the TimeFrameGetPrice array.
How can I fix this?
Cheers
Filter = 1;
AddColumn( O, "Open", 1.6 );
AddColumn( H, "High", 1.6 );
AddColumn( L, "Low", 1.6 );
AddColumn( C, "Close", 1.6 );
/*AddColumn(V,"Volume",1.0);
AddColumn(OI,"Open Interest",1.0); */
DH = TimeFrameGetPrice( "H", inDaily, 0 );
AddColumn( ValueWhen( DH == H, H ), "HHV", 1.6 );
AddColumn( ValueWhen( DH == H, DateTime() ), "Date/Time", formatDateTime );
Code:Filter = 1; AddColumn( O, "Open", 1.6 ); AddColumn( H, "High", 1.6 ); AddColumn( L, "Low", 1.6 ); AddColumn( C, "Close", 1.6 ); /*AddColumn(V,"Volume",1.0); AddColumn(OI,"Open Interest",1.0); */ DH = TimeFrameGetPrice( "H", inDaily, 0 ); AddColumn( ValueWhen( DH == H, H ), "HHV", 1.6 ); AddColumn( ValueWhen( DH == H, DateTime() ), "Date/Time", formatDateTime );
DH = TimeFrameGetPrice( "H", inDaily, 0 );
DHcond = H == DH;
Filter = DHcond;
AddColumn( O, "Open", 1.6 );
AddColumn( H, "High", 1.6 );
AddColumn( L, "Low", 1.6 );
AddColumn( C, "Close", 1.6 );
/*AddColumn(V,"Volume",1.0);
AddColumn(OI,"Open Interest",1.0); */
AddColumn( ValueWhen( DHcond, H ), "HHV", 1.6 ); // redundant High column
AddColumn( ValueWhen( DHcond, DateTime() ), "Date/Time", formatDateTime ); // redundant datetime column
DH = TimeFrameGetPrice( "H", inDaily, 0 );
Filter = H == DH;
AddColumn( O, "Open", 1.6 );
AddColumn( H, "High", 1.6 );
AddColumn( L, "Low", 1.6 );
AddColumn( C, "Close", 1.6 );
/*AddColumn(V,"Volume",1.0);
AddColumn(OI,"Open Interest",1.0); */
AddColumn( H, "HHV", 1.6 ); // redundant High column
AddColumn( DateTime(), "Date/Time", formatDateTime ); // redundant datetime column
Alternative code with different filtering
Code:DH = TimeFrameGetPrice( "H", inDaily, 0 ); DHcond = H == DH; Filter = DHcond; AddColumn( O, "Open", 1.6 ); AddColumn( H, "High", 1.6 ); AddColumn( L, "Low", 1.6 ); AddColumn( C, "Close", 1.6 ); /*AddColumn(V,"Volume",1.0); AddColumn(OI,"Open Interest",1.0); */ AddColumn( ValueWhen( DHcond, H ), "HHV", 1.6 ); // redundant High column AddColumn( ValueWhen( DHcond, DateTime() ), "Date/Time", formatDateTime ); // redundant datetime column
Or more simple
Code:DH = TimeFrameGetPrice( "H", inDaily, 0 ); Filter = H == DH; AddColumn( O, "Open", 1.6 ); AddColumn( H, "High", 1.6 ); AddColumn( L, "Low", 1.6 ); AddColumn( C, "Close", 1.6 ); /*AddColumn(V,"Volume",1.0); AddColumn(OI,"Open Interest",1.0); */ AddColumn( H, "HHV", 1.6 ); // redundant High column AddColumn( DateTime(), "Date/Time", formatDateTime ); // redundant datetime column
Both outputs are equal
Arghhhhhhhhhhh trash this is so much more easier!
Thank-you very much. I didn't realise that Filter could be used for this.
That reserved variable is called Filter for a reason.
default setting Filter = 1; simply means Filter = true;
So if you use that Filter setting then no filtering is applied but all possible output based on entire available barcount of a symbol is sent to result list.
Another question if possible.
I have just changed my database settings to better reflect the backfilled data. I have changed the 'Daily time-compression uses' radio button to "Day/Night session times as defined above". The data being imported is FX data and the data source defines the day session from 0900-0000 and the evening from 0000-0900 the next day.
The problem now is that AmiBroker is refusing to present the data on the Daily time scale.
I can view data on every other time scale, except for daily.
Please see images below:
View attachment 61237
Hourly
View attachment 61238
1-min
View attachment 61239
Daily
View attachment 61240
Daily chart is the same as 1-min
Another question if possible.
I have just changed my database settings to better reflect the backfilled data. I have changed the 'Daily time-compression uses' radio button to "Day/Night session times as defined above". The data being imported is FX data and the data source defines the day session from 0900-0000 and the evening from 0000-0900 the next day.
The problem now is that AmiBroker is refusing to present the data on the Daily time scale.
I can view data on every other time scale, except for daily.
Please see images below:
View attachment 61237
AddColumn(DateTime(), "date/time", formatDateTime);
Thanks trash. I tried this but when I switch to daily format, the OHLC bars are different to those that are provided by the broker.
A follow-up question to the previous exploration issue:
If I am trying to determine when the daily high and daily low occured within the same exploration, I will need a second date/time column to display that information (only one column at the moment). How do I add an additional date/time column for that output data?
Code:AddColumn(DateTime(), "date/time", formatDateTime);
The above just gives me the same result as the original column.
Thanks
dt = DateTime();
DH = TimeFrameGetPrice( "H", inDaily, 0 );
DL = TimeFrameGetPrice( "L", inDaily, 0 );
DHcond = H == DH;
DLcond = L == DL;
Filter = DHcond OR DLcond;
SetOption( "Nodefaultcolumns", True );
AddTextColumn( Name(), "Symbol", 1 );
AddColumn( O, "Open", 1.6 );
AddColumn( IIf( DHcond, ValueWhen( DHcond, dt ), Null ), "HHV DT", formatDateTime, colorLightGrey, colorDarkGreen, 120 );
AddColumn( H, "High", 1.6, IIf( DHcond, colorLightGrey, colorDefault), IIf( DHcond, colorDarkGreen, colorDefault) );
AddColumn( IIf( DLcond, ValueWhen( DLcond, dt ), Null ), "LLV DT", formatDateTime, colorLightGrey, colorDarkRed, 120 );
AddColumn( L, "Low", 1.6, IIf( DLcond, colorLightGrey, colorDefault), IIf( DLcond, colorDarkRed, colorDefault) );
AddColumn( C, "Close", 1.6 );
/*AddColumn(V,"Volume",1.0);
AddColumn(OI,"Open Interest",1.0); */
Is it possible to get the date of when something is bought/sold?
Your broker probably has future looking bars. Then go to AB support. I'm not from AB.
As for code
Code:dt = DateTime(); DH = TimeFrameGetPrice( "H", inDaily, 0 ); DL = TimeFrameGetPrice( "L", inDaily, 0 ); DHcond = H == DH; DLcond = L == DL; Filter = DHcond OR DLcond; SetOption( "Nodefaultcolumns", True ); AddTextColumn( Name(), "Symbol", 1 ); AddColumn( O, "Open", 1.6 ); AddColumn( IIf( DHcond, ValueWhen( DHcond, dt ), Null ), "HHV DT", formatDateTime, colorLightGrey, colorDarkGreen, 120 ); AddColumn( H, "High", 1.6, IIf( DHcond, colorLightGrey, colorDefault), IIf( DHcond, colorDarkGreen, colorDefault) ); AddColumn( IIf( DLcond, ValueWhen( DLcond, dt ), Null ), "LLV DT", formatDateTime, colorLightGrey, colorDarkRed, 120 ); AddColumn( L, "Low", 1.6, IIf( DLcond, colorLightGrey, colorDefault), IIf( DLcond, colorDarkRed, colorDefault) ); AddColumn( C, "Close", 1.6 ); /*AddColumn(V,"Volume",1.0); AddColumn(OI,"Open Interest",1.0); */
Sure
for( i = 0; i < BarCount; i++ )
{
if( priceatbuy == 0 && Buy[ i ] )
priceatbuy = BuyPrice[ i ];
if( priceatbuy > 0 && SellPrice[ i ] > 1.1 * priceatbuy )
{
Sell[ i ] = 1;
SellPrice[ i ] = 1.1 * priceatbuy;
priceatbuy = 0;
}
else
Sell[ i ] = 0;
}
How am I supposed to go about it?
I've tried using loops, but that didn't seem to work for me.
Code:for( i = 0; i < BarCount; i++ ) { if( priceatbuy == 0 && Buy[ i ] ) priceatbuy = BuyPrice[ i ]; if( priceatbuy > 0 && SellPrice[ i ] > 1.1 * priceatbuy ) { Sell[ i ] = 1; SellPrice[ i ] = 1.1 * priceatbuy; priceatbuy = 0; } else Sell[ i ] = 0; }
The priceatbuy or BuyPrice doesn't seem to match up to the price of the actual buying price when backtested.
Has anyone managed to successfully import minutely FX data into amibroker and get it to correctly compress it into daily bars?
I am having alot of problems with this, and it seems to be a common issue that was discussed on the yahoo message boards (last thread was in 2010). It seems to be related to amibroker's inability to correctly handle DST or inability to correctly define weekends.
I have tried to follow this guide but the compressed data is still incorrect.
If anyone knows of an alternative trading program then I would like to hear it.
Cheers
Quick question: any tricks on how to distinguish between even and odd numbers ---such as in an idx loop?
Later,
RutheezKey
i = 10;
Even = (int(i/2) - i/2) == 0;
Odd = NOT Even;
_TRACE( "!CLEAR!" );
_TRACE( StrFormat( "%g is even index (true/false): %g", i, even ) );
_TRACE( StrFormat( "%g is odd index (true/false): %g", i, odd ) );
i = 10;
Even = (int(i/2)*2/i) == 1;
Odd = NOT Even;
_TRACE( "!CLEAR!" );
_TRACE( StrFormat( "%g is even index (true/false): %g", i, even ) );
_TRACE( StrFormat( "%g is odd index (true/false): %g", i, odd ) );
Hi RutheezKey --Hi All,
I recently upgraded AB and boy am I happy. Finally, a decent editor!! I'm also thrilled with the new static "ranking" functions ---- pretty neat what all can be accomplished. Even on the older laptop, the 64-bit edition simply kicks butt. For the little money involved, I question why I always take so long to purchase the upgrades (standard disclaimer applies....no financial interest on my part).
Quick question: any tricks on how to distinguish between even and odd numbers ---such as in an idx loop?
Later,
RutheezKey
Hi All,
I recently upgraded AB and boy am I happy. Finally, a decent editor!! I'm also thrilled with the new static "ranking" functions ---- pretty neat what all can be accomplished. Even on the older laptop, the 64-bit edition simply kicks butt. For the little money involved, I question why I always take so long to purchase the upgrades (standard disclaimer applies....no financial interest on my part).
Quick question: any tricks on how to distinguish between even and odd numbers ---such as in an idx loop?
Later,
RutheezKey
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?