how to refresh window - page 2

 

fake a tick


#property  indicator_separate_window

#import "user32.dll"
   int PostMessageW(int hWnd,int Msg,int wParam,int lParam);
   int RegisterWindowMessageW(string lpString);
#import


double sl1;

int OnInit() {
   ChartSetInteger(ChartID(),CHART_EVENT_OBJECT_CREATE,true);
   IndicatorShortName("1");
   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---

      string dis_sl1 = DoubleToStr(sl1, Digits);
      
      int chart_ID = 0;
      string object_name = "mm_edit01";
      int sub_window = WindowFind("1");
      
      ObjectCreate(chart_ID,object_name,OBJ_EDIT,sub_window,0,0);
      
      ObjectSetInteger(chart_ID,object_name,OBJPROP_XDISTANCE,412);
      ObjectSetInteger(chart_ID,object_name,OBJPROP_YDISTANCE,120);
      ObjectSetInteger(chart_ID,object_name,OBJPROP_XSIZE,60);
      ObjectSetInteger(chart_ID,object_name,OBJPROP_YSIZE,19);
      ObjectSetString(chart_ID,object_name,OBJPROP_TEXT,dis_sl1);
      ObjectSetString(chart_ID,object_name,OBJPROP_FONT,"Arial");
      ObjectSetInteger(chart_ID,object_name,OBJPROP_FONTSIZE,10);
      ObjectSetInteger(chart_ID,object_name,OBJPROP_ALIGN,ALIGN_CENTER);
      ObjectSetInteger(chart_ID,object_name,OBJPROP_READONLY,false);
      ObjectSetInteger(chart_ID,object_name,OBJPROP_CORNER,CORNER_LEFT_UPPER);
      ObjectSetInteger(chart_ID,object_name,OBJPROP_COLOR,clrWhite);
      ObjectSetInteger(chart_ID,object_name,OBJPROP_BGCOLOR,clrBlack);
      ObjectSetInteger(chart_ID,object_name,OBJPROP_BORDER_COLOR,clrSilver);
      ObjectSetInteger(chart_ID,object_name,OBJPROP_BACK,false);
      ObjectSetInteger(chart_ID,object_name,OBJPROP_SELECTABLE,false);
      ObjectSetInteger(chart_ID,object_name,OBJPROP_SELECTED,false);
      ObjectSetInteger(chart_ID,object_name,OBJPROP_HIDDEN,false);

      
   return(rates_total);
  }
      
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,         // Event ID
                  const long& lparam,   // Parameter of type long event
                  const double& dparam, // Parameter of type double event
                  const string& sparam  // Parameter of type string events
                  )
  {
//---

   
      if(id==CHARTEVENT_OBJECT_CREATE)
      {
         if(StringFind(sparam, "Horizontal Line", 0) >= 0) 
         {
            sl1 = ObjectGetDouble(ChartID(), sparam, OBJPROP_PRICE, 0);
            ObjectSetString(ChartID(), sparam, OBJPROP_TEXT, "sl1"); 
            int hwnd=WindowHandle(Symbol(), Period());
            int msg = RegisterWindowMessageW("MetaTrader4_Internal_Message");
            PostMessageW(hwnd, msg, 2, 1); // fake tick
         }
      }
  }
 
qjol:


fake a tick



Thanks a lot! that what I want.


Thank you very much.

Reason: