| / | Forum |
|
Goldbach
2010.02.04 11:36
I have to evaluate max profit value by one order's Lots, Ask (Bid) and TakeProfit value. (TakeProfit value = TP x Point) If this order is a take profit order, the order closed price will equal to Ask + TP x Point (Bid - TP x Point). I found a formula: profit = Lots x MarketInfo(Symbol(), MODE_TICKVALUE) x TP But the tick value is not a constant, I wanna evaluate the tick value before sending this order, so I need to calculate tick value by TP price. |
|
Using Skype™ to Send Messages from an Expert Advisor The article deals with the ways of how to send internal messages and SMSes from an Expert Advisor to mobile phones using Skype. |
|
gordon
2010.02.04 11:48
Goldbach wrote >>
I have to evaluate max profit value by one order's Lots, Ask (Bid) and TakeProfit value. (TakeProfit value = TP x Point) If this order is a take profit order, the order closed price will equal to Ask + TP x Point (Bid - TP x Point). I found a formula: profit = Lots x MarketInfo(Symbol(), MODE_TICKVALUE) x TP But the tick value is not a constant, I wanna evaluate the tick value before sending this order, so I need to calculate tick value by TP price. You are asking to know the future... U can only know current tick value, but obviously at the moment of opening the order u cannot know what the tick value will be when it closes, since that's in the future.
|
|
Goldbach
2010.02.08 10:40
gordon wrote >>
You are asking to know the future... U can only know current tick value, but obviously at the moment of opening the order u cannot know what the tick value will be when it closes, since that's in the future. Thanks for your reply. By running EA with following test code: Comment("TICKVALUE = " + MarketInfo(Symbol(), MODE_TICKVALUE) + ", 1 / Bid = " + (1 / Bid)); The output: TICKVALUE = 1.11881853, 1 / Bid = 0.01118944 so I guess that if the TICKVALUE is associated with BID value? |
|
gordon
2010.02.08 14:05
Goldbach wrote >>
Thanks for your reply. By running EA with following test code: Comment("TICKVALUE = " + MarketInfo(Symbol(), MODE_TICKVALUE) + ", 1 / Bid = " + (1 / Bid)); The output: TICKVALUE = 1.11881853, 1 / Bid = 0.01118944 so I guess that if the TICKVALUE is associated with BID value? Tick value is the value of one tick of the quote currency (accessible via MODE_TICKSIZE), in the account deposit currency. It's the method the broker uses to 'translate' your profit on trading any pair into the currency in your own account, so it is sort of like an 'exchange rate'. |
|
cloudbreaker
2010.02.08 14:35
I use Tickvalue (together with Ticksize) in any of my EAs where I need, for example, to build a risk or lotsize formula which is flexible enough to function across any combination of account currency and chart pair. CB |
|
gordon
2010.02.08 15:05
gordon wrote >>
You are asking to know the future... U can only know current tick value, but obviously at the moment of opening the order u cannot know what the tick value will be when it closes, since that's in the future. One clarification regarding my comment - since Tick value acts as an 'exchange rate', if the quoted currency is the SAME as the deposit currency, Tick value will be fixed (and in those cases u can use it in your calculations). But in other cases it will be variable and only it's current value can be known (or if u save it to file, the values in the past). |
|
Goldbach
2010.02.09 11:25
gordon wrote >>
One clarification regarding my comment - since Tick value acts as an 'exchange rate', if the quoted currency is the SAME as the deposit currency, Tick value will be fixed (and in those cases u can use it in your calculations). But in other cases it will be variable and only it's current value can be known (or if u save it to file, the values in the past). Thanks, I found a solution: What's the difference between MODE_TICKSIZE & MODE_POINT? |
|
Miroslav_Popov
2010.02.09 13:06
One application is when you want to place Stop Loss calculated as an amount of money. Let's say SL at $135. Another application is when you want the stop to be percentage from your balance. Example SL at 10% of current balance. So we have to convert the money to pips. The main problem is to find that "exchange rate". I'm using this code but it's radder complicated: /// /// The Account Percent Stop limits the loss to a /// predefined percent of the account balance. /// Returns the number of pips for the StopLoss. double AccountPercentStopPips(string symbol, double percent, double lots) { double balance = AccountBalance(); double exchrate = AccountExchangeRate(symbol); double lotsize = MarketInfo(symbol, MODE_LOTSIZE); double point = MarketInfo(symbol, MODE_POINT); double spread = MarketInfo(symbol, MODE_SPREAD); double stopLossPips = percent * balance * exchrate / (lots * lotsize * point) - spread; return (stopLossPips); } /// Gets the Account Exchange Rate /// AccountExchangeRate = AccountCurrency / QuotedCurrency /// It serves to convert the profit of a deal in account currency. /// This code has to be improved! double AccountExchangeRate(string symbol) { if (StringLen(symbol) != 6) return (1); string accCurrency = AccountCurrency(); string baseCurrency = StringSubstr(symbol, 0, 3); string quotedCurrency = StringSubstr(symbol, 3, 3); if (accCurrency == quotedCurrency) return (1); else if (accCurrency == baseCurrency) return (MarketInfo(symbol, MODE_BID)); else { string pair = StringConcatenate(accCurrency, quotedCurrency); double rate = MarketInfo(pair, MODE_BID); LastError = GetLastError(); if (LastError == 4106) { pair = StringConcatenate(quotedCurrency, accCurrency); rate = MarketInfo(pair, MODE_BID); LastError = GetLastError(); if (LastError == 0) rate = 1 / rate; else rate = 1; } else if (LastError != 0) rate = 1; return (rate); } return (1); }This code doesn't work with no forex symbols. Any ideas for improvement? |