Hi guys,
i have programmed the following StopLoss:
double StopLossDyn()
{
double MovAver = iMA(NULL,0,10,0,0,PRICE_CLOSE,0);
double BB= iBands(NULL,0,10,1,0,PRICE_CLOSE,MODE_LOWER,0);
double y;
double x;
y = ((MovAver-BB)*100000);
x = MathAbs(y);
My frist question: did i make a logic mistake?
The other question: How i code a MoneyManagement-function?
I would like that the programm only risking 1% of my Accountbalance!
i hope you can help me!
And i'm very sorry about my bad english. hope you forgive me ;-)
Greetings - Luke
Hi,
Please use the SRC button at the top to paste code:
double StopLossDyn() { double MovAver = iMA(NULL,0,10,0,0,PRICE_CLOSE,0); double BB= iBands(NULL,0,10,1,0,PRICE_CLOSE,MODE_LOWER,0); double y; double x; y = ((MovAver-BB)*100000); x = MathAbs(y);
Also,
1) Why are you multiplying by 100000? Is that your account balance? If so, use the AccountBalance() function.
2) What does your function return? To me, it seems that your stop loss is the distance between the moving average and the lower band - will it always be like that, in both long and short?
3) Don't adjust your stop-loss size to your account balance - instead, adjust your lot size.
No, its not my account balance! i dont know why i have to multiply it with 100,000. if i dont multiply the differnce the calculated result is to small ( for example 0.00034 and not 34 pips). The Function only calculate the diffence between moving average and the upper BollingerBand. This difference is the Stoploss for long and short positons (MathAbs.. )
In the next step i want to calculate the lot size. i want to adjust the lotsize to my "StopLossDyn()" !
i tried: Accountbalance*0.01 / StopLossDyn() = Lotsize ---> The results seems very wrong!
Can you help me?
Thanks in advance!
Luke
No, its not my account balance! i dont know why i have to multiply it with 100,000. if i dont multiply the differnce the calculated result is to small ( for example 0.00034 and not 34 pips). The Function only calculate the diffence between moving average and the upper BollingerBand. This difference is the Stoploss for long and short positons (MathAbs.. )
In the next step i want to calculate the lot size. i want to adjust the lotsize to my "StopLossDyn()" !
i tried: Accountbalance*0.01 / StopLossDyn() = Lotsize ---> The results seems very wrong!
Can you help me?
Thanks in advance!
Luke
Hi, 34 pips in MT4 terms is actually 0.0034 - so what you are getting is right, you dont need to multiply by 100000
So, lets suppose your stop-loss is 34 pips. now you want to adjust the lot size. First, you will have to determine how much of your account you want to risk on a single trade. If your account balance is 1000, and your risk factor is 10% of your account per trade, and your stop loss is 34 pips, you can trade 0.3 lots(which is roughly 100 dollars, if you take an average of 1 dollar per 0.1 lot)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi guys,
i have programmed the following StopLoss:
double StopLossDyn()
{
double MovAver = iMA(NULL,0,10,0,0,PRICE_CLOSE,0);
double BB= iBands(NULL,0,10,1,0,PRICE_CLOSE,MODE_LOWER,0);
double y;
double x;
y = ((MovAver-BB)*100000);
x = MathAbs(y);
return(x); }
My frist question: did i make a logic mistake?
The other question: How i code a MoneyManagement-function?
I would like that the programm only risking 1% of my Accountbalance!
i hope you can help me!
And i'm very sorry about my bad english. hope you forgive me ;-)
Greetings - Luke