I am wondering if anyone can help with an indicator that I am trying to build. The general idea is to have a vertical list made up of 14 rows and 3 columns. The first column would contain currency pair symbol names, the second column would contain the amount of pips from that pair's daily open price, and the third column would contain the pip spread for that pair. I know how to get the currency pair symbol on the chart and how to get the spread on the chart as well. My problem is that I need to be able to create a sorted list, that is in descending order, that auto sorts as pip spreads change.
For example, when big news comes out, the pip spreads go crazy and I would like the list to stay in order of spread size so that i can tell, by a simple glance, what pair has the smallest spread or the largest spread at any one time.
Here is the beginning code that I am working with. If anyone can help, I would greatly appreciate it.
externcolor font_color = White;
externcolor pos_color = LimeGreen;
externcolor neg_color = Red;
externint font_size = 11;
externstring font_face = "Arial";
externint corner = 0; //0 - for top-left corner, 1 - top-right, 2 - bottom-left, 3 - bottom-right//------externint currencypair_x = 10;
externint currencypair_y = 60;
externint pipcount_x = 150;
externint pipcount_y = 60;
externint titles_x = 10;
externint titles_y = 35;
//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+int init()
{
ObjectMakeLabel( "currencypair", currencypair_x, currencypair_y );
ObjectMakeLabel( "pipcount", pipcount_x, pipcount_y );
ObjectMakeLabel( "titles", titles_x, titles_y );
return(0);
} // end of init()//+------------------------------------------------------------------+//| Custom indicator iteration function -- Runs with each new tick |//+------------------------------------------------------------------+int start()
{
ObjectSetText( "titles", "Pair " + "PIPS " + "Spread", font_size, font_face, font_color );
//------------------------------------------------double EUopen = iClose("EURUSD",PERIOD_D1,0)-iOpen("EURUSD",PERIOD_D1,0);
string EUpips2opens;
{
double EUpips2open =MathFloor(EUopen/Point/10);
EUpips2opens = StringConcatenate(DoubleToStr(EUpips2open,0),"");
}
string EUnegpips;
{
if (EUpips2open < 0)
double EUnegpip = MathAbs(EUopen/Point/10);
EUnegpips = StringConcatenate(DoubleToStr(EUnegpip,0),"");
}
ObjectSetText( "currencypair", Symbol(), font_size, font_face, font_color );
if (EUpips2open >= 0) ObjectSetText( "pipcount", EUpips2opens, font_size, font_face,pos_color );
else ObjectSetText( "pipcount", EUnegpips, font_size, font_face,neg_color );
return(0);
} // end of start()//+------------------------------------------------------------------+//| Custom functions |//+------------------------------------------------------------------+int ObjectMakeLabel( string n, int xoff, int yoff ) {
ObjectCreate( n, OBJ_LABEL, 0, 0, 0 );
ObjectSet( n, OBJPROP_CORNER, corner );
ObjectSet( n, OBJPROP_XDISTANCE, xoff );
ObjectSet( n, OBJPROP_YDISTANCE, yoff );
ObjectSet( n, OBJPROP_BACK, false );
} // end of ObjectMakeLabel//+------------------------------------------------------------------+//| Custom indicator deinitialization function |//+------------------------------------------------------------------+int deinit()
{
//----ObjectDelete( "currencypair" );
ObjectDelete( "pipcount" );
return(0);
} // end of deinit()
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Hello,
I am wondering if anyone can help with an indicator that I am trying to build. The general idea is to have a vertical list made up of 14 rows and 3 columns. The first column would contain currency pair symbol names, the second column would contain the amount of pips from that pair's daily open price, and the third column would contain the pip spread for that pair. I know how to get the currency pair symbol on the chart and how to get the spread on the chart as well. My problem is that I need to be able to create a sorted list, that is in descending order, that auto sorts as pip spreads change.
For example, when big news comes out, the pip spreads go crazy and I would like the list to stay in order of spread size so that i can tell, by a simple glance, what pair has the smallest spread or the largest spread at any one time.
Here is the beginning code that I am working with. If anyone can help, I would greatly appreciate it.