Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 550

 
Regarding proxies, if anyone needs really working IPs, I can advise http://buy.fineproxy.org/ myself for a long time I buy addresses there, everything works fine and there is a possibility of a test period!
 

Sorry for the flooding, I'll ask you again.

Can you suggest a free open interest indicator? Thanks in advance!

 
GSB:

You can't write codes that inattentively :)

Go to Comment("USDCADAsk = ",USDCADAsk); followed by USDCADAsk = DoubleToString(MarketInfo("USDCAD",MODE_ASK),usdcaddigits); USDCADAsk is declared as double and you put a string in it,

and then Digits.... again ^) and Point

You have to look for such errors yourself, no one will fix them for you as well as trade! The compiler generates 28 errors and you put the demo into trading. You may wish you were using real money but the market would have corrected you!

Whose Bid Ask is it ?


Correct


Turns out you didn't need to use additional variables and then you don't need normalisation, it should be like this.
OrderSend("USDCAD",OP_BUY,Lot,MarketInfo("USDCAD",MODE_ASK),slip,0,0,"USDCAD",magic[0],0,Red);
 
Example2:

Turns out you didn't need to use additional variables and then you don't need normalisation, it should be like this.

OrderSend("USDCAD",OP_BUY,Lot,MarketInfo("USDCAD",MODE_ASK),slip,0,0,"USDCAD",magic[0],0,Red);

Firstly, you yourself tried to display them on the screen to check, which led to errors, and secondly, normalization is desirable and the order setting price and TP, SL. If the price is not normalized, it can cause errors. This is the rule and we should not break it. See examples and analyse why this is the case and not the other way around, e.g. https://book. mql4.com/ru/samples/shared
 
Hi, could you tell me how to add, say, 23% to OrderOpenPrice? If you know that OrderOpenPrice is already 77%. I'm dividing by 77, multiplying by 23 and I get 7 points instead of 31. Here is a line of code if (MarketInfo-OrderOpenPrice()>OrderOpenPrice()/50*Percent*Point). This is a transfer to Breakeven, but not in points, but in percentage points. Thank you in advance!
 
vidnab:
Hello! If you don't mind telling me how to add say 23% to OrderOpenPrice? If you know that OrderOpenPrice is already 77%. I'm dividing by 77, multiplying by 23 and I get 7 points instead of 31. Here is a line of code if (MarketInfo-OrderOpenPrice()>OrderOpenPrice()/50*Percent*Point). This is a transfer to Breakeven, but not in points, but in percentage points. Thank you in advance!


I bought one hundred thousand euros at 50 rubles, then I add 23% to the purchase price.

For your case, you need to lay out the code in full. Although if you just want to bring it to 100%, divide by 0.77.

 

Thank you for your reply. Here's all the code

//+----------------------------------------------------------------------------+
//| e-MovingInWL2.mq4 |
//| |
//| Kim Igor V. aka KimIV |
//| http://www.kimiv.ru |
//| |
//| 27.10.2008 Adviser moves stop to breakeven. |
//+----------------------------------------------------------------------------+
#property copyright "Kim Igor V. aka KimIV"
#property link "http://www.kimiv.ru"

//------- External parameters of the Expert Advisor -----------------------------------------+
extern string _P_Expert = "---------- EA parameters";
extern bool AllSymbols = True; // Watch positions of all symbols
extern int Magic = -1; // Position identifier
extern int LevelProfit = 25; // Profit level in points
extern int LevelWLoss = 1; // Breakeven level in points
extern bool ShowComment = True; // Show comment

//------- Parameters of trade orders execution ------------------------------+
extern string _P_Performance = "---------- Parameters of execution";
extern bool UseSound = True; // Use sound signal.
extern string SoundSuccess = "expert.wav"; // Sound of success
extern string SoundError = "timeout.wav"; // Error sound.
extern inttern NumberOfTry = 2; // Number of attempts

//------- Global variables of the Expert Advisor -------------------------------------+
bool gbDisabled = False; // Flag of locked EA
bool gbNoInit = False; // Flag of failed initialization
color clModifyBuy = Aqua; // colour clModifyBuy icon
color clModifySell = Tomato; // Colour of the sale modification icon

//------- Connection of external modules -----------------------------------------+
#include <stdlib.mqh>


//+----------------------------------------------------------------------------+
//| |
//| PREDEFINED FUNCTIONS |
//| |
//+----------------------------------------------------------------------------+
//| expert initialisation function |
//+----------------------------------------------------------------------------+
void init() {
gbNoInit=False;
if (!IsTradeAllowed()) {
Message("For the EA to work correctly, it is necessary\n "+
"Allow the EA to trade");
gbNoInit=True; return;
}
if (!IsLibrariesAllowed()) {
Message("For the EA to work correctly, you should\n "+
"Allow import from external EAs");
gbNoInit=True; return;
}
if (!IsTesting()) {
if (IsExpertEnabled()) Message("The Expert Advisor will be started with the next tick");
else Message("The button \"Allow EAs to start{") is released;
}
start();
}

//+----------------------------------------------------------------------------+
//| expert deinitialization function |
//+----------------------------------------------------------------------------+
void deinit() {
if (!IsTesting()) Comment(");
}

//+----------------------------------------------------------------------------+
//| expert start function |
//+----------------------------------------------------------------------------+
void start() {
if (gbDisabled) {
Message("Critical error! EA STOPPED!"); return;
}
if (gbNoInit) {
Message("EA initialization failed!"); return;
}
if (ShowComment) {
Comment(IIFs(AllSymbols, "AllSymbols ", ")
, "Magic="+IIFs(Magic<0, "Any", DoubleToStr(Magic, 0))+" "
, "LevelProfit="+DoubleToStr(LevelProfit, 0)+"n "
, "LevelWLoss="+DoubleToStr(LevelWLoss, 0)+"n "
);
} else Comment(");

string sy=IIFs(AllSymbols, "", NULL);
MovingInWL(sy, -1, Magic);
}


//+----------------------------------------------------------------------------+
//| |
//| USER FUNCTIONS |
//| |
//+----------------------------------------------------------------------------+
//| Author : Kim Igor V. aka KimIV, http://www.kimiv.ru |
//+----------------------------------------------------------------------------+
//| Version : 01.09.2005 |
//| Description : Returns the name of trade operation |
//+----------------------------------------------------------------------------+
//| Parameters: ||
//| op - identifier of trade operation |
//+----------------------------------------------------------------------------+
string GetNameOP(int op) {
switch (op) {
case OP_BUY : return("Buy");
case OP_SELL : return("Sell");
case OP_BUYLIMIT : return("BuyLimit");
case OP_SELLLIMIT : return("SellLimit");
case OP_BUYSTOP : return("BuyStop");
case OP_SELLSTOP : return("SellStop");
default : return("Unknown Operation");
}
}

//+----------------------------------------------------------------------------+
//| Author : Kim Igor V. aka KimIV, http://www.kimiv.ru |
//+----------------------------------------------------------------------------+
//| Version : 18.07.2008 |
//| Description : It returns one of two values depending on the condition. |
//+----------------------------------------------------------------------------+
color IIFc(bool condition, color ifTrue, color ifFalse) {
if (condition) return(ifTrue); else return(ifFalse);
}

//+----------------------------------------------------------------------------+
//| Author : Kim Igor V. aka KimIV, http://www.kimiv.ru |
//+----------------------------------------------------------------------------+
//| Version : 01.02.2008 |
//| Description : It returns one of two values depending on the condition. |
//+----------------------------------------------------------------------------+
string IIFs(bool condition, string ifTrue, string ifFalse) {
if (condition) return(ifTrue); else return(ifFalse);
}

//+----------------------------------------------------------------------------+
//| Author : Kim Igor V. aka KimIV, http://www.kimiv.ru |
//+----------------------------------------------------------------------------+
//| Version : 01.09.2005 |
//| Description : Displaying a message in the comment and in the log |
//+----------------------------------------------------------------------------+
//| Parameters: |
//| m - message text |
//+----------------------------------------------------------------------------+
void Message(string m) {
Comment(m);
if (StringLen(m)>0) Print(m);
}

//+----------------------------------------------------------------------------+
//| Author : Kim Igor V. aka KimIV, http://www.kimiv.ru |
//+----------------------------------------------------------------------------+
//| Version : 28.11.2006 |
//| Description : Modification of one pre-selected order. |
//+----------------------------------------------------------------------------+
//| Parameters : |
//| pp - price level of the order |
//| sl - price level of the stop |
//| tp - price level of takeout |
//| ex - expiry date |
//+----------------------------------------------------------------------------+
void ModifyOrder(double pp=-1, double sl=0, double tp=0, datetime ex=0) {
bool fm;
color cl=IIFc(OrderType()==OP_BUY
|| OrderType()==OP_BUYLIMIT
|| OrderType()==OP_BUYSTOP, clModifyBuy, clModifySell);
double op, pa, pb, os, ot;
int dg=MarketInfo(OrderSymbol(), MODE_DIGITS), er, it;

if (pp<=0) pp=OrderOpenPrice();
if (sl<0 ) sl=OrderStopLoss();
if (tp<0 ) tp=OrderTakeProfit();

pp=NormalizeDouble(pp, dg);
sl=NormalizeDouble(sl, dg);
tp=NormalizeDouble(tp, dg);
op=NormalizeDouble(OrderOpenPrice(), dg);
os=NormalizeDouble(OrderStopLoss(), dg);
ot=NormalizeDouble(OrderTakeProfit(), dg);

if (pp!=op || sl!=os || tp!=ot) {
for (it=1; it<=NumberOfTry; it++) {
if (!IsTesting() && (!IsExpertEnabled() || IsStopped())) break;
while (!IsTradeAllowed()) Sleep(5000);
RefreshRates();
fm=OrderModify(OrderTicket(), pp, sl, tp, ex, cl);
if (fm) {
if (UseSound) PlaySound(SoundSuccess); break;
} else {
er=GetLastError();
if (UseSound) PlaySound(SoundError);
pa=MarketInfo(OrderSymbol(), MODE_ASK);
pb=MarketInfo(OrderSymbol(), MODE_BID);
Print("Error(",er,") modifying order:",ErrorDescription(er),", try ",it);
Print("Ask=",pa," Bid=",pb," sy=",OrderSymbol(),
" op="+GetNameOP(OrderType())," pp=",pp," sl=",sl," tp=",tp);
Sleep(1000*10);
}
}
}
}

//+----------------------------------------------------------------------------+
//| Author : Kim Igor V. aka KimIV, http://www.kimiv.ru |
//+----------------------------------------------------------------------------+
//| Version : 23.04.2009 |
//| Description : Move stop level to lossless |
//+----------------------------------------------------------------------------+
//| Parameters: |
//| sy - name of the instrument ( "" - any symbol, |
//| NULL - current symbol) |
//| op - operation ( -1 - any position) |
//| mn - MagicNumber ( -1 - any magik) |
//+----------------------------------------------------------------------------+
void MovingInWL(string sy="", int op=-1, int mn=-1) {
double po, pp;
int i, k=OrdersTotal();

if (sy=="0") sy=Symbol();
for (i=0; i<k; i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if ((OrderSymbol()==sy || sy==") && (op<0 || OrderType()==op)) {
if (mn<0 || OrderMagicNumber()==mn) {
po=MarketInfo(OrderSymbol(), MODE_POINT);
if (OrderType()==OP_BUY) {
if (OrderStopLoss()-OrderOpenPrice()<LevelWLoss*po) {
pp=MarketInfo(OrderSymbol(), MODE_BID);
if (pp-OrderOpenPrice()>LevelProfit*po) {
ModifyOrder(-1, OrderOpenPrice()+LevelWLoss*po, -1);
}
}
}
if (OrderType()==OP_SELL) {
if (OrderStopLoss()==0 || OrderOpenPrice()-OrderStopLoss()<LevelWLoss*po) {
pp=MarketInfo(OrderSymbol(), MODE_ASK);
if (OrderOpenPrice()-pp>LevelProfit*po) {
ModifyOrder(-1, OrderOpenPrice()-LevelWLoss*po, -1);
}
}
}
}
}
}
}
}
//+----------------------------------------------------------------------------+

 
This is Igor Kim's code, but I can't get in touch with him. If you can help!
 
GSB:

Firstly, you yourself tried to display them on the screen to check, which led to errors, and secondly, normalization is desirable and the order setting price and TP, SL. If the price is not normalized, it can lead to errors. This is the rule and we should not break it. See examples and analyse why this is the case and not the other way around, e.g. https://book. mql4.com/ru/samples/shared

I didn't write it to reproach, just to let others see. Thank you for your time.
 

A functionally quite complete expert. What do you want to add to it?

Это перевод в безубыток, только не в пунктах, а в процентах

What percentage value do you want to translate the breakeven on?

And you will still need this value in pips to modify orders.

Reason: