Hi, still working on my trader managed to fix my trade timer idea using a method combining HonestKnave and Wroeders help, so thanks guys!
Got another bit of it that needs improving where i currently crudely work out a lot size for a trade and it makes sense but doesnt work on anything other than currencies that include your base currency.
What I'm trying to do is work something out where in MT4 if you have a trade open and click and drag your SL or TP it shows you the net profit of your trade I need to work this out before hand in order to calculate the right Lot Size so it only risks that maximum amount per trade it opens based on the variable stoploss value that is set by the ATR indicator.
Mine works at the moment but its a bit crude and in some cases its Value Loss can be way more than the fixed loss amount.
my code is here:
While waiting and trying to look through William Roeders posts about delta per point I cant quite work it out for myself. I think ive got something close but dont understand how and why to program the Delta per point bit.
Ive come up with this which on the face of it seems to work but not sure if this will work for everything including spicy pairs and JPY's where digits are 3 even on a 5 digit broker. Note this EA runs on 1 chart at a time so only trades the pair of the chart it is on.
in my EA the Stop is set dynamically using the ATR indicator and some maths behind that. I do that in an int called StopLossCalculations. then that fixed stop loss is how im trying to work this back.
Is there a simple snippet of Code of how to do DeltaPerLot?
how I code myself is make things in sort of Modules. a bit like this is within an Int called RiskManagement that way if and when i make EA's for different purposes I can simply drag and drop in the module into a new EA and takes me little time to do.
I use a Visual composer to quite easy for me but you still have to actually code it to get it to do what you want.
What I cant actually get is what is the calculation for DeltaPerLot!!
Your Cryptic approach/response often comes across mega sarchastic which is why i think ive struggled to follow the answers you have given to others, although i do see some pretty no interest in learning comments just wanting you to code it for them. I have followed the links though and where im getting stuck is the logic to it i feel like im not seeing the relevance of DPP in the maths im looking at or for.
I'm struggling to understand the relevance of some of the code though that's probably where i'm going wrong. because i'm not using TickValue by itself I use TickSize also.
I see your argument in the other posts where people are using Point etc to work things out which obviously wont work on a 1 digit chart and they should have used TickValue and TickSize.
But in my above I dont use that, so where is the relevance of DeltaPerPoint within mine?
Taking the notes out this is what I see:
So in the instance Tick Value = 0.768745 and TickSize = 0.00010 DeltaValuePerLot= 7687.45
maybe im looking at it shorted sighted seeing where to use this from here feels the odd bit to get to the LotSize
You don't need to use the same approach as WHRoeder (or anyone) but understand it and apply it for your needs.
To calculate a lot size from a risk I am using such code :
Obviously you can use Balance or whatever you want for "capital".
"sldistance" is a decimal value like 0.0012 (12 pips). "Risk" is for example 2 (for 2% of capital to use).
Thanks Alain, Thats what im talking about! but i think Wroeder has got the wrong end of the stick.
His reply sent me to was to look at his previous posting about this where he responded to not just use Tick Value on its own and to use Delta Per point but i didnt understand as I wasnt using TickValue on its own. I do get his DeltaPerPoint now but I dont see that you need to go to that level to do what you have just done above thats what i was trying to do.