TICKVALUE of the past?

 

hi ;)

first i want to say thx for so much input all of you gave me, my english is bad sry for that ;) i was reading here for years, finally i registered an account, because i got a problem and i think i need your help.

im not using the mt4 strategy tester, i calculate the trades and the results "on the fly", i loop through the bars, open the trades, close the trades and save the values.

entry ---------------- 
lots = _EQUITY * (_RISK/100) / _SL_POINTS / TICKVALUE; 

close ----------------
res_pts = MathAbs(OCP - OOP) / point; 
res_cur = res_pts * lots * TickValue;

im currently using this to calculate lots/profit/loss of a trade,  i know that TICKVALUE is changing, but since yesterday i know, it depends on the BID price.

1) that means my calculations are wrong for the past? i only got the TICKVALUE from now and calculate all the trades with this value, is there a big deviation?

after that, i have seen that maybe TICKSIZE needs to go into that calculation because if TICKSIZE changes, TICKVALUE is changing too.

i understand why to use MODE_TICKSIZE

TICKSIZE  0.1 --- TICKVALUE 7 and maybe

TICKSIZE  0.2 --- TICKVALUE 14

thats clear.

2) but how can i calculate lots/profit/loss from the past, i got only MODE_TICKVALUE from BID now and MODE_TICKSIZE from now?

is it possible to use that https://www.mql5.com/en/forum/123665

AccountExchangeRate(string symbol) modified for TICKVALUE

with the Close[x] of the bar instead of the BID, bad idea?

3) that means mt4 backtests are wrong? it is using the actual TICKVALUE for all calculations in the past?

https://www.mql5.com/en/forum/129966/page2#394478

As Gordon stated, tickvalue will be zero for all currency pairs other than the one being tested...and it will be fixed at the most recent "live" 
value at the time the backtest is started for all cross-currency pairs. This means for cross-currency pairs the tickvalue is wrong during the backtest.


so im now doing wrong like the mt4 tester?

hope you can help me ;) many thx!

 
nina32:
lots = _EQUITY * (_RISK/100) / _SL_POINTS / TICKVALUE; 
  1. You place the stop where it needs to be - where the reason for the trade is no longer valid. E.g. trading a support bounce the stop goes below the support.
  2. Account Balance * percent = RISK = (OrderOpenPrice - OrderStopLoss)*DIR * OrderLots * DeltaPerlot (Note OOP-OSL includes the SPREAD)
  3. Do NOT use TickValue by itself - DeltaPerlot
  4. You must normalize lots properly and check against min and max.
  5. You must also check FreeMargin to avoid stop out
 
hi WHRoeder, youre one of the guys i read a lot of stuff ;) thank you

your 1) clear

your 2) not clear

i've seen this before but what is DIR, you never answered this question in the old thread ?

edit: i understand 1/-1 ? for turning the result of (OOP-OSL)


DeltaPerLot depends on TICKVALUE/TICKSIZE, can i use the value from now to calculate the trades from the past?

OOP-OSL includes the SPREAD - yes, i know my OOP/OCP does the same ;) even it is closed or hit the sl

I do not use OrderProfit(),OrderOpenprice() or OrderClosePrice() because i use my own backtester algo, i just simulate the trades based on closed candles

your 3) clear, please explain 2 for that ;)

your 4) clear is in my mm

your 5) clear is in my mm

 
Ok this is what i got now:

//+------------------------------------------------------------------+
#include <stderror.mqh>
#include <stdlib.mqh>

//+------------------------------------------------------------------+
void OnTick(){
 string op =
  "Acc : " + AccountCurrency()+" |"+
  "Base : " + StringSubstr(Symbol(),0,3)+" |"+
  "Quot : " + StringSubstr(Symbol(),3,3)+" |"+  
  "TICKVALUE_MT : " + MarketInfo(Symbol(),MODE_TICKVALUE)+" |"+
  "TICKVALUE_PB : " + TickValuePerBar(Symbol(),0);
 Print(op);    
}

//+------------------------------------------------------------------+
double TickValuePerBar(string symbol, int shift=0){

 string AC = AccountCurrency();
 string S1 = StringSubstr(symbol,0,3);
 string S2 = StringSubstr(symbol,3,3);
 
 if(AC==S2) return(1);
 
 double TS=MarketInfo(symbol,MODE_TICKSIZE); 
 
 if(MarketInfo(symbol,MODE_DIGITS)==3) TS=MarketInfo(symbol,MODE_TICKSIZE)/100;    
      
 if(AC==S1) return(MarketInfo(symbol,MODE_POINT) / iClose(symbol,PERIOD_M1,shift) / TS);
    
 GetLastError(); 
     
 string pair = StringConcatenate(AC,S2); 
  
 if(MarketInfo(pair,MODE_DIGITS)==3) TS=MarketInfo(pair,MODE_TICKSIZE)/100; else TS=MarketInfo(pair,MODE_TICKSIZE); 
 
 double rate = MarketInfo(pair,MODE_POINT) / iClose(pair,PERIOD_M1,shift) / TS;
 int    lerr = GetLastError();   
        
 if(lerr!=0 && lerr!=ERR_HISTORY_WILL_UPDATED){
  Alert("GetTickValuePerBar > error > pair "+pair+" > rate "+rate+" > "+lerr+" > "+ErrorDescription(lerr));
  rate = 0;
 }  
      
 return(rate);

}

here are the results for bar 0:

2014.10.16 21:49:22.224    TICKVALUE GBPUSD,H1: Acc : EUR |Base : GBP |Quot : USD |TICKVALUE_MT : 0.7813598787329469 |TICKVALUE_PB : 0.7813598787329469

2014.10.16 21:50:13.158    TICKVALUE USDJPY,H1: Acc : EUR |Base : USD |Quot : JPY |TICKVALUE_MT : 0.7344624469350882 |TICKVALUE_PB : 0.7344624469350881

2014.10.16 22:04:47.877    TICKVALUE EURUSD,H1: Acc : EUR |Base : EUR |Quot : USD |TICKVALUE_MT : 0.7810669374365383 |TICKVALUE_PB : 0.7810669374365383

2014.10.16 22:05:51.536    TICKVALUE EURCHF,H1: Acc : EUR |Base : EUR |Quot : CHF |TICKVALUE_MT : 0.8282122210995347 |TICKVALUE_PB : 0.8282122210995346

account is in EUR, 5 digits and i just need it for that pairs, it seems to work?

0;AUDCAD 1;AUDCHF
2;AUDJPY 3;AUDNZD
4;AUDUSD 5;CADCHF
6;CADJPY 7;CHFJPY
8;EURAUD 9;EURCAD
10;EURCHF 11;EURGBP
12;EURJPY 13;EURNZD
14;EURUSD 15;GBPAUD
16;GBPCAD 17;GBPCHF
18;GBPJPY 19;GBPNZD
20;GBPUSD 21;NZDCAD
22;NZDCHF 23;NZDJPY
24;NZDUSD 25;USDCAD
26;USDCHF 27;USDJPY

will this work correct >>> TickValuePerBar(symbol,100)?

yes its not exact but with the close price of that bar we are much more closer then using one fixed TICKVALUE for all history calculations?

result seems to be ok but im not shure ;) ???

Reason: