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
double loss_for_1_lot = pips_to_bsl/ ts * tv ;
It is NOT tv that results in a div 0. it can only be ts. On a 5 digit broker ts might print zero (4 digits)
Sounds to me like you never opened that pair to get the market info from your broker before downloading history from somewhere else.
I find it difficult to believe the zero divide is generated by the code posted.
DomGilberto compile this script and attach it to the chart you believe is returning a zero ticksize.
I'm hoping this video I've made (40 seconds or so) illustrates what I am talking about ( as I am not sure if I am making it clear or not ).
Video: http://screencast.com/t/uMHY5DpM
You will see that the first part when I drop the script onto the live chart (real account) that the tick value and tick size return "0" on that "notional account", which I illustrate in the lots window (units).
The second part is with the same broker but on a lot based feed and this time it returns a tick value and tick size. Again, I illustrate that you trade using lots....
So with regards to the strategy tester, I have no idea why it has been working and sometimes it doesn't. The account has been connected whilst I run the back-tests too (on a demo notional fed account (units)).
My next question would be, if this is the typical response I will get from the notional fed account, are you able to suggest how I correct my position sizing calculation in this circumstance? It works perfectly for a lot based feed... Hope that explains it a little better?
If you are using different code in your "test" code then what does it prove ?
Are you aware that TICKVALUE returns the current value from now . . . even during a Strategy Test run ? so for any pair where the base currency isn't the deposit currency it will be incorrect and your lot calculations will be wrong . . .
In your video, you use GBPUSD in the first instance and then GBPJPY in the second.
I think that if you had attached your script to a GBPUSD normal lot chart, you would get a value for tickvalue, but ticksize would also be zero.
This is because your script alerts are using doubles and so 0.00001 will print as 0.
Use DoubleToStr(MarketInfo(Symbol(),MODE_TICKVALUE),8) instead
Ok firstly, thanks for everyone's help.
Here is the video for "Gumrai" and "SDC" confirming what you're both asking me to do. I have labelled the scripts with your MQL4 aliases, which obviously correspond to your code you've posted here. Video: http://screencast.com/t/kglCd2hCae
The broker and the corresponding feed was not changed during the pause. It is a notional feed account too (units).
@RaptorUK: Yea I knew that TICKVALUE returned the current value from now. I guess your second part looking at it now is kind of logical. I'm getting confused with how I am able to utilise tickvalue as part of my notional feed account to make sure the position sizing is correct...?
Ok firstly, thanks for everyone's help.
Here is the video for "Gumrai" and "SDC" confirming what you're both asking me to do. I have labelled the scripts with your MQL4 aliases, which obviously correspond to your code you've posted here. Video: http://screencast.com/t/kglCd2hCae
The broker and the corresponding feed was not changed during the pause. It is a notional feed account too (units).
@RaptorUK: Yea I knew that TICKVALUE returned the current value from now. I guess your second part looking at it now is kind of logical. I'm getting confused with how I am able to utilise tickvalue as part of my notional feed account to make sure the position sizing is correct...?
Those videos are a pain, they are too big for my screen.
Why not just post the script code and the alert result.
I don't know what you put into the script that was supposed to be my suggested code, but there is no way that it can result in "08"
Use
@RaptorUK: Yea I knew that TICKVALUE returned the current value from now. I guess your second part looking at it now is kind of logical. I'm getting confused with how I am able to utilise tickvalue as part of my notional feed account to make sure the position sizing is correct...?
Those videos are a pain, they are too big for my screen.
Why not just post the script code and the alert result.
I don't know what you put into the script that was supposed to be my suggested code, but there is no way that it can result in "08"
Use
Sorry - I realise now that I forgot to put "DoubleToStr" my bad!!
TickSize = 0.00100000
TickValue = 0.00001026
(Dropped on GBPJPY notional feed)
@SDC I simply copied your code from here and placed it into a new script. That's what was being returned.
This area in my code I have it printing out the formula to break down the maths - Where this is happening is on a BUY PENDING ORDER... yet this part of the code "pips_to_ssl" is pips to SELL stop loss... Which is NOT being used for a buy stop pending order....
Ok new update, I've played around with it repeating the precise place where the zero divide occurs.
This area in my code I have it printing out the formula to break down the maths - Where this is happening is on a BUY PENDING ORDER... yet this part of the code "pips_to_ssl" is pips to SELL stop loss... Which is NOT being used for a buy stop pending order....
I refer you back to my earlier post
"Note that
will also result in zero if pips_to_bsl is zero. Is this possible?"
bsl or ssl, same coding.