Download MetaTrader 5

Have you seen that picture?

To add comments, please log in or register
Do you need private account monitoring? The Signals will provide you one!
Carl Schreiber
6592
Carl Schreiber 2014.11.07 19:25 

Hi,

I created an indicator to display volume + spread as 90° turned text objects in its separate window.

At the beginning everything looks perfect!, but after a while (some hours on the m1 chart) it gets mad look at the attached snapshot.

Can it be that mt4 gets into troubles by the non standard font that I use: Monofonto?

My error-function ErrN(_LastError) doesn't show any error!

This is the function that creates the objects (I doubled Line, as I thought it might be caused by the length):

#define ErrN(n) if(n>1){ Print(__FILE__," L:",__LINE__," Error# ",(string)_LastError ); ResetLastError(); } // usage ErrN(GetLastError());

string showVoSpr(long vol, int spr, int b=0 ){
        bool a,c,d;
        ResetLastError();
        if ( actBar != Time[b] ) {
                maxSpr=spr; minSpr= spr; //reset max & min
                VolEma = (Volume[b+1] -VolEma)*VOL_EmaConst + VolEma; // calc Vol.Ema
                actBar = Time[b]; // set newBar
                chScale = (int)ChartGetInteger(0,CHART_SCALE); //check scale for font-size
                objID  = IndiName+(string)TimeDay(actBar)+"."+TimeToStr(actBar,TIME_MINUTES); //Obj.ID: "SpVo 7.18:35"
                if ( ObjectFind(objID) >= 0 ) ObjectDelete(objID);
                ResetLastError(); // is set if not found :(
                a = ObjectCreate(0,objID,OBJ_TEXT,IndiWin,actBar,0);
                ErrN(_LastError); 
                d = ObjectSet(objID,OBJPROP_ANGLE,90); 
                ErrN(_LastError);// ERR_OBJECT_DOES_NOT_EXIST
        } else if ( ObjectFind(objID) < 0 ) {
                ResetLastError(); // is set if not found :(
                a = ObjectCreate(0,objID,OBJ_TEXT,IndiWin,actBar,0);
                ErrN(_LastError);//ERR_OBJECT_ALREADY_EXISTS
                d = ObjectSet(objID,OBJPROP_ANGLE,90);
                ErrN(_LastError);
        }
        maxSpr = fmax(maxSpr,spr); minSpr = fmin(minSpr,spr);
        Line = StringConcatenate(
                                        (string)spr," (",(string)minSpr,"-",(string)maxSpr,")  ",
                                        (string)vol," {",DoubleToStr(VolEma,0),"}"
               );
   switch (chScale) {
        case 3:
              c = ObjectSetText(objID,Line+"  "+Line,7,"Monofonto",White); 
              break;
        case 4: //
              c = ObjectSetText(objID,Line+"  "+Line,9,"Monofonto",White); 
              break;
        case 5: // biggest candles
              c = ObjectSetText(objID,Line+"  "+Line,11,"Monofonto",White); 
              break;
           default:
                ObjectSet(objID,OBJPROP_BACK,true);
              c = ObjectSetText(objID,Line+"  "+Line,11,"Monofonto",clrNONE); 
              break;
   }
   ErrN(_LastError);
   return(Line);
}


After some hours the indicator looks like:


PS: I tried to post it at the service-desk but when I click on the save button I get the error message: Enter your request title (it may not exceed 100 characters)

while in that field I entered: "Text-Objects getting mad?" :(

Have a nice weekend.

SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2014.11.07 23:49  
I believe the text is being created over and over. Maybe delete object and recreate it?
Carl Schreiber
6592
Carl Schreiber 2014.11.08 08:28  
deysmacro:
I believe the text is being created over and over. Maybe delete object and recreate it?

no -

1) I checked it and I posted the code and you can see either that a new object is created only if it couldn't be found otherwise only the text is changed.

2) I was running

c = ObjectSetText(objID,Line+"  "+Line,11,"Monofonto",White);

in this way for a longer time the values are written without this 'art of writing':

c = ObjectSetText(objID,Line+"  "+Line,11,"",White);
Keith Watford
Moderator
9624
Keith Watford 2014.11.08 09:29  
Is objID  assigned a different value elsewhere in your code?
Carl Schreiber
6592
Carl Schreiber 2014.11.08 09:54  
GumRai:
Is objID  assigned a different value elsewhere in your code?

No! Only the values to be displayed are calculated out of this function.

BTW I attached this indi. at the chart (first entry) at 16:18. The first "mutiple-stamp" appears at 20:01 until the market closes with 10 'after-burners' ;)

May be it's a buffer overflow to get admin. rights ;)

To add comments, please log in or register