Broker digits Vs Symbol digits HowTo ?

 

I want my EA to work seamlessly with 4-digit brokers and 5-digit brokers

AND

4-digit and 2-digit symbols (E.g EURUSD and USDJPY) with 4-digit brokers

AND

5-digit and 3-digit symbols (E.g EURUSD and USDJPY) with 5-digit brokers

AND

have external decimal pip values (E.g TP = 20.0 pips) work correctly in all cases.

Have tried various solutions but the whole thing got fairly messy and in the end

it didn't work anyhow.

Any general guidelines, maybe some code examples ?

 
Create power factor
int MyPoint;
if(Digits==3||Digits==5)MyPoint=10; else MyPoint=1;
then put it everywhere you calculate pips, like this:
OrderSend(Symbol(),OP_SELL,lots,Bid,5*MyPoint,Ask+SL*Point*MyPoint,Ask-TP*Point*MyPoint,"",0,0,CLR_NONE);
 

That simple?

May have to Mul by 10 to get decimal pips...

I'll check it out.

Reason: