This is the code i have to run EA based on an indicator which is connected by Icustom. Problem is it is fixed to put SL to object price 2 or 1 and i want to replace that with a fixed stop loss. Even though i implemented the min-max SL functions it didn't workout for me. Can someone help me it gets broken when i delete get_sl functions.
You just have to change the lines highlighted in green - assign _sl with a fixed value:
if(OrdersTotalT(OP_SELL)==0 && Ask>current_res && current_res!=last_res) { double _sl= MathAbs(current_res -get_res_sl())/_point; SendOrder(OP_SELL,_sl); last_res=current_res; } double _sup=get_sup(); if(OrdersTotalT(OP_BUY)==0 && Bid<_sup && _sup!= last_sup) { double _sl = MathAbs(_sup -get_sup_sl())/_point;// SendOrder(OP_BUY,_sl); last_sup=_sup; }
General rules and best pratices of the Forum. - General - MQL5 programming forum
Messages Editor
You just have to change the lines highlighted in green - assign _sl with a fixed value:
Thanks a lot for the answer will try to do that and can you show me an example please ?
I also want to change TP points and fix that as well.
Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Messages Editor
Ok i changed it thanks.
You just have to change the lines highlighted in green - assign _sl with a fixed value:
if(IsTesting())get_indi(); double current_res=get_res(); if(OrdersTotalT(OP_SELL)==0 && Ask>current_res && current_res!=last_res) { double _sl= MathAbs(current_res -assign_sl())/200; SendOrder(OP_SELL,_sl); last_res=current_res; } double _sup=get_sup(); if(OrdersTotalT(OP_BUY)==0 && Bid<_sup && _sup!= last_sup) { double _sl = MathAbs(_sup -assign_sl())/200;// SendOrder(OP_BUY,_sl); last_sup=_sup; }
I've edited like this but there is a function definition needed idk i that's correct.
Just made it thanks a lot for the help.
Seng Joo Thio
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
This is the code i have to run EA based on an indicator which is connected by Icustom. Problem is it is fixed to put SL to object price 2 or 1 and i want to replace that with a fixed stop loss. Even though i implemented the min-max SL functions it didn't workout for me. Can someone help me it gets broken when i delete get_sl functions.