Bars news
- Indikatoren
- Aleksander Gladkov
- Version: 1.1
- Aktualisiert: 19 Dezember 2023
- Aktivierungen: 10
Indicator of news linked to a bar.
The published current value of the news has a characteristic impact on the currency it relates to: positive, negative, neutral . The indicator summarizes all these values for the selected period, taking into account the importance of the news: high, medium, low . As a result, a percentage is calculated for the currency pair, which shows the news of which currency is dominant. If the value is positive, then the pair has news pressure towards BUY, if negative - SELL.
Outputs three values:
- number of news items during the bar period
- index impact of news for the bar period
- current index news impact
int BN_handle;
int OnInit()
{
ResetLastError();
BN_handle=iCustom(NULL,0,"\\Indicators\\Examples\\Bars_news_v10.ex5",100,10);
if(BN_handle==INVALID_HANDLE)
{
PrintFormat("Error getting the indicator handle Bars News. Error code = %d",GetLastError());
return(INIT_FAILED);
}
return(INIT_SUCCEEDED);
}
void OnDeinit(const int reason)
{
if(BN_handle!=INVALID_HANDLE) IndicatorRelease(BN_handle);
}
void OnTick()
{ static int Cur_bar=1;
double Number_of_bar_news,Impact_of_bar_news,Current_news_impact;
if (Cur_bar<10)
{ Number_of_bar_news =iCustomGet(BN_handle,0,Cur_bar);
Impact_of_bar_news =iCustomGet(BN_handle,1,Cur_bar);
Current_news_impact =iCustomGet(BN_handle,2,Cur_bar);
PrintFormat("Cur_bar =%d:, Number_of_bar_news =%d, Impact_of_bar_news =%.1f Current_news_impact =%.1f",
Cur_bar,Number_of_bar_news,Impact_of_bar_news,Current_news_impact);
Cur_bar++;
}
}
double iCustomGet(const int ind_handle,const int buffer,int start_pos)
{
double Custom[1];
ResetLastError();
if(CopyBuffer(ind_handle,buffer,start_pos,1,Custom)<0)
{
PrintFormat("Failed to copy data from the indicator, error code %d",GetLastError());
return(0.0);
}
return(Custom[0]);
}