A month's problem

 
Hi. I coded an expert to calculate the new lot size after every position. Problem is, the calculated lot is not used in the immediate next trade. It comes second. Can anyone help me find a better way of doing it? Seems I have been using a wrong approach, for way too long. I can't think no more. D(:
 
Nelson Wanyama:
Hi. I coded an expert to calculate the new lot size after every position. Problem is, the calculated lot is not used in the immediate next trade. It comes second. Can anyone help me find a better way of doing it? Seems I have been using a wrong approach, for way too long. I can't think no more. D(:

I bet some one will help you out when you post the code of your problem involved

 
Kenneth Parling:

I bet some one will help you out when you post the code of your problem involved

It's kinda complicated. I just need to know what one would to calculate the lot size before a trade. I'd post the code but I'm using a mobile right now
 
you can describe the equation too.
 
Nelson Wanyama:
Hi. I coded an expert to calculate the new lot size after every position. Problem is, the calculated lot is not used in the immediate next trade. It comes second. Can anyone help me find a better way of doing it? Seems I have been using a wrong approach, for way too long. I can't think no more. D(:
We need more info, but I suggest you to check Trade History functions, and use onTick(), EveryBar() functions. It must be the time when you execute the function you have
 
Nelson Wanyama:
Hi. I coded an expert to calculate the new lot size after every position. Problem is, the calculated lot is not used in the immediate next trade. It comes second. Can anyone help me find a better way of doing it? Seems I have been using a wrong approach, for way too long. I can't think no more. D(:

There are too many hidden data why you need it the second.. The idea is to broad to be answered. but if it's like that I guess having a 2nd variable would help you then

 

I managed. My lotsize was to be recalculated before a new position opens. I had to declare lot as a global variable, give it a value when no position is present, then reset it to zero when a position exists. Otherwise, the previous lot was being used before the lot was calculated for recently closed position. For trade execution function, I did this:

bool Trade(double &Ask, double &Bid)            // I have been having trouble with the m_symbol.Ask()|| __.Bid() returning zero.
{
        if(Lots==0)
                return(false);
}

Thank you everyone for you consistent help. 

Reason: