Shure, code is ok, but notice that in the extremely rar case when ma20==ma40 mas will be false..
i prefer:
if(ma20>ma50){ }else if(ma20<ma50){ }
but that is personal coding style. your code is valid and nicely readable..
trader201:
is this code ok? (bool variable in declaration and in the code). Am I saying here, correctly, trade if sma20>sma40?
here is the code:
double ma20=iMA(NULL,0,20,0,MODE_SMA,PRICE_MEDIAN,1);
double ma40=iMA(NULL,0,13,0,MODE_SMA,PRICE_MEDIAN,1);
bool mas=ma20>ma40;
if (mas=true)
{
ordersend(...);
}
is ok?
Thanks again
trader201
It's not actually ok. You are doing an assignment in the if statement rather than a test.
if( mas==true ){ // do stuff } else{ // do other stuff } ... OR if( mas ){ // do stuff } else{ // do other stuff }
when you use a bool variable there is no need to compare it to true or false.

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
is this code ok? (bool variable in declaration and in the code). Am I saing here, correctly, trade if sma20>sma40?
here is the code:
double ma20=iMA(NULL,0,20,0,MODE_SMA,PRICE_MEDIAN,1);
double ma40=iMA(NULL,0,13,0,MODE_SMA,PRICE_MEDIAN,1);
bool mas=ma20>ma40;
if (mas=true)
{
ordersend(...);
}
is ok?
Thanks againg
trader201