The problem and the solution are in your code.
Hi, this is the Indi code:
#property version "1.00" #property strict #property indicator_chart_window #property indicator_buffers 4 #property indicator_color1 clrSeaGreen #property indicator_color2 clrRed #property indicator_color3 clrYellow #property indicator_color4 clrYellow #property indicator_width1 2 #property indicator_width2 2 #property indicator_width3 1 #property indicator_width4 1 double Buya[]; double Sella[]; double Buys[]; double Sells[]; #include <Controls/Dialog.mqh> #include <Controls/Button.mqh> #include <Controls/Label.mqh> #include <Controls/RadioGroup.mqh> #include <Controls/ComboBox.mqh> #include <Controls/SpinEdit.mqh> //-- CEdit EditBuyLine,AlertBuy, EditSellLine, AlertSell, AmountV; CLabel InsertBuyValue,InsertSellValue,Amount; CLabel PreAlertBuy,PreAlertSell; CButton DrawLine,Clear,DrawSell,ClearSell,SellMargin,ClearSellMargin; CButton DrawMargin1,Clear1; CComboBox CandleOption; CAppDialog Interface; double Tbuy; double Tsell; double Abuy; double Asell; double PrintLine = 0; double PrintLine2 = 0; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() //-- { { Interface.Create(0,"Control Panel v5",0,10,15,450,300); // texto criar buy line InsertBuyValue.Create(0,"InsertBuyValue",0,10,10,50,35); InsertBuyValue.Text("CALL:"); InsertBuyValue.Color(clrGreen); // Caixa editar buy price EditBuyLine.Create(0,"InsertBuyPrice",0,70,10,140,35); EditBuyLine.Text(" "); EditBuyLine.Color(clrGreen); EditBuyLine.ColorBorder(clrBlack); EditBuyLine.ReadOnly(false); EditBuyLine.TextAlign(ALIGN_CENTER); // Botao Desenhar Buy line DrawLine.Create(0,"Plot",0,145,10,230,35); DrawLine.Text("Get Line"); DrawLine.ColorBackground(clrGreenYellow); //-- Botao limpar linha buy price Clear.Create(0,"Clear",0,235,10,315,35); Clear.Text("Clear"); Clear.ColorBackground(clrYellow); Interface.Add(InsertBuyValue); Interface.Add(EditBuyLine); Interface.Add(DrawLine); Interface.Add(Clear); Interface.Add(AlertBuy); Interface.Run(); //-- Indicators buffer mapping { SetIndexBuffer(0,Buya); SetIndexStyle(0,DRAW_ARROW); SetIndexArrow(0,164); SetIndexLabel(0,"Buy"); SetIndexBuffer(1,Sella); SetIndexStyle(1,DRAW_ARROW); SetIndexArrow(1,164); SetIndexLabel(1,"Sell"); SetIndexBuffer(2,Buys); SetIndexStyle(2,DRAW_ARROW); SetIndexArrow(2,159); SetIndexLabel(2,"Alert Buy"); SetIndexBuffer(3,Sells); SetIndexStyle(3,DRAW_ARROW); SetIndexArrow(3,159); SetIndexLabel(3,"Alert Sell"); } return(INIT_SUCCEEDED); } return(0); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { Interface.Destroy(reason); EventKillTimer(); } //+------------------------------------------------------------------+ //| ChartEvent function | //+------------------------------------------------------------------+ void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { //--- Interface.OnEvent(id,lparam,dparam,sparam); //-- Desenhar linha Buy if(id==CHARTEVENT_OBJECT_CLICK &&sparam ==("Plot")) { ObjectCreate("PrintLine", OBJ_HLINE, 0, 0, EditBuyLine.Text()); ObjectSet("PrintLine", OBJPROP_STYLE, STYLE_SOLID); ObjectSet("PrintLine", OBJPROP_COLOR, Green); ObjectSet("PrintLine", OBJPROP_WIDTH, 2); ObjectGet("PrintLine",1); Abuy = (double)EditBuyLine.Text(); Print (_Symbol, "Tocou no sinal BUY:", Abuy); } //-- Limpar Buy Line { if(id==CHARTEVENT_OBJECT_CLICK &&sparam ==("Clear")) ObjectDelete("PrintLine"); } //-- Desenhar linha alerta Buy if(id==CHARTEVENT_OBJECT_CLICK &&sparam ==("DrawMargin1")) { ObjectCreate("PrintLine2", OBJ_HLINE, 0, 0,(double)EditBuyLine.Text()+(double)AlertBuy.Text()*Point); ObjectSet("PrintLine2", OBJPROP_STYLE, STYLE_SOLID); ObjectSet("PrintLine2", OBJPROP_COLOR, Yellow); ObjectSet("PrintLine2", OBJPROP_WIDTH, 1); Tbuy = (double)EditBuyLine.Text()+(double)AlertBuy.Text()*Point(); Print ("Linha Alerta buy: ->", Tbuy); } //--Limpar Margem 1 { if(id==CHARTEVENT_OBJECT_CLICK &&sparam ==("Clear1")) ObjectDelete("PrintLine2"); } } //+------------------------------------------------------------------+ //| 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[]) { //--- static datetime last_bar = 0; datetime this_bar = Time[0]; if(last_bar != this_bar) // SETAS // { if (Tbuy != 0 && Bid <= Tbuy) { last_bar = this_bar; Buys[0] = Tbuy; Tbuy = NULL; return(0); } if (Tsell != 0 && Bid >= Tsell) { last_bar = this_bar; Sells[0] = Tsell; Tsell = NULL; return(0); } } return(rates_total); }
This is the EA code:
#include <stdlib.mqh> #include <stderror.mqh> input double Amount = 1; int OnInit() { return(INIT_SUCCEEDED); } void OnTick() { Comment("EA is running "); //doubles double up=iCustom(NULL,0,"CPAv5",0,0); double down=iCustom(NULL,0,"CPAv5",1,0); //Call if (up!=0&&up!=EMPTY_VALUE) Alert("Do stuff..."); } void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { }
Hope someone can guide me, many thanks
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi,
I 've done a simple indicator using Dialog. Working fine, no errors.
I am now trying no create an EA to use it's signals.
Once I load the EA I get the alert "CApp Dialog: find sub window error".
My indi has no sub windows.
I searched deeply for it but couldn't find any related information.
Thanks in advance for any help
Dimanche