David Diez:
What do you mean does not make sense? Can you put the code ?
Have written averaging function to my new expert but for some reason does not make sense at Strategy Tester. I hope someone could help with this.
Marius Ovidiu Sunzuiana:
What do you mean does not make sense? Can you put the code ?
In the image you can see that result is the same despite the parameters.
What do you mean does not make sense? Can you put the code ?
David Diez: In the image you can see that result is the same despite the parameters.
Do you really expect an answer?
We can't see your broken code.
There are no mind readers here and our crystal balls are cracked.
William Roeder:
Do you really expect an answer? We can't see your broken code. There are no mind readers here and our crystal balls are cracked.
Do you really expect an answer? We can't see your broken code. There are no mind readers here and our crystal balls are cracked.
Just mix mugwort and rain water in a vile on the first Sunday after a full moon, pour it over your computer and re-run the EA
iRick:
This will help
😁
Just mix mugwort and rain water in a vile on the first Sunday after a full moon, pour it over your computer and re-run the EA
William Roeder:
Do you really expect an answer? We can't see your broken code. There are no mind readers here and our crystal balls are cracked.
Do you really expect an answer? We can't see your broken code. There are no mind readers here and our crystal balls are cracked.
if(AvDistance>0){ //--------------------------- Averaging LONG deal ---! double AveragingLong=NormalizeDouble(OpenPriceLong-(AvDistance*10)*Point,Digits); // PRICE TO START AVERAGING Print("OpenPrice LONG is ",OpenPriceLong);Print("Averaging LONG is ",AveragingLong); if(Ask<=AveragingLong){ Print("Averaging LONG under ",AveragingLong); Comment("Averaging LONG under ",AveragingLong); int FirstBuy=0,LastBuy=0; double FirstProfit=0,LastProfit=0; if(OrderSelect(0,SELECT_BY_POS,MODE_TRADES)){ // FIRST ORDER if(OrderType()==OP_BUY){ FirstBuy=OrderTicket(); FirstProfit=OrderProfit()+OrderSwap()+OrderCommission(); } } if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)){ // LAST ORDER if(OrderType()==OP_BUY){ LastBuy=OrderTicket(); LastProfit=OrderProfit()+OrderSwap()+OrderCommission(); } } if(LastProfit>=MathAbs(FirstProfit)*(1+AvOverlapping/100)){ // CONDITION CLOSE Print("FirstBuy profit is ",FirstProfit,", ticket ",FirstBuy); Print("LastBuy profit is ",LastProfit,", ticket ",LastBuy); if(OrderSelect(FirstBuy,SELECT_BY_TICKET,MODE_TRADES)){ if(!OrderClose(OrderTicket(),OrderLots(),Bid,3,clrNONE)){ Print("OrderClose error ",GetLastError()); RefreshRates(); return; } } if(OrderSelect(LastBuy,SELECT_BY_TICKET,MODE_TRADES)){ if(!OrderClose(OrderTicket(),OrderLots(),Bid,3,clrSilver)){ Print("OrderClose error ",GetLastError()); RefreshRates(); return; } } } } }
-
if(OrderSelect(0,SELECT_BY_POS,MODE_TRADES)){ // FIRST ORDER if(OrderType()==OP_BUY){ FirstBuy=OrderTicket(); FirstProfit=OrderProfit()+OrderSwap()+OrderCommission(); } }
Using OrdersTotal directly and/or no Magic number filtering on your OrderSelect loop means your code is incompatible with every EA (including itself on other charts and manual trading.)
Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 and MetaTrader 4 - MQL4 programming forum
MagicNumber: "Magic" Identifier of the Order - MQL4 Articles - What if there is no open orders?
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)){ // LAST ORDER
No value given to i.- "Doesn't make sense" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. We can't see your broken code. There are no mind readers here and our crystal balls are cracked.
William Roeder:
i is last order, but probably meaningless.
-
Using OrdersTotal directly and/or no Magic number filtering on your
OrderSelect loop means your code is incompatible with every EA (including itself on other charts and manual
trading.)
Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 and MetaTrader 4 - MQL4 programming forum
MagicNumber: "Magic" Identifier of the Order - MQL4 Articles - What if there is no open orders?
- No value given to i.
- "Doesn't make sense" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. We can't see your broken code. There are no mind readers here and our crystal balls are cracked.
David Diez:
i is last order, but probably meaningless.
last order is OrdersTotal()-1i is last order, but probably meaningless.
You better use a loop for your orders
ffoorr: last order is OrdersTotal()-1
Using OrdersTotal directly and/or no Magic number filtering on your
OrderSelect loop means your code is incompatible with every EA (including itself on other charts and manual
trading.)
Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 and MetaTrader 4 - MQL4 programming forum
MagicNumber: "Magic" Identifier of the Order - MQL4 Articles
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
Have written averaging function to my new expert but for some reason does not make sense at Strategy Tester. I hope someone could help with this.