I want to put MA shortname in chart window

 
Hello

I am using 5 numbers of SMA in H4 TF. When I look at my chart I cant remember which one is what . I always touch with mouse pointer to know their value. I think it will be very handy if I can put shortname beside of MA with same color and moving along with MA indi. I dont know how to set in program bcos my MQL4 knowledge is very poor and I will appreciate if somebody modify Moving Average Indi.

1,000,000 thanks

mithetnme
 

code I use for similar purpose ...

void BuildWindowLabels()
{
      ObjectCreate( gsWinName+kZ1Name, OBJ_LABEL, WindowFind(gsWinName),0,0);
      ObjectSetText(gsWinName+kZ1Name, kZ1Name, 10, "Arial Bold", indicator_color1);
      ObjectSet(    gsWinName+kZ1Name, OBJPROP_CORNER, 0);
      ObjectSet(    gsWinName+kZ1Name, OBJPROP_XDISTANCE, 80);
      ObjectSet(    gsWinName+kZ1Name, OBJPROP_YDISTANCE, 10);
        
      ObjectCreate( gsWinName+kZ2Name, OBJ_LABEL, WindowFind(gsWinName),0,0);
      ObjectSetText(gsWinName+kZ2Name, kZ2Name, 10, "Arial Bold", indicator_color2);
      ObjectSet(    gsWinName+kZ2Name, OBJPROP_CORNER, 0);
      ObjectSet(    gsWinName+kZ2Name, OBJPROP_XDISTANCE, 180);
      ObjectSet(    gsWinName+kZ2Name, OBJPROP_YDISTANCE, 10);

      ObjectCreate( gsWinName+kZ3Name, OBJ_LABEL, WindowFind(gsWinName),0,0);
      ObjectSetText(gsWinName+kZ3Name, kZ3Name, 10, "Arial Bold", indicator_color3);
      ObjectSet(    gsWinName+kZ3Name, OBJPROP_CORNER, 0);
      ObjectSet(    gsWinName+kZ3Name, OBJPROP_XDISTANCE, 280);
      ObjectSet(    gsWinName+kZ3Name, OBJPROP_YDISTANCE, 10);
 
      ObjectCreate( gsWinName+kZ4Name, OBJ_LABEL, WindowFind(gsWinName),0,0);
      ObjectSetText(gsWinName+kZ4Name, kZ4Name, 10, "Arial Bold", indicator_color4);
      ObjectSet(    gsWinName+kZ4Name, OBJPROP_CORNER, 0);
      ObjectSet(    gsWinName+kZ4Name, OBJPROP_XDISTANCE, 380);
      ObjectSet(    gsWinName+kZ4Name, OBJPROP_YDISTANCE, 10);

      ObjectCreate( gsWinName+kZ5Name, OBJ_LABEL, WindowFind(gsWinName),0,0);
      ObjectSetText(gsWinName+kZ5Name, kZ5Name, 10, "Arial Bold", indicator_color5);
      ObjectSet(    gsWinName+kZ5Name, OBJPROP_CORNER, 0);
      ObjectSet(    gsWinName+kZ5Name, OBJPROP_XDISTANCE, 80);
      ObjectSet(    gsWinName+kZ5Name, OBJPROP_YDISTANCE, 30);

      //ObjectCreate( gsWinName+kZ6Name, OBJ_LABEL, WindowFind(gsWinName),0,0);
      //ObjectSetText(gsWinName+kZ6Name, kZ6Name, 10, "Arial Bold", indicator_color6);
      //ObjectSet(    gsWinName+kZ6Name, OBJPROP_CORNER, 0);
      //ObjectSet(    gsWinName+kZ6Name, OBJPROP_XDISTANCE, 180);
      //ObjectSet(    gsWinName+kZ6Name, OBJPROP_YDISTANCE, 30);

      ObjectCreate( gsWinName+kZ7Name, OBJ_LABEL, WindowFind(gsWinName),0,0);
      ObjectSetText(gsWinName+kZ7Name, kZ7Name, 10, "Arial Bold", indicator_color7);
      ObjectSet(    gsWinName+kZ7Name, OBJPROP_CORNER, 0);
      ObjectSet(    gsWinName+kZ7Name, OBJPROP_XDISTANCE, 280);
      ObjectSet(    gsWinName+kZ7Name, OBJPROP_YDISTANCE, 30);

      ObjectCreate( gsWinName+kZ8Name, OBJ_LABEL, WindowFind(gsWinName),0,0);
      ObjectSetText(gsWinName+kZ8Name, kZ8Name, 10, "Arial Bold", indicator_color8);
      ObjectSet(    gsWinName+kZ8Name, OBJPROP_CORNER, 0);
      ObjectSet(    gsWinName+kZ8Name, OBJPROP_XDISTANCE, 380);
      ObjectSet(    gsWinName+kZ8Name, OBJPROP_YDISTANCE, 30);
}
 
brewmanz:

code I use for similar purpose ...


Hi brewmanz

Thank you for your advice. But according to your code, it will show at one corner of chart window. I am sorry that I didnt explain how I want . I edit my threat to show it & please advice me again.

thanks again


mithetnme

 

mithetnme:

and I will appreciate if somebody modify Moving Average Indi.

Look at the "Moving Averages.mq4" that comes with MT
   switch(MA_Method)
     {
      case 1 : short_name="EMA(";  draw_begin=0; break;
      case 2 : short_name="SMMA("; break;
      case 3 : short_name="LWMA("; break;
      default :
         MA_Method=0;
         short_name="SMA(";
     }
   IndicatorShortName(short_name+MA_Period+")");
Look at the Alligator.mq4
//---- index labels
   SetIndexLabel(0,"Gator Jaws");
   SetIndexLabel(1,"Gator Teeth");
   SetIndexLabel(2,"Gator Lips");
Modify your indicator.
 
WHRoeder:
Look at the "Moving Averages.mq4" that comes with MT Look at the Alligator.mq4 Modify your indicator.

Hello WHRoeder

Thanks for your help. But I already tried it. Custom MA indicator itself can show no name in chart window. So I add "ObjectCreate"command and it shows shortname at one corner of chart window. I actually want to display the shortname at beside of MA and moving together with it.

thanks again

mithetnme

int init()
  {
   int    draw_begin;
   string short_name;
//---- drawing settings
   SetIndexStyle(0,DRAW_LINE);
   SetIndexShift(0,MA_Shift);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
   if(MA_Period<2) MA_Period=13;
   draw_begin=MA_Period-1;
//---- indicator short name
   switch(MA_Method)
     {
      case 1 : short_name="EMA(";  draw_begin=0; break;
      case 2 : short_name="SMMA("; break;
      case 3 : short_name="LWMA("; break;
      default :
         MA_Method=0;
         short_name="SMA(";
     }
      ObjectDelete("MAname");
      
     ObjectCreate("MAname", OBJ_LABEL, 0, 0, 0);
     ObjectSetText("MAname", short_name+MA_Period+")", 12, "Arial", White);
     ObjectSet("MAname", OBJPROP_CORNER, 1);
     ObjectSet("MAname", OBJPROP_XDISTANCE, 7);
     ObjectSet("MAname", OBJPROP_YDISTANCE, 5);
     
   IndicatorShortName(short_name+MA_Period+")");
   SetIndexDrawBegin(0,draw_begin);
//---- indicator buffers mapping
   SetIndexBuffer(0,ExtMapBuffer);
//---- initialization done
   return(0);
  }
 

mithetnme:

corner of chart window. I actually want to display the shortname at beside of MA and moving together with it.

Use OBJ_TEXT to put it near price. Move it each bar
        datetime x=Time[0]+60*Period();
        double   y=ima(...);
        if ((!ObjectMove(cnfrm, 0, x, y))
        &&  (!ObjectCreate(cnfrm, OBJ_TEXT, 0, x, y)))
            Alert("ObjectCreate(",cnfrm,",TEXT) [1] failed: ",GetLastError());
        else if (!ObjectSet( cnfrm, OBJPROP_COLOR, Color.Open ))    Alert(
            "ObjectSet(", cnfrm, ",Color) [1] failed: ", GetLastError() );
Reason: