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
Script "CloseAllPositions" - example class CTrade, method PositionClose (Closes a position with the specified ticket):
Kusmayadi
void OnTick()
{
string signal="";
double KArray[];
double KArray[];
ArraySetAsSeries(KArray,true);
ArraySetAsSeries(DArray,true);
int StochasticDefinition=iStochastic(_Symbol,_Period,14,3,3 MODE_SMA,STO_LOWHIGH);
CopyBuffer(StochasticDefinition,0,0,3,KArray);
CopyBuffer(StochasticDefinition,1,0,3,DArray);
double KValue0=KArray[0];
double KValue0=KArray[0];
double KValue0=KArray[1];
double KValue0=KArray[1];
if (KValue0<20&&DValue<20)
if ((KValue0>DValue0<20) && (KValue1<DValue1))
{
signal="buy";
if (KValue0>80&&DValue>80)
((KValue0>80&&DValue>80) && (KValue1>DVlue1))
{
signal="sell";
}
//Chart output
Comment ("Signal: ",signal);
}
thank you for this code ,
it look work , but how to avoid rejected ??
2019.05.31 10:59:16.731 testClose (EURUSD_,H1) CTrade::OrderSend: instant buy 0.01 position #49458 EURUSD_ at 1.11356 [rejected]
thank you for this code ,
it look work , but how to avoid rejected ??
2019.05.31 10:59:16.731 testClose (EURUSD_,H1) CTrade::OrderSend: instant buy 0.01 position #49458 EURUSD_ at 1.11356 [rejected]
https://www.mql5.com/en/docs/standardlibrary/tradeclasses/ctrade/ctradesetdeviationinpoints
PositionClose(PositionGetSymbol(i),0.1)) add 0.1=deviation
try it!
Example: Close on time . One clarification - the EA works only with the current symbol and the specified Magic number. If you want to close all-all positions, just comment out the lines with the symbol filter and Magic number.
hi, Can anyone check what is going wrong with the closing of the positions here? This is the code I written , its not working.
hi, Can anyone check what is going wrong with the closing of the positions here? This is the code I written , its not working.
Mistake number 1: the indicator handle SHOULD BE CREATED ONLY ONCE - it should be done in OnInit () !!!
Please correct this error first. Then you can look further.
Hi Vladimir,
I am having the same problem, my code doesnt work.
Update: Above code works, function was never called. I have also on issue with the PCSv9. If someone knows PCSv9 I would like to hire her/him.