Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 1139
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
I open ten weekly charts of currency pairs in MT5 and the terminal loads 800 megabytes of tick history. It is constantly loaded, though there are almost no changes on the charts. The question is why I need tick history, if I use only weekly charts? By the way, on MT4 weekly charts open instantly without any delay.
this is a feature of mt5 - load everything on m1 and then build the required period... ....
and so each time, for each symbol
The idea of the EA is to buy or sell when the price touches a horizontal level or a manually drawn trend line. I made an EA out of different working EAs and indicator. But the EA does not work. Or rather, it only opens SELL without any signal on the first tick. What is wrong?
/+------------------------------------------------------------------+
//| |
//| Copyright © 2010, MetaQuotes Software Corp.
//| http://www.mql4.com/ru/users/rustein |
//+------------------------------------------------------------------+
#define MAGIC 131313 //open inward channel
//---------------------------------------
extern inttern TF=15;
//+------------------------------------------------------------------+
extern int StopLoss = 300;
//--------------------------------------------
extern double TakeProfit = 3000;
//--------------------------------------
extern int Per_MA= 20;
//---- constants
#define OP_BUY_ 0
#define OP_SELL_ 1
//-------------------------------------------------------------------+
extern double Lots = 0.1;
extern double MaximumRisk = 1;
extern double DecreaseFactor = 0;
bool b_1=true, s_1=true;
//+------------------------------------------------------------------+
//| Calculate open positions |
//+------------------------------------------------------------------+
double MA=iMA(NULL,TF,Per_MA,0,0,0,1);
int CalculateCurrentOrders(string symbol)
{
int buys=0,sells=0;
//----
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC)
{
if(OrderType()==OP_BUY) buys++;
if(OrderType()==OP_SELL) sells++;
}
}
//---- return orders volume
if(buys>0) return(buys);
else return(-sells);
}
//+------------------------------------------------------------------+
//| Calculate optimal lot size |
//+------------------------------------------------------------------+
double LotsOptimized()
{
double lot=Lots;
int orders=HistoryTotal(); // history orders total
int losses=0; // number of losses orders without a break
//---- select lot size
//lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/1000.0,2);
lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/100/MarketInfo(Symbol(),MODE_TICKVALUE)/StopLoss,2);
//---- calcuulate number of losses orders without a break
if(DecreaseFactor>0)
{
for(int i=orders-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) { Print("Error in history!"); break; }
if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL) continue;
//----
if(OrderProfit()>0) break;
if(OrderProfit()<0) losses++;
}
if(losses>1) lot=NormalizeDouble(lot-lot*losses/DecreaseFactor,2);
}
//---- return lot size
if(lot<0.01) lot=0.01;
return(lot);
}
//-------------------------------------------------
/* this part from the indicator
int CheckBreakoutLines(int shift)
{
// Total Objects
int obj_total = ObjectsTotal();
// Time of bar
datetime now = Time[shift];
// Iterate
for(int i = obj_total - 1; i >= 0; i--)
{
// Object name
string label = ObjectName(i);
// Types
int OType = ObjectType(label);
bool trendline = false;
bool hline = false;
// Price to evaluate
double cprice = 0;
// Trendlines
if(OType == OBJ_TREND )
{
bool ray = ObjectGet(label, OBJPROP_RAY);
if(!ray)
{
datetime x1 = ObjectGet(label, OBJPROP_TIME1);
datetime x2 = ObjectGet(label, OBJPROP_TIME2);
if(x1 < now && x2 < now) continue;
}
cprice = GetCurrentPriceOfLine(label, shift);
trendline = true;
} else if(OType == OBJ_HLINE ) {
cprice = ObjectGet(label, OBJPROP_PRICE1);
hline = true;
} else {
continue;
}
// Breakouts and false breakouts of trendlines and hlines
if(MA>cprice &&Ask<cprice)
{
if(trendline) { return(OP_BUY_); } else if(hline) { return(OP_BUY_); }
} else if(MA>cprice &&Ask<cprice) {
if(trendline) { return(OP_SELL_); } else if(hline) { return(OP_SELL_); }
}
}
return(EMPTY_VALUE);
}
double GetCurrentPriceOfLine(string label, int shift)
{
double price1 = ObjectGet(label, OBJPROP_PRICE1);
double price2 = ObjectGet(label, OBJPROP_PRICE2);
datetime d1 = ObjectGet(label, OBJPROP_TIME1);
datetime d2 = ObjectGet(label, OBJPROP_TIME2);
int shiftfrom = iBarShift(Symbol(), 0, d1, false);
int shiftto = iBarShift(Symbol(), 0, d2, false);
int lapse = MathAbs(shiftto - shiftfrom);
int distance = MathAbs(shift - shiftfrom);
double pendiente = (price2 - price1) / lapse;
double cpoint = price1 + (distance * pendiente);
return(cpoint);
}
//-------------------------------------------------------------------------------------------------------------
//+------------------------------------------------------------------+
//| Check for open order conditions |
//+------------------------------------------------------------------+
void CheckForOpen()
{
int res;
//--------------------------------------------------------------------+
//--------------------------------------------------------------------+
//---- buy conditions
if(OP_BUY_&&b_1)
{
res=OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,3,Ask-(StopLoss*Point),Ask+TakeProfit*Point," VV",MAGIC,0,Green);
b_1=false; s_1=true;
return;
}
//---- sell conditions
if(OP_SELL_&&s_1)
{
res=OrderSend(Symbol(),OP_SELL,LotsOptimized(),Bid,3,Bid+(StopLoss*Point),Bid-TakeProfit*Point," VV",MAGIC,0,Red);
s_1=false;b_1=true;
return;
}
//----
}
//+------------------------------------------------------------------+
//| Start function |
//+------------------------------------------------------------------+
void start()
{
//---- check for history and trading
if(Bars<100 || IsTradeAllowed()==false) return;
//---- calculate open orders by current symbol
if(CalculateCurrentOrders(Symbol())==0) CheckForOpen();
}
//+------------------------------------------------------------------+
//|---------------------------// END //------------------------------|
//+------------------------------------------------------------------+
The idea of the EA is to buy or sell when the price touches a horizontal level or a manually drawn trend line. I made an EA out of different working EAs and indicator. But the EA does not work. Or rather, it only opens SELL without any signal on the first tick. What is wrong?
/+------------------------------------------------------------------+
//| |
//| Copyright © 2010, MetaQuotes Software Corp.
//| http://www.mql4.com/ru/users/rustein |
//+------------------------------------------------------------------+
#define MAGIC 131313 //open inward channel
//---------------------------------------
extern inttern TF=15;
//+------------------------------------------------------------------+
extern int StopLoss = 300;
//--------------------------------------------
extern double TakeProfit = 3000;
//--------------------------------------
extern int Per_MA= 20;
//---- constants
#define OP_BUY_ 0
#define OP_SELL_ 1
.....................................
.....................................
//---- check for history and trading
if(Bars<100 || IsTradeAllowed()==false) return;
//---- calculate open orders by current symbol
if(CalculateCurrentOrders(Symbol())==0) CheckForOpen();
}
//+------------------------------------------------------------------+
//|---------------------------// END //------------------------------|
//+------------------------------------------------------------------+
Loaded the program into notepad and deleted the blank lines. It became possible to cover with a glance. Pressed the SRC button and pasted. Here's what came up. 1) Why would you need to define
if we already have OP_BUY=0 and OP_SELL=1
2) The root of all evil is in this fragment. One and the same condition (MA>cprice &&Ask<cprice) is checked twice, and different decisions are taken.
3) After that each branch performs checks but the result is still the same
Generally speaking, the above line can be simplified and written as follows
if(trendline)return OP_BUY; if(hline) return OP_BUY; или еще проще if(trendline or hline) return OP_BUY;
Loaded the programme into notepad and deleted the blank lines. It became possible to cover with a glance. Pressed the SRC button and pasted. Here's what came up. 1) Why would you need to define
if we already have OP_BUY=0 and OP_SELL=1
2) The root of all evil is in this fragment. One and the same condition (MA>cprice &&Ask<cprice) is checked twice, and different decisions are taken.
3) After that each branch performs checks but the result is still the same
The line above can be simplified and written as follows
Thanks for the reply, but it still opens only SELL, as I see it since OP_SELL = 1. This condition is always satisfied. I rewrote it like this
The orders have stopped opening, in my opinion, int CheckBreakoutLines(int shift) does not work.
Dear Professionals. What should I do before installing MT4 or after it so that afterwards the quotes history will be written/read from any disk except the system disk or it is NOT possible?
MT4 from all brokers dump everything to C:\Users\MAN\AppData\Roaming\MetaQuotes\Terminal\100.......001\history\downloads (for each broker and for each their terminal respectively). Two MT4 at two brokers for 3-4 pairs ate 25 GB, i.e. all free memory. Also the necessary quotes are loaded in the tester C:\Users\.......\tester\history.
Please help advice, not taking into account reinstalling Windows(I have 7) with reallocation of disk sizes. Maybe I'm doing something wrong? If I missed it and it's already been discussed somewhere - please throw a link at me...
Thanks in advance.
Dear Professionals. What should I do before installing MT4 or after it so that afterwards the quotes history will be written/read from any disk except the system disk or it is NOT possible?
MT4 from all brokers dump everything to C:\Users\MAN\AppData\Roaming\MetaQuotes\Terminal\100.......001\history\downloads (for each broker and for each their terminal respectively). Two MT4 at two brokers for 3-4 pairs ate 25 GB, i.e. all free memory. Also the necessary quotes are loaded in the tester C:\Users\.......\tester\history.
Please help advice not taking into account reinstalling Windows(I have 7) with reallocation of disk sizes. Maybe I'm doing something wrong? If I missed it and it's already been discussed somewhere - please throw a link at me...
Thanks in advance.
Simply copy the whole terminal folder to a non-system drive, create a shortcut to it and write the /portable switch
Simply copy the entire terminal folder to a non-system drive, create a shortcut to it and use the /portable switch
Thank you.