voidOnTick()
{
// Получим значение индикатора
dMA = iMA(Symbol(), 0,PeriodMA, MovingShift, MODE_SMA, PRICE_CLOSE, 0); // MODE_SMA - простое усреднение , значение 0. PRICE_CLOSE- цена закрытия, значение 0. TrailingOrders();// Если нет открытых ордеров, то входим в условиеif(CountOrders()==0)
{
// Если появился сигнал на покупку, то откроем ордер на покупкуif(bSignalBuy() == true)
vOrderOpenBuy();
// Если появился сигнал на продажу, то откроем ордер на продажуif(bSignalSell() == true)
vOrderOpenSell();
}
DrawLABEL("nextlot",1,5,0,Color1(),StringConcatenate("CURRENT LOT: ",DoubleToStr(LOT(),2)));
DrawLABEL("currentlot",1,5,0,Color2(),StringConcatenate("NEXT LOT: ",DoubleToStr(LOT(),2)));
}
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
You set it correctly. Did you change something inside TrailingOrders() function?
I changed it and put it "as is" and the result was the same.
I've changed it and put it "as is" and the result is the same.
We need to see the input parameters, because according to the log the trawl works correctly
2021.12.24 16:10:14.788 2021.12.17 00:00:00 111 - copy: Lot=0.01; StopLoss=200; TakeProfit=560; Slippage=3; Magic=1; K_Martin1=0.01; K_Martin2=1.9; K_Martin3=1.4; OrdersClose=3; OrdersClose2=5; DigitsLot=2; PeriodMA=21; MovingShift=1;
2021.12.24 16:10:14.788 2021.12.17 00:00:00 111 - copy: Lot=0.01; StopLoss=200; TakeProfit=560; Slippage=3; Magic=1; K_Martin1=0.01; K_Martin2=1.9; K_Martin3=1.4; OrdersClose=3; OrdersClose2=5; DigitsLot=2; PeriodMA=21; MovingShift=1;
maybe i put the function in the code incorrectly?
and put the function itself separately
have I put the function in the code incorrectly?
and put the function itself separately
The trail is correct.
Try it like this
The trolley is standing correctly.
Try this.
take off into space
stop stops first, then instantly flies into space along with the take (closing the order on the way)
this is not the issue as i understand it.
correct me if I am wrong: void OnTick()
if there are no open orders and there is a signal, then vOrderOpenBuy() / vOrderOpenSell()
Then comes void vOrderModify(int iOTi) - i.e. they set stops and takei and then check for errors.
That is, until the order closes at a stop or a take, it isn't possible to correct it in terms of trailing.
You need one (maximum two) multiple of stop and take.
If you want to change the trailing stop and take a profit, then you should do it manually.
i'm still thinking how to implement it.
take off into space
the stop first stands, then instantly flies into space after the take (closing the order on the way)
This is not the point, as I understand it.
correct me if I am wrong: void OnTick()
if there are no open orders and there is a signal, then vOrderOpenBuy() / vOrderOpenSell()
Then comes void vOrderModify(int iOTi) - i.e. they set stops and takei and then check for errors.
That is, until the order closes at stop or take, it isn't possible to correct it in terms of trailing.
You need one (maximum two) multiple of stop and take.
If you want to change the trailing stop and take a profit, then you should do it manually.
i'm still thinking how to implement it.
Corrected
take off into space
the stop first stands, then instantly flies into space followed by the take (closing the order on the way)
That's because your rules are not working:
Forum on trading, automated trading systems and testing of trading strategies.
Any questions from newbies on MQL4 and MQL5, help and discussion of algorithms and codes
Mihail Matkovskij, 2021.12.23 22:01
In general, the rules are as follows.
They would have been done a long time ago and nailed it. But no...
I couldn't help but find a ready-made example:https://www.mql5.com/ru/code/30808
And an article: https://www.mql5.com/ru/articles/134
Although it's complicated for beginners but I think you will manage it if you are really interested in the subject.
Corrected
Thank you!
I didn't know you could put a double inside a void function
That's because your rules don't work:
You should have done it a long time ago and scored. But no...
I couldn't stand it and found you a ready-made example:https://www.mql5.com/ru/code/30808
And an article:https://www.mql5.com/ru/articles/134
It may be complicated for beginners but I think you will understand it if you are really interested in the subject.
Thank you