An example of an adviser that closes all positions: Close all positions
The command that starts the uninstall:
m_close_all=true;
then we check: if the flag , and check whether the positions remained in the market or not and then delete the positions
//| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { if(m_close_all) { if(IsPositionExists()) CloseAllPositions(); else m_close_all=false; } //--- we work only at the time of the birth of new bar static datetime PrevBars=0; datetime time_0=iTime(Symbol(),Period(),0); if(time_0==PrevBars) return; //--- if(ProfitAllPositions()>=InpProfit) m_close_all=true; }
Thanks for the input I now almost made it work like this:
But with this closing of trade it now makes:
"i" - undeclared identifier
Anyone know how to fix this position close on symbol?
void Exit(){ trade.PositionClose(PositionGetSymbol(i),0.1);}
void Exit(){ for(int i=1;i<PositionsTotal();i++) trade.PositionClose(PositionGetSymbol(i),0.1);}
right now I use this and it does not make any errors.
but trades are not closing.. anyone can fix this?
bool EXITRSIAllowsTrade(){ double exitrsi = iRSI(_Symbol,_Period,RSIPERIODexit,applied_price2exit); double iRSIBuffer[]; CopyBuffer(exitrsi,0,0,1,iRSIBuffer); if(iRSIBuffer[0] > RSIMinexit) { return true; } return false;}
this is the bool that I am using as a criteria to exit
right now I use this and it does not make any errors.
but trades are not closing.. anyone can fix this?
this is the bool that I am using as a criteria to exit
You define the iRSIBuffer array. But you do not set it as a time series. This means that iRSIBuffer[0] contains the oldest data element. If you set iRSIBuffer as a time series then iRSIBuffer[0] will contain the most recent RSI value.
Oh thanks, I was doing it like this for all my indicators.. how do I add a time series?
Thank you for this big find!
Oh thanks, I was doing it like this for all my indicators.. how do I add a time series?
Thank you for this big find!
You can find the answer to your question in the documentation: https://www.mql5.com/en/docs/array
ArraySetAsSeries.

- www.mql5.com

- 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 Guys,
For my EA I am using Bool function criteria's with return True/False to meet Buy requirement for example:
Now I want to make the same function but then to close trade on symbol.\
I know this following Void Exit part is wrong, someone can give a help?