&(PriceInfoEURUSD[0].close==PriceInfoEURUSD[HighestCandleEURUSD].high))
Doubles
are rarely equal. Understand the links in: The == operand. - MQL4 programming forum
Doubles are rarely equal. Understand the links in:
The == operand. - MQL4 programming forum
I agree with you.
is it actually "safe" to use CExpertTrade class then?
//+------------------------------------------------------------------+ //| Easy LONG trade operation | //+------------------------------------------------------------------+ bool CExpertTrade::Buy(double volume,double price,double sl,double tp,const string comment="") { double ask,stops_level; //--- checking if(m_symbol==NULL) return(false); string symbol=m_symbol.Name(); if(symbol=="") return(false); //--- ask=m_symbol.Ask(); stops_level=m_symbol.StopsLevel()*m_symbol.Point(); if(price!=0.0) { if(price>ask+stops_level) { //--- send "BUY_STOP" order return(OrderOpen(symbol,ORDER_TYPE_BUY_STOP,volume,0.0,price,sl,tp, m_order_type_time,m_order_expiration,comment)); } if(price<ask-stops_level) { //--- send "BUY_LIMIT" order return(OrderOpen(symbol,ORDER_TYPE_BUY_LIMIT,volume,0.0,price,sl,tp, m_order_type_time,m_order_expiration,comment)); } } //--- return(PositionOpen(symbol,ORDER_TYPE_BUY,volume,ask,sl,tp,comment)); }
when stops_level is 0.0 (and it is very often, at least in my implementation), only if two double numbers (price and bid) are equal, sell order at
market price is placed, otherwise, sell stop or sell limit order are opened.
it seems very unreliable to me, exactly due to comparison of two double numbers.
any experience (positive or negative) with that?
Hi,
I'm trying to write a code that can trade 4 currency pairs at a time, but I only want a maximum of 1 position per currency pair open at any given moment.
However, I do not know which Function I should be using for such an instruction.
I am currently using PositionsTotal()<4 to prevent more than 4 open trades from happening at any time.
Is there any function or method that can instruct the EA to have only a maximum of 1 unique currency pair open at any given time?
This is my current code for criteria to open and execute a Buy trade.
Any advice will be greatly appreciated! Thank you! :)
i included parts of this library for exactly this reason, it provides you classes to access positions grouped by symbol, magic number and
other criteria.
Check CPosition class
- www.mql5.com
please how do you include this libary
Mine, I want to Opening only 1 trade per currency pair at a time but with a maximum number of 4 different pairs
i used this
// Specific parameter controlling which positions are allowed
ExtExpert.SetAvailablePositions(Inp_Allowed_Positions);
if someone can help me with code and where to place it, I will appreciate deeply.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I'm trying to write a code that can trade 4 currency pairs at a time, but I only want a maximum of 1 position per currency pair open at any given moment.
However, I do not know which Function I should be using for such an instruction.
I am currently using PositionsTotal()<4 to prevent more than 4 open trades from happening at any time.
Is there any function or method that can instruct the EA to have only a maximum of 1 unique currency pair open at any given time?
This is my current code for criteria to open and execute a Buy trade.
Any advice will be greatly appreciated! Thank you! :)