The variables with iInFront are global variables. Just check the variable iAllProfit after the function call.
int Count_Total_Magic_Symbol(){ //~~~~~~~~~~~~~~~ iAns=0; iAllProfit=0; iAllSize=0; //~~~~~~~~~~~~~~~ for(i=OrdersTotal()-1; i>=0; i--){ if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)){ if(OrderMagicNumber()==iMagic && OrderSymbol()==iSymbol_){ iAns++; iAllProfit+=OrderProfit(); iAllSize+=OrderLots();}}} return(iAns);}
The variables with iInFront are global variables. Just check the variable iAllProfit after the function call.
thanks .
I programed like this before ...
but it return value is 0 . I want to study it why it works fail ... can u tell me,plase ?
double OrdersProfitsSumUp()
{
double sum=0;
int total = OrdersTotal();
for(int i=total-1;i>=0;i--)
{
OrderSelect(i, SELECT_BY_POS);
if(OrderSymbol()==Symbol())
{
if(OrderMagicNumber()==MN)
{
if(symbolprofit_orders[i]!=0)
{
symbolprofit_orders[i]=OrderProfit();
}
}
}
sum+=symbolprofit_orders[i];
}
return(sum);
}
Perhaps it cannot go pass this if(symbolprofit_orders[i]!=0) because the array value equals 0. Try debugging, after the first if{statement} put a Alert( "Code_Made_It_This_Far" ), run it through the back-tester. If the Alert triggers on the first If, move it down to the next If and so-on. You can sometimes start from the inner If and work you way outward if you think the problem lies there. You can also Alert values like Alert( symbolprofit_orders[i] ). Alert, Prints within the back-tester. It's probably better to use Print on live charts it you don't want the pop-ups.
Also, I cannot see your Array Declaration. Did you give the Array a proper size? Are you re-sizing the Array to allow for more data. You have to manage Array resources yourself otherwise it'll not work. Good Luck.
Perhaps it cannot go pass this if(symbolprofit_orders[i]!=0) because the array value equals 0. Try debugging, after the first if{statement} put a Alert( "Code_Made_It_This_Far" ), run it through the back-tester. If the Alert triggers on the first If, move it down to the next If and so-on. You can sometimes start from the inner If and work you way outward if you think the problem lies there. You can also Alert values like Alert( symbolprofit_orders[i] ). Alert, Prints within the back-tester. It's probably better to use Print on live charts it you don't want the pop-ups.
Also, I cannot see your Array Declaration. Did you give the Array a proper size? Are you re-sizing the Array to allow for more data. You have to manage Array resources yourself otherwise it'll not work. Good Luck.
Thanks for your advises, I debuging though the script, run it directly and I know the problem lies
if(symbolprofit_orders[i]!=0)
{
symbolprofit_orders[i]=OrderProfit();
}
,I try to retuen OrderProfit(),the value is correct, but when I symbolprofit_orders[i]=OrderProfit();, then it returns value is 0 .
Why do you need the Array variable? When a normal variable will do the same job.
I am sorry, I am newbie in this area ..... so ..my knowlegde is limited ... and ask for help here,...
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
good day
if i opened two symbol orders,how to sum up a certain symbol orders' profit,now mmatter it is 0- or 0+ .
waiting ....
kindly regard .