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
This is what I got. Please tell me what's wrong. Thank you in advance!
Hello!
I'm writing here as there doesn't seem to be anyone on mq4.
Can you tell me what I'm doing wrong? Option 2 is not working.
Hello, Please help me with writing a function in MT4. I know my account balance, I know how many trades will open (e.g. 9), I know the risk (e.g. 3% of AccountBalance), I need to calculate a lot for the first trade, if each next lot will be doubled and all trades will overlap each other.
This is what I got. Please tell me what's wrong. Thank you in advance!
Hello!
I'm writing here, because there seems to be nobody on mq4.
Can you tell me what I'm doing wrong? Option 2 doesn't work.
Highlighted: there should be an assignment - "=" and you have a comparison - "==".
Hi all !
I am learning to write robots in mt4, i decided to start with binary options . I am writing simple EA, but compiler generates a lot of warnings, i can't understand it (
Help: "Oh MQL4 Guru" =))))))
Thanks in advance!)
Here is the code for the EA.
//+------------------------------------------------------------------+
//|Bolinger_Bands_traider.mq4 |
//|Copyright 2017, Penrov Nikolay |
//|vk.com/buzamonolit |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, Petrov Nikolay"
#property link "vk.com/buzamonolit"
#property version "1.00"
#property strict
//+------------------------------------------------------------------+
//| expert initialization function|
//+------------------------------------------------------------------+
extern int Bolinger_Bands = 20; // Bollinger Band period
extern double Delta = 0.0003; // At what distance to open the order
string Symb; // Name of the financial instrument.
int Total; // Number of orders
//+------------------------------------------------------------------+
//| expert initialization function|
//+------------------------------------------------------------------+
int init()
{
//----
Initialize_Objects(0);
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function|
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function|
//+------------------------------------------------------------------+
int start()
{
//----
double price = Bid;
double CurrBol_High = iBands(Symb,0, Bolinger_Bands, 0,0, PRICE_CLOSE, MODE_UPPER, 0);
double CurrBol_Low = iBands(Symb,0, Bolinger_Bands, 0,0, PRICE_CLOSE, MODE_LOWER, 0);
double PriceBol_High = price - CurrBol_High;
double PriceBol_Low = price - CurrBol_Low;
datetime NextClose = Time[0] + Period()*60*2;
int MinutesToNextClose = (NextClose - TimeCurrent())/60 + 1;
int err;
// Order counting
Symb=Symbol();// Name of the fin.symbol(); // symbol(); // symbol(); // order icon(); // symbol().
Total=0;// Number of orders
for(int i=1; i<=OrdersTotal(); i++) // Order loop
{
if (OrderSelect(i-1,SELECT_BY_POS)==true) // If there is a next
{// Order analysis:
if (OrderSymbol()!=Symb)continue; // Not our financial instrument
if (OrderType()>1)// We have a pending order
{
Alert("Pending order detected. Expert Advisor is not working;)
return(0);// Exit()
}
Total++;// Counter market. order
if (Total>1)// Not more than one order
{
Alert("Several market orders. Expert Advisor is not working.");
return(0);// Exit()
}
}
}
ObjectSetText("Obj_Label", "TF" + Period() + ", " + DoubleToStr(price, 5) + ", tick " + TimeToStr(TimeCurrent(), TIME_SECONDS) + ", O@" + TimeToStr(Time[0], TIME_MINUTES) + ", NC@" + TimeToStr(NextClose, TIME_MINUTES) + " (" + MinutesToNextClose + " min)", 10, "Arial", DarkGreen );
ObjectSetText("Obj_Label2", "Orders:" + Total + ", delta " + DoubleToStr(Delta,5) + ", distance to MA:" + DoubleToStr(PriceBol_High, 5), 10, "Arial", DarkGreen );
ObjectSetText("Obj_Label3", "Orders: " + Total + ", Delta " + DoubleToStr(Delta,5) + ", distance to MA:" + DoubleToStr(PriceBol_Low, 5), 10, "Arial", DarkGreen );
// price analysis and order opening
if ((MathAbs(PriceBol_Low) < Delta) && (price > CurrBol_Low) && (Open[0] > CurrBol_Low+Delta) && (Total<1))
{
if (OrderSend(Symbol(), OP_BUY, 1.00,Bid , 3, 0, 0, "BO exp:900", 0,DoubleToStr(MinutesToNextClose,0), Green) >0) Print ("Opened OK");
else
{
err=GetLastError();
Print("error(",err,"));
return(0);
}
Print ("CALL @ " + price + " + TimeToStr(TimeCurrent(), TIME_SECONDS) + " exp in " + MinutesToNextClose);
}
if ((MathAbs(PriceBol_High) < Delta) && (price < CurrBol_High) && (Open[0] < CurrBol_High-Delta) && (Total<1))
{
if (OrderSend(Symbol(), OP_SELL, 1.00,Bid , 3, 0, 0, "BO exp:900", 0,DoubleToStr(MinutesToNextClose,0), Red) > 0) Print ("Opened OK");
else
{
err=GetLastError();
Print("error(",err,"));
return(0);
}
Print ("PUT @ " + price + " + TimeToStr(TimeCurrent(), TIME_SECONDS) + " exp in " + MinutesToNextClose);
}
//----
return(0);
}
//+------------------------------------------------------------------+
int Initialize_Objects(int Win) // User fie
{// .object creation
ObjectCreate("Obj_Label",OBJ_LABEL, Win, 0,0); // object creation
ObjectSet("Obj_Label", OBJPROP_CORNER, 0); // Bind to a corner
ObjectSet("Obj_Label", OBJPROP_XDISTANCE, 13); // X coordinate
if (Win==0)
ObjectSet("Obj_Label",OBJPROP_YDISTANCE, 15);//Y coordinate
else
ObjectSet("Obj_Label",OBJPROP_YDISTANCE,15);//Y Coordinate
ObjectCreate("Obj_Label2",OBJ_LABEL,Win, 0,0); // Object creation
ObjectSet("Obj_Label2",OBJPROP_CORNER, 0); // Binding to a corner
ObjectSet("Obj_Label2", OBJPROP_XDISTANCE, 13); // X coordinate
if (Win==0)
ObjectSet("Obj_Label2",OBJPROP_YDISTANCE, 35);//Y coordinate
else
ObjectSet("Obj_Label2",OBJPROP_YDISTANCE, 35);//Y Coordinate
ObjectCreate("Obj_Label3",OBJ_LABEL, Win, 0,0); // Create object
ObjectSet("Obj_Label3",OBJPROP_CORNER, 0); // Binding to a corner
ObjectSet("Obj_Label3", OBJPROP_XDISTANCE, 13); // X coordinate
if (Win==0)
ObjectSet("Obj_Label3",OBJPROP_YDISTANCE, 55);//Y coordinate
else
ObjectSet("Obj_Label3",OBJPROP_YDISTANCE, 55);//Y Coordinate
return(0);// Exit from user.function
}
Here are the warnings. I can't figure out what he doesn't like(
possible loss of data due to type conversion Bolinger_Bands_traider.mq4 51 24
implicit conversion from 'number' to 'string' Bolinger_Bands_traider.mq4 76 35
implicit conversion from 'number' to 'string' Bolinger_Bands_traider.mq4 76 227
implicit conversion from 'number' to 'string' Bolinger_Bands_traider.mq4 77 43
implicit conversion from 'number' to 'string' Bolinger_Bands_traider.mq4 78 43
implicit conversion from 'string' to 'number' Bolinger_Bands_traider.mq4 85 71
implicit conversion from 'number' to 'string' Bolinger_Bands_traider.mq4 93 23
implicit conversion from 'number' to 'string' Bolinger_Bands_traider.mq4 93 91
implicit conversion from 'string' to 'number' Bolinger_Bands_traider.mq4 99 72
implicit conversion from 'number' to 'string' Bolinger_Bands_traider.mq4 107 23
implicit conversion from 'number' to 'string' Bolinger_Bands_traider.mq4 107 91
0 error(s), 11 warning(s), compile time: 204 msec 1 12
Elementary. The error is theGetLots() function.The whole function.
Maybe you can tell me how to write it correctly. I wanted to calculate using loop by brute forcing from max lot.
Maybe you can tell me how to write it correctly. I wanted to calculate using a loop by trying from the maximum lot.
Where is the logic? You set the maximum allowed lot for the first order and then increase it for each successive order. Doesn't that seem to you, to put it mildly, not very sensible?
Further, you decrease the lot of the first order in the loop using some totally incomprehensible method, while the lots of the other orders that were "calculated" before remain unchanged, and these values do not go beyond the limits of this function. So, what do they do then?
Not to mention that the increment loop can't be a real number, it has to be a counter, an integer. But you set the lot value as a counter and subtract one from it each iteration. This is a major mistake, a very serious one.
Clarify the logic in your mind first and then try to implement it into your code.
But here are the warnings. I can not understand what he does not like(
possible loss of data due to type conversion Bolinger_Bands_traider.mq4 51 24
implicit conversion from 'number' to 'string' Bolinger_Bands_traider.mq4 76 35
implicit conversion from 'number' to 'string' Bolinger_Bands_traider.mq4 76 227
implicit conversion from 'number' to 'string' Bolinger_Bands_traider.mq4 77 43
implicit conversion from 'number' to 'string' Bolinger_Bands_traider.mq4 78 43
implicit conversion from 'string' to 'number' Bolinger_Bands_traider.mq4 85 71
implicit conversion from 'number' to 'string' Bolinger_Bands_traider.mq4 93 23
implicit conversion from 'number' to 'string' Bolinger_Bands_traider.mq4 93 91
implicit conversion from 'string' to 'number' Bolinger_Bands_traider.mq4 99 72
implicit conversion from 'number' to 'string' Bolinger_Bands_traider.mq4 107 23
implicit conversion from 'number' to 'string' Bolinger_Bands_traider.mq4 107 91
0 error(s), 11 warning(s), compile time: 204 msec 1 12
Output one line with number 51, as there is no count here to understand the error"possible loss of data due to type conversion Bolinger_Bands_traider.mq4 51 24"
The rest: "implicit conversion from 'number' to 'string' Bolinger_Bands_traider.mq4 107 91
translate numeric values into a text string where we create the object - a text string, for example
period()
it should be
DoubleToString(Period(),0)
translate the numeric values to a text string where we create a text string object, e.g.
period()
it should be
DoubleToString(Period(),0)
Since when is period a Double type?