[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 88

 

Everything was here C:\Users\======AppData\Local\VirtualStore\Program Files\====== - MetaTrader\

vista

 

Please advise.

I wrote a simple script (set two pendants close to the market to put it on the chart before news release so I don't have to do it manually). It seems to be much easier, but it does not work, no orders are opened and the journal just says that the script is loaded successfully, and then immediately removed in the same second! It compiles without errors. I converted it to expert form, i.e. added init and deinit, to check it in tester, it worked. But, as you understand, I do not need an Expert Advisor, but just a script.

What is wrong here? Thank you in advance.

Here is the code of the script:

#property copyright "alexey15"
#property link ""
#property show_confirm

extern int SL = 15;
extern int TP = 90;
extern int DELTA = 15;
extern double LOT = 0.1;
extern int SLIP = 3;

//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
//----
double BUYPRICE = Ask + DELTA*Point;
double SELLPRICE = Bid - DELTA*Point;
int OPEN_ORDER;

OPEN_ORDER=OrderSend(Symbol(),OP_BUYSTOP,LOT,BUYPRICE,SLIP,BUYPRICE-SL*Point,BUYPRICE+TP*Point,NULL,0,0,Blue);
OPEN_ORDER=OrderSend(Symbol(),OP_SELLSTOP,LOT,SELLPRICE,SLIP,SELLPRICE+SL*Point,SELLPRICE-TP*Point,NULL,0,0,Red);


//----
return(0);
}
//+------------------------------------------------------------------+

 
wiwkin52:

Hello. Please help. I uninstalled the mt and all the indicators along with it, all of them. Now I installed it and everything is still there. What should I do? Maybe there are copies of indicators and everything else stored somewhere?

Did you only uninstall or did you also delete the MT folder from Program Files?
 
alexey15:

Please advise.

I wrote a simple script (set two pendants close to the market to put it on the chart before news release so I don't have to do it manually). It seems to be much easier, but it does not work, no orders are opened and the journal just says that the script is loaded successfully, and then immediately removed in the same second! It compiles without errors. I converted it to expert form, i.e. added ininit and deinit, to check it in tester, it worked. But, as you understand, I do not need an Expert Advisor, but just a script.

What is wrong here? Thank you in advance.

Here is the code of the script:


I checked it. Your script works.

Print the error just in case:

int start()
{
//----
double BUYPRICE = Ask + DELTA*Point;
double SELLPRICE = Bid - DELTA*Point;
int TicketBS,TicketSS;
TicketBS=OrderSend(Symbol(),OP_BUYSTOP,LOT,BUYPRICE,SLIP,BUYPRICE-SL*Point,BUYPRICE+TP*Point,NULL,0,0,Blue);
TicketSS=OrderSend(Symbol(),OP_SELLSTOP,LOT,SELLPRICE,SLIP,SELLPRICE+SL*Point,SELLPRICE-TP*Point,NULL,0,0,Red);
 if(TicketBS<=0 || TicketSS<=0)Print("Error = ",GetLastError());
//----
return(0);
}

 
alexey15:

Please advise.

I wrote a simple script (setting two pendants in both directions close to the market to put it on the chart before news release so I don't have to do it manually). It seems to be much easier, but it does not work, no orders are opened and the journal just says that the script is loaded successfully, and then immediately removed in the same second! It compiles without errors. I converted it to expert form, i.e. added init and deinit, to check it in tester, it worked. But, as you understand, I do not need an Expert Advisor, but just a script.

What is wrong here? Thank you in advance.

It works on the four-digit number. I have not checked it on five-digit levels but I have added a check for constraints on StopLevel:

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
extern int SL     = 15;
extern int TP     = 90;
extern int DELTA  = 15;
extern double LOT = 0.1;
extern int SLIP   = 3;

//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
//----
int StopLevel = MarketInfo(Symbol(),MODE_STOPLEVEL);
if (DELTA <= StopLevel) DELTA = StopLevel+1;

double BUYPRICE = Ask + DELTA*Point;
double SELLPRICE = Bid - DELTA*Point;
int OPEN_ORDER;

OPEN_ORDER=OrderSend(Symbol(),OP_BUYSTOP,LOT,BUYPRICE,SLIP,BUYPRICE-SL*Point,BUYPRICE+TP*Point,NULL,0,0,Blue);
OPEN_ORDER=OrderSend(Symbol(),OP_SELLSTOP,LOT,SELLPRICE,SLIP,SELLPRICE+SL*Point,SELLPRICE-TP*Point,NULL,0,0,Red);

//----
return(0);
}
//+------------------------------------------------------------------+
In principle, you can make Point adjustments for four, five digits to avoid errors. Because the Delta level should be ten times bigger on a five-digit, i.e. 150 instead of 15, and the stops and the takes accordingly...

Then it would look like this:

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
extern int SL     = 15;
extern int TP     = 90;
extern int DELTA  = 15;
extern double LOT = 0.1;
extern int SLIP   = 3;

//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
//----
double PointX;

if(Digits==5 || Digits==3) PointX = Point * 10;    // Корректировка Point под трёх- пятизнак
if(Digits==4 || Digits==2) PointX = Point;

int StopLevel = MarketInfo(Symbol(),MODE_STOPLEVEL);
if (DELTA <= StopLevel) DELTA = StopLevel+1;

double BUYPRICE = Ask + DELTA*PointX;
double SELLPRICE = Bid - DELTA*PointX;
int OPEN_ORDER;

OPEN_ORDER=OrderSend(Symbol(),OP_BUYSTOP,LOT,BUYPRICE,SLIP,BUYPRICE-SL*PointX,BUYPRICE+TP*PointX,NULL,0,0,Blue);
OPEN_ORDER=OrderSend(Symbol(),OP_SELLSTOP,LOT,SELLPRICE,SLIP,SELLPRICE+SL*PointX,SELLPRICE-TP*PointX,NULL,0,0,Red);

//----
return(0);
}
//+------------------------------------------------------------------+
 

Good morning !

Anyone have any tips on the indices...?

 
volshebnik:

Good morning !

Anyone have any tips on the indices...?

Right, the indices.
 
splxgf:
Right, the indices.
Not funny ) The question was here - https://www.mql5.com/ru/forum/131277/page87 But as the forum administrators don't recommend repeating questions, so I didn't post it again.
 
volshebnik:

Hello !

Can you please tell me what's wrong ? I am using the tester on GBPUSD - it opens trades as it should be. I am using it on the dollar index DXH1 - it does not open many deals, the error "130" - Incorrect stops. Moreover, it is not clear what is wrong - it opens and does not open in similar situations, but more than that. Spread and stop level for Dollar Index -100 and 200. Spread and stop level for GBPUSD -3 and 4. Prices in the dollar index, e.g. 78.150, in the pair - 4 decimal places. But it is accounted for.

Here is a part of the code :


Just off the top of my head:

1) SL and TP are non-normalised;

2) OrderSend uses Digits when normalizing, while the order is placed by Symb.

Try it this way:

int opDigits=MarketInfo(Symb,MODE_DIGITS);
SL = NormalizeDouble(SL,opDigits);
TP = NormalizeDouble(TP,opDigits);
ОткрФрвверх = NormalizeDouble(ОткрФрвверх,opDigits);
ticketup=OrderSend(Symb, OP_BUYSTOP, Lot, ОткрФрвверх,0, SL, TP,NULL,A,0,вверх); // Ордер вверх
 
PapaYozh:


At a guess:

1) SL and TP are non-normalised;

2) OrderSend uses Digits for normalisation, whereas the order is set by Symb.

Try it this way:

Thank you very much ! It worked, but rarely, sometimes the same error occurs - 130....... ( Is it always necessary to normalise the stops or only on indices ? (just on currency pairs stops have always worked, in my opinion, without normalisation).
Reason: