How to use ObjectCreate in my ea

 

Hello,

I'm looking for a way to plot dots in my ea which shows the calculated trailing stops. I would like to displays dots like a parabolic SAR indicator.

As I can see, ObjectCreate() is only able to plot arrows, lines, rectangles,... but not a dot or any other alphanumeric characters.

I you have an experience or an idea how I could do that, it would be great.


Thanks

Eric

 

i believe you can use wingdings if you create an arrrow, there are dots in wingdings, then use the wingding code as the arrow code with OBJPROP_ARROWCODE

      ObjectCreate"dots",OBJ_ARROW,0,0,0);
      ObjectSet"dots",OBJPROP_ARROWCODE,115);
 

Yes, it works fine.

Very thanks SDC.

 
//+------------------------------------------------------------------+
//| EA equivalent of indicator buffers                               |
//+------------------------------------------------------------------+
/*  Example 1:
 *  if (...) Ordermodify(...);
 *  Polyline("SL"+(oo.ticket%99), oo.SL, Color.SL, 0);
 *
 *  Example 2:
 *  double  ELineCurr = iMA(NULL,0, ELine.Period, 0, MODE_EMA, PRICE_CLOSE, 1);
 *  Polyline("ELine", ELineCurr, Color.ELine, 1);
 ******************************************************************************/
#define POLYLINE_MAX 20 // Must match priceMM
double  price00[], price01[], price02[], price03[], price04[],  // \   Export
        price05[], price06[], price07[], price08[], price09[],  //  \  from
        price10[], price11[], price12[], price13[], price14[],  //  |  Polyline
        price15[], price16[], price17[], price18[], price19[];  //  |
int     LRU[POLYLINE_MAX];                                      //   > Import to
string  lineName[POLYLINE_MAX];                                 // _/  PLHelper
void Polyline(string name, double price, color clr, int shift=0){
    if (!Show.Objects)  return;
    for (int idx=0; idx < POLYLINE_MAX; idx++){     LRU[idx]++; }
    for (idx=0; idx < POLYLINE_MAX; idx++){
        bool new = lineName[idx] != name;   if (!new) break;    }
    if (new)    idx=ArrayMaximum(LRU);
    switch (idx){
    case  0: PLHelper(name, price, clr, idx, new, shift, price00); return;
    case  1: PLHelper(name, price, clr, idx, new, shift, price01); return;
    case  2: PLHelper(name, price, clr, idx, new, shift, price02); return;
    case  3: PLHelper(name, price, clr, idx, new, shift, price03); return;
    case  4: PLHelper(name, price, clr, idx, new, shift, price04); return;
    case  5: PLHelper(name, price, clr, idx, new, shift, price05); return;
    case  6: PLHelper(name, price, clr, idx, new, shift, price06); return;
    case  7: PLHelper(name, price, clr, idx, new, shift, price07); return;
    case  8: PLHelper(name, price, clr, idx, new, shift, price08); return;
    case  9: PLHelper(name, price, clr, idx, new, shift, price09); return;
    case 10: PLHelper(name, price, clr, idx, new, shift, price10); return;
    case 11: PLHelper(name, price, clr, idx, new, shift, price11); return;
    case 12: PLHelper(name, price, clr, idx, new, shift, price12); return;
    case 13: PLHelper(name, price, clr, idx, new, shift, price13); return;
    case 14: PLHelper(name, price, clr, idx, new, shift, price14); return;
    case 15: PLHelper(name, price, clr, idx, new, shift, price15); return;
    case 16: PLHelper(name, price, clr, idx, new, shift, price16); return;
    case 17: PLHelper(name, price, clr, idx, new, shift, price17); return;
    case 18: PLHelper(name, price, clr, idx, new, shift, price18); return;
    case 19: PLHelper(name, price, clr, idx, new, shift, price19); return;
}   }
void PLHelper( string name, double price, color clr, int idx, bool new
             , int shift, double& mem[] ){
    datetime    t0  = Time[shift];  int firstBar = ArraySize(mem)-1;
    static datetime time0[POLYLINE_MAX];
    if (time0[idx] < Time[shift+1])     new = true;     // Missing bars, leave a gap.
    if (new){   t0 += 60*Period();      firstBar = -1;  lineName[idx]=name;
        static int      segNo[POLYLINE_MAX];    segNo[idx]++;
        static datetime time1[POLYLINE_MAX];    time1[idx] = Time[shift];   }
    LRU[idx] = 0;   string objName=name+"-"+segNo[idx];
    if (new || t0 != time0[idx]){
        ArraySetAsSeries(mem, true);        // Shift values m[2]=m[1]; m[1]=m[0]
        firstBar=ArrayResize(mem, firstBar+2)-1;    if (firstBar < 0){  Alert(
            "ArrayResize failed: ",GetLastError());                     return;}
        ArraySetAsSeries(mem, false);
        time0[idx]=t0;      mem[0]=price;
    }
    /**/ if(ObjectMove(objName, 1, t0,          price))
            ObjectMove(objName, 0, time1[idx],  mem[firstBar]); // New or tmplt.
    else if (!ObjectCreate( objName, OBJ_TREND, WINDOW_MAIN
                          , time1[idx], mem[firstBar], t0,  price )){   Alert(
        "ObjectCreate(", objName, "Trend) [1] failed: ",GetLastError());return;}
    else if (!ObjectSet( objName, OBJPROP_COLOR, clr ))                 Alert(
        "ObjectSet(", objName, "Color) [3] failed: ",   GetLastError());
    else if (!ObjectSet( objName, OBJPROP_RAY, false ))                 Alert(
        "ObjectSet(", objName, "Ray) [1] failed: ",     GetLastError());
    double maxError=0;  int maxBar;
    for (int pos=1; pos < firstBar; pos++){
        double error=MathAbs(ObjectGetValueByShift(objName, pos+shift)-mem[pos]);
        if (error > maxError){  maxError=error; maxBar=pos; }
    }
    if (maxError >= pips2dbl){  // Split the line into two segments at the max.
        if (!ObjectMove(objName, 1, Time[shift+maxBar], mem[maxBar]))   Alert(
            "ObjectMove(", objName, "Trend) failed: ",  GetLastError());
        segNo[idx]++; objName=name+"-"+segNo[idx];
        ArrayResize(mem, maxBar+1); // Drop firstBar..(maxBar+1)
        time1[idx] = Time[shift+maxBar];
        /**/ if(ObjectMove(objName, 0, time1[idx],  mem[maxBar]))
                ObjectMove(objName, 1, t0,          price);
        else if (!ObjectCreate( objName, OBJ_TREND, WINDOW_MAIN
                              , time1[idx], mem[maxBar], t0, price )){  Alert(
            "ObjectCreate(", objName, "Trend) [2] failed: ",GetLastError()); }
        else if (!ObjectSet( objName, OBJPROP_COLOR, clr ))             Alert(
            "ObjectSet(", objName, "Color) [4] failed: ",   GetLastError());
        else if (!ObjectSet( objName, OBJPROP_RAY, false ))             Alert(
            "ObjectSet(", objName, "Ray) [3] failed: ",     GetLastError());
    }   // Split the line into two segments at the max.
}   // PLHelper
 
update code https://www.mql5.com/en/forum/130907 Allows color change, deletion, style modification.
Reason: