sub-pip pricing/pipettes

 

hi

big headach on this part pip stuff - please u help?

also

need knowledge on multi symbol ea - metaquotes talk but never see any hard facts - just atc blags on how some using multisym ea's but no real info..

1. If i do MODE_DIGITS on many pairs, i get answers of 3 or 5

If do MODE_POINT on same pairs, for ones that give 3 Digits i get Point of 0.001

BUT for pairs that give 5 Digits i get Point = 0

i use Alapri, i find thread on 4 or 5 pips stuff and they give no answer

2. bid/ask prices are shown in marketinfo as 2 or 4 digits.

so i have SL=13, unless I *10 when add to normalized price using Point - is like 1.3 SL which wrong.

so how should i now use Point?

maybe have global gPoint = Point/10 ?

but not like.

is numbers in code - wat happen broker change to say 4 or 6 digits?

my code break.

U got ideas for runtime calcs setup Point so SL/TP work on eg, 2 or 4 digits.

3. is currently used 3rd/5th decimal digit just for finer spreads? and if so this mean should work 2 or 4 digits for SL/TP?

4. am confusued on workings of all this with mt.

I do multisymbol ea. process many pairs. must remap its internal self to each working on pair - then go on like just default pair/period.

5. so how others do multisymbol ea?

thank you

 

fbj

Not 100% sure of the question but this may be the answer, to that and other questions!

A generic function to handle variations in all sorts of things between orders including server errors - enjoy :)

-BB-

int OpenAtMarket (string strPair, int iOrderType, double dLots, int iStopLossPips, int iTakeProfitPips, string strOrderComment, int iMagicNumber, datetime dtExpiry, color cColour, int iNR, int iMTS)
{
 int iMaxNumRetries, iNumRetries=iNR;
 double dPrice, dSL, dTP;
 
    // is server or context busy - try n times to submit the order
    iNumRetries=iNR;
    
     if(iOrderType > OP_SELL)
      {
        Print("OpenAtMarket Error: OrderType is a Pending Order!");
        return(0);
      }
     
    while(iNumRetries>0)
    {
        RefreshRates();
        if(iOrderType==OP_BUY) 
          {
           dPrice=NormalizeDouble(Ask, Digits);
           dSL=NormalizeDouble(dPrice-iStopLossPips*Point, Digits);
           dTP=NormalizeDouble(dPrice+iTakeProfitPips*Point, Digits);
          }
          
        if(iOrderType==OP_SELL) 
           {
            dPrice=NormalizeDouble(Bid, Digits);
            dSL=NormalizeDouble(dPrice+iStopLossPips*Point, Digits);
            dTP=NormalizeDouble(dPrice-iTakeProfitPips*Point, Digits);           
           }
    
        int iTicket =  OrderSend(strPair, iOrderType, dLots, dPrice, Slippage, dSL, dTP, strOrderComment, iMagicNumber, dtExpiry, cColour);
 
        iNumRetries--;
 
        if(iTicket == -1 )
        {
            int iError = GetLastError();
 
            // retry if error is "busy", otherwise give up
            if(iError==ERR_SERVER_BUSY || iError==ERR_TRADE_CONTEXT_BUSY || iError==ERR_BROKER_BUSY || iError==ERR_NO_CONNECTION 
            || iError==ERR_TRADE_TIMEOUT || iError==ERR_INVALID_PRICE || iError==ERR_OFF_QUOTES || iError==ERR_PRICE_CHANGED || iError==ERR_REQUOTE)
                Sleep(iMTS);
            else
            {
                iNumRetries = 0;
                Print("OpenAtMarket: OrderSend Error ", iError );
            }
        }
        else
            iNumRetries = 0;
    }
 
    return(iTicket);
}
 

hey, u great spirit boost - share code! :)

ok, my act i gotta clean up to make btr 'talki talki' - be not layzy on kybrd - be more to point ;)

code is global - talk is not so easy but maybe i use numbered points better

keep telling me if like mud - lol

.

i take one line of nice code u show and i tyr show wat get at -

dSL=NormalizeDouble(dPrice-iStopLossPips*Point, Digits);

1.

eg, 1.1234->dPrice; 15->iStopLossPips; 0.0001->Point; 4->Digits

1.1234-15*0.0001->1.1234-0.0015->1.1219

BUT so ok, market decide sub-pip = 1/10

so get below

2.

eg, 1.1234->dPrice; 15->iStopLossPips; 0.00001->Point; 5->Digits

1.1234-15*0.00001->1.1234-0.00015->1.12325

eg, market [currently] looks 4whole digits as pips, BUT 1.1232 -> SL is only 2whole pips away from 1.1234 but wannted 15whole pips away and be SL of 1.1219

.

in 2, want SL=15, get SL=1.5

.

below i try explain more my wory and thots

.

.

.

1.
i do test with this preset [] of 12 syms
{"","EURGBP","EURUSD","AUDUSD","EURCHF","EURJPY "
,"GBPUSD","USDJPY","CHFJPY","USDCAD","USDCHF"
,"AUDJPY","NZDUSD"}
2.
make calls to MarketInfo(..,[MODE_DIGITS|MODE_POINT])
3.
result
MODE_DIGITS = 3 or 5.
MODE_POINT = zero on syms with MODE_DIGITS = 5 (i use Alpari demo)
4.
comment
MODE_POINT is not so needed, MODE_DIGITS is needed
point can be found by [digits] preset array element - eg, [digits] gives 0.0001
so i c point as nice thing but not only way get 0.01 or 0.0001 ...
5.
so ok i use below example
before sub-pip pricing eg, USDJPY, Digits=2 && Point=0.01
When use eg, SL=15 then Point*SL --> 0.15
afaik, wat expect...

now with sub-pip eg, USDJPY, Digits==3 && Point=0.001
When use eg, SL=15 then Point*SL --> 0.015 and get (130) is use in send..
afaik, wat not expect...
6.
whi i say NOT EXPECT
- pairs with eg, JPY are quoted maybe 3 digits but last digit is not pip, is 10th pip
- if do SL*Point get 0.015
that is 1.5 pips so have lost SL meaning
- if mod SL to SL*=10;
and now do SL*Point get 0.15
that is 15 pips
7.
c wat mean?
must be code to do init() like once off mod on programs sl,tp or???
8.
Bid/Ask etc STILL quoted with two decimal places and not three on jpy syms
9.
is like maybe here but not here... lol
OR maybe use extern double SL=150;
so now get Point*SL, 0.001*150 --> 0.15
c wat mean?
is more clear?

10.

- wat happen market decide go extend 1/100 sub-pip?

- wat happen market decide eg, non jpy syms having 4 whole pips now move to 5 whole pips?

at now, code 'assume' eg, non jpy has 4 whole pips, 'assume' is not good in code...

- is like 2 possibles

- ANY code that use constants or even preset arrays gonna come unstuck

- wat happen if u have many many experts out there? user accounts at risk unless code is self correcting or validates runtime data maybe periodicaly to katch these market changes...


i keep on - u say more if not clear wat i on bout - i go crazyt over this - not want use constants or presets - must be code answer which use current data to decide on whole pip Point
Best 2 u

 

please - can others c wat get on their broker demo/live accounts

(i use Alpari demo)

.

1.
i do test with this preset [] of 12 syms
{"","EURGBP","EURUSD","AUDUSD","EURCHF","EURJPY "
,"GBPUSD","USDJPY","CHFJPY","USDCAD","USDCHF"
,"AUDJPY","NZDUSD"}
2.
make calls to MarketInfo(..,[MODE_DIGITS|MODE_POINT])
3.
result
MODE_DIGITS = 3 or 5.
MODE_POINT = ZERO on syms with MODE_DIGITS = 5 (i use Alpari demo)

.

IF u get ZERO is not this MT BUG or is broker bug?????

 

fbj

I know you are trying but as Yoda would say "clarity, coming from more, is not"

IME, an account is nano or whatever and has a set pip/point size (whether sub or other).

Your externs for SL pips, TS pips & TP pips would takes this into account
If you dont wont to enter those (pre-converted) values, then SL pips, TS pips & TP pips must be scaled early in the start() function to match account type

Just use the code in the example and see if it errors!
I believe it does resolve all your other concerns as

Digits

gives the same value as MarketInfo(..,MODE_DIGITS)

and so works whatever the pair/broker/account type it is on

FWIW

-BB-

 

if SL==15 and EURJPY then wat?

digits = 3

point = 0.001

how code do without using hard coded stuff?

if 0.15 is wat want then u know of non constant way?

if market make sub-pips to mess with spread, wat stop market from make jpy's 3 decimals as whole pips instead of now 2pips?

any code fail if use constants.

.

"Your externs for SL pips, TS pips & TP pips would takes this into account"

u mean extern int SL=150; so now will cause your code produce 0.15 ?

.

"If you dont wont to enter those (pre-converted) values, then SL pips, TS pips & TP pips must be scaled early in the start() function to match account type"

how do without constants?

i cannot use start() or init() - i run multi symbol,period using systems not geared to any symbol, period or market condition. must be all dynamic code and not rely on constants.

also Digits for above reason is not any good - like any of mql 11 predefined variables - is not good - only good for default chart EA attached to.

if cycle around many pairs, those 11 predefined variables + any other specific pair data must be seen as virtual attached default chart and all usual default chart environment must be reloaded and EA code body then not care about wat chart on - it got data, that all that matter.

this why i ask, i look for coding solution without any need edit/compile and resend to customers. is this wrong idea? if think so please offer other method.

.

maybe you are meaning, with contsants maybe do

gPoint=0.0001;

if (Digits == 2 || Digits == 3)
{

gPoint=0.01;
}

and now your function use gPoint instead?

this wat u meaning?

.

very good you offer your time anyway

Best 2 u

 

fbj

Ooops - forgot Slippage will need to be multiplied by 10 as well.

The above code does work on a sub-pip MT broker, so long as SL, TS, TP & Slippage are multiplied by 10

This could be handled early in the start() function so that the extern values are at the familiar level

FWIW

-BB-

 

thanku headsup ;)

.

1. not understand - TS is wat?

.

2. so

eg, gbpusd and slippage=5 and price=1.1234 and Point=0.00001 and Digts=5

a. ea do slippage*=10; --> 50

b. ea do OrderSend(..,1.1234,..,50,..);

c. broker server side: it do

price +- slippage * Point --> 1.1234 +- 50 * 0.00001 --> 1.1234 +- 0.00150

ok?

.

3.

would u decide sub-pip broker by eg:

if(Digits==3 || Digits==5) //sub-pip broker so do mods to all:

Point,

Digit,

Slippage,

TP,

SL

.

BUT NOT Spread - (i not add cuz get eg: MarketInfo GBPUSD,H1: MODE_SPREAD=30)

Reason: