#include <Trade\PositionInfo.mqh> //--- input patameter input ushort InpMaxPositions = 1; // number of orders CPositionInfo m_position; // trade position object //+------------------------------------------------------------------+ int total = 0; for(int i = PositionsTotal()-1; i >= 0; i--) if(m_position.SelectByIndex(i)) // selects the position by index for further access to its properties if(m_position.Symbol() == _Symbol) total++; if(total > InpMaxPositions) return; else { //--- your code } //+------------------------------------------------------------------+
franc_: I don't understand why this happens
if(smaData[1] > priceData[1].open && smaData[1] < priceData[1].close && …
Your signal exists for an entire candle. Either check for an existing position before opening a new one, or only process your signal once on a new bar.
For a new bar test, Bars is
unreliable (a refresh/reconnect can change number of bars on chart,) volume is unreliable (miss ticks,) Price is unreliable
(duplicate prices and
The == operand. - MQL4 programming forum.) Always use time.
I disagree with making a new bar function, because it can only be called once per tick. A variable can be tested multiple times.
New candle - MQL4 programming forum
I disagree with making a new bar function, because it can only be called once per tick. A variable can be tested multiple times.
New candle - MQL4 programming forum
franc_:
Tester or Demo?
can some body help me i want to make an EA that executes a trade when two EMA crossover and take profit at the next crossover while executing
other trades at the other crossover.
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 don't understand why this happens
https://imgur.com/a/qsr36lT (I don't know how to add images)
This is the code. Go to the end to see the buy programming.
The strategy uses sma, macd and parabolic sar. When the sma crosses a positive candle, the sar is below the sma and the macd is above zero, I send a buy operation.