Hi , I checked out many EAs on forex forums, I should get a collection of more than 3000. There are plenty of mis unerstanading and confusion.
Even inside the book from Andrew Young, book who is a referential for everybody
This function shown by the author, can work in major cases, and for major brokers w/ major pairs. But never for exotic pairs. This function is to figure out if the broker is 4 or 4 digits.
// Pip Point Function
double PipPoint(string Currency)
{
int CalcDigits = MarketInfo(Currency,MODE_DIGITS);
if(CalcDigits == 2 || CalcDigits == 3) double CalcPoint = 0.01;
else if(CalcDigits == 4 || CalcDigits == 5) CalcPoint = 0.0001;
return(CalcPoint);
}
OK, it works, it's looks like the DigMull from VGC
double DigMull()
{
double Result=Point;
if(Digits<4)
Result=0.01; // OK
if(Digits==4 || Digits==5)
Result=0.0001;
return(Result);
}
but not for 6 digits ,, or for exotic pairs
So, I recreate a new one (very different)
double DigMull()
{
int diff_digits = 4 - MarketInfo(symbol, MODE_DIGITS);
double Result= 1 / MathPow(10, (MarketInfo(symbol, MODE_DIGITS) + diff_digits));
return(Result);
}
May be someone could tell me what he thinks about this and provide better explanation than me here...
Comments
In Phoenix ea, you find this , bcozn, they calculate in pips
if (Digits==3 || Digits==5)
pipMultiplier=10;
else pipMultiplier=1;
So, SL will become (for a OPEN_BUY)
SL = Ask - StopLoss * Point * pipMultiplier
I.z
ModeStopLevel = 70 (provided by the borker in 5 digits)
ModeStopLevel * Point = 0.07
ModeStopLevel * DigMull = 0.7 ! bad
So, now the system (Squeletton EA) is acting like this:
- when break even is going to be reached, (less than 2 points), the stop loss is set at its lowest as possible
If the trade is not closed, the squeletton EA is waiting until the current price is higher than break even + TradeStop (initial StopLoss), and automatically, the Stoploss of the order is set up to this new value
same process for take profit, except the new take profit is set to the value of TradeProfit + TradeProfit.
I added also a profit lock stop. - when Profit Lock STOP is going to be reached, (less than 2 points), the stop loss is set at its lowest as possible. If Profit Lock Stop is bypassed , same process occurs
I found different ways of calcultating the Minimum Stop Loss
Other guys wrote this :
TMinStop= MarketInfo(Symbol(),MODE_STOPLEVEL)+spread
in exemple
Bid-MarketInfo(Symbol(),MODE_STOPLEVEL)*Point
______________________________________________
Take a look on MT4 limitations
http://book.mql4.com/appendix/limits
Requirements.
Correct prices used when performing trade operations.
The possibility of deleting a pending order is regulated by the FreezeLevel parameter.
StopLevel Minimum Distance Limitation.
A trade operation will not be performed if any of the following conditions is disrupted.
FreezeLevel Limitation (Freezing Distance).
Market orders can not be closed if the StopLoss and TakeProfit values violate the FreezLevel parameter requirements.
StopLoss or TakeProfit orders can not be modified if StopLoss or TakeProfit values violate the StopLevel parameter requirements.
Pending orders can not be deleted or modified if the declared open price violates the FreezeLevel parameter requirements.