extern int MartinStep = 2; extern double LOT = 0.01;
double GetLot(){
int time = 0;double profit = 0; double lots = 0; double Lot = 0; for(int i = OrdersHistoryTotal()-1;i>=0;i--){ if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)){ if(OrderSymbol() == Symbol()&& OrderMagicNumber() == Magic){ if(time<OrderCloseTime()){ time=OrderCloseTime(); profit=OrderProfit(); lots = OrderLots(); } } } }
if(profit == 0 &&time == 0) { Lot = LOT; } if(profit >= 0) { Lot = LOT; } if(profit < 0 ) { Lot = NormalizeDouble (lots*MartinStep,2); }
return(Lot); }
Please help to correct errors in function. The EA opens several orders correctly, and then the log shows an error "invalid lots amount". I can not understand what is wrong.
Please help to correct errors in function. The EA opens several orders correctly, and then the log shows an error "invalid lots amount". I can not understand what is wrong.
Either I have never got to operator lots = OrderLots(); and lots still remain =0. Or lots*MartinStep exceeded maximal allowed lot size.
Hi all! Can you tell me how to implement EA re-initialization at the end of the day? Well, in init() there are some actions that need to be repeated at a certain time. I don't want to rewrite them in start(). I am more interested in the theoretical possibility of restarting the EA. Thank you in advance.
Hi all! Can you tell me how to implement EA re-initialization at the end of the day? Well, in init() there are some actions that need to be repeated at a certain time. I don't want to rewrite them in start(). I am more interested in the theoretical possibility of restarting the EA. Thank you in advance.
Would you please tell me if the flags and static variables are reset or remain in the EA's memory when restarting the EA (remove it from the chart and then put it back on again)?
Forexman77: Would you please tell me if the flags and static variables are reset or remain in the EA's memory when restarting the EA (remove it from the chart and then put it back on again)?
During initialization everything is reset, except Global Variables
extern int MartinStep = 2;
extern double LOT = 0.01;
double GetLot(){
int time = 0;double profit = 0; double lots = 0; double Lot = 0;for(int i = OrdersHistoryTotal()-1;i>=0;i--){
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)){
if(OrderSymbol() == Symbol()&& OrderMagicNumber() == Magic){
if(time<OrderCloseTime()){
time=OrderCloseTime();
profit=OrderProfit();
lots = OrderLots();
}
}
}
}
if(profit == 0 &&time == 0)
{
Lot = LOT;
}
if(profit >= 0)
{
Lot = LOT;
}
if(profit < 0 )
{
Lot = NormalizeDouble (lots*MartinStep,2);
}
return(Lot);
}
lots = OrderLots();
Lot = NormalizeDouble (lots*MartinStep,2);Either I have never got to operator lots = OrderLots(); and lots still remain =0. Or lots*MartinStep exceeded maximal allowed lot size.
I figured it out, the error is here
Hi all! Can you tell me how to implement EA re-initialization at the end of the day? Well, in init() there are some actions that need to be repeated at a certain time. I don't want to rewrite them in start(). I am more interested in the theoretical possibility of restarting the EA. Thank you in advance.
Hi all! Can you tell me how to implement EA re-initialization at the end of the day? Well, in init() there are some actions that need to be repeated at a certain time. I don't want to rewrite them in start(). I am more interested in the theoretical possibility of restarting the EA. Thank you in advance.
Would you please tell me if the flags and static variables are reset or remain in the EA's memory when restarting the EA (remove it from the chart and then put it back on again)?
During initialization everything is reset, except Global Variables
Everything is reset during initialisation except Global Variables
Everything is reset during initialisation except Global Variables