[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 1015

 

Help!!! I've been struggling for three hours!!! I can't assign the variable order=Close[1]. The idea is that at the time of placing the order to remember the price, as it was at that time.

Then you can compare it with the current price and move the stop loss or take profit,

I may be an idiot, but I should know better.

Thanks in advance.

//+------------------------------------------------------------------+
//| Tester.mq4 |
//| Dimon |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Dimon"
#property link "http://www.metaquotes.net"

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+

extern int BandsPeriod=20,i=1 ;extern int BandsShift=0;
extern double BandsDeviations=2.0;
extern double Lots=0.1,TakeProfit=50,stoploss=10 ;double PointX;extern int parametrA=2;
int init()
{ if(Digits==5 || Digits==3) PointX = Point * 10; // Correction Point for three-five digits
if(Digits==4 || Digits==2) PointX = Point;
//----
Alert ("PointX",PointX);
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{double order, newloss=12;Alert (" order ",order);
if (parametrA==0){
int total=OrdersTotal();// Comment(" total ",total); Alert (" total ",total);
if ( total !=0 ){return;}

double Average,Verhnyayaghranytsa,Nyzhnyayaghranytsa,newres,sum,deviation;
string text; int ticket; int err;
text="macd sample";}else { Comment("buoy!",Verhnyayaghranytsa );
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-stoploss*PointX,Ask+TakeProfit*PointX, "macd sample",16384,0,Green);
Alert (" stoploss ",Ask-stoploss*PointX);Alert (" parametrA ",parametrA);
order=Close[1];Comment("buoy!order ",order );parametrA--;
}
//----

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

 
I just started to write an EA for mt4 using Gordago forex optimizer, I am good with the algorithm, so I put the EA directly into the terminal, prepositioned stoplosses and takeprofits for buying and selling in Optimizer.Everything is testing normally, but the EA does not work on a real chart at all; if I set zeros instead of stops and takeovers, trading goes on at once, but not with the results I need.
 
Dimka-novitsek:

Help!!! I've been struggling for three hours!!! I can't assign the variable order=Close[1]. The idea is that at the time of placing the order to remember the price, as it was at that time.

Then you can compare it with the current price and move the stop loss or take profit,

I may be an idiot, but I'm not sure what to do with it.

Thanks in advance.

....
Files:
1_1.mq4  2 kb
 
Thank you!!!!Certainly!!!!
 
sezon:

Thought I'd check in here as well ...

How do I set up sending email to narod.ru?

All variants tried:

SMTP server - smtp.narod.ru

SMTP login: - имя@narod.ru

SMTP password - password

From: slt-soft@narod.ru

To: slt-soft@narod.ru

Error: Mail: login to smtp.narod.ru failed

I'm not sure exactly, but the people seem to need only a username (i.e. you have a name - everything before the dog), not a full e-mail

But on some smtp servers you need to replace the doggie with a plus sign and then it starts logging in normally, on some servers it understands both the doggie and the plus sign, and on some only the login

 
Of course, it's not 1, it's 0!!!! Just don't understand, how is it possible to declare a variable ahead of the start function? !!!!!!!!!!!!!!!!This is the only way it works!
 
I'll reread the global variables. But the compiler didn't!
 
Dimka-novitsek:
I'll reread the global variables. But the compiler didn't!
didn't mind because there were no syntax errors. This is a logical error, the compiler does not see it
 
001:


Yes, that's exactly it. There is a file, you've uploaded, which is very useful, OptimizationReport.mq4. I have improved it a bit, in order to calculate the Recovery Factor. Now I want to get the value of this variable in the main code to speed up optimization by detecting the passes of the tester and setting the limit of the PV level. I tried to do it through global variables. I cannot see the value of my variable in the main code.

I write in the Expert Advisor:

double myValue = GlobalVariableGet("myValue");
Print("myValue="+myValue);
MessageBox("myValue="+myValue);
Alert("myValue="+myValue);

in the include("I put it up):

GlobalVariableSet("myValue", 1);

Doesn't work, myValue=0.00000000


The problem is that usually this bibilio works at the very end. To generate a report.

It would be better just to make a function to calculate the recovery factor and call it on every tick or bar, or only when the position is closed. But on every tick it is easier to calculate the maximum drawdown.

 
Vinin:

The problem is that this bibliography usually works at the very end. To generate a report.

It is better to just make a function to calculate the recovery factor and call it on every tick, or bar, or only when the position is closed. But on each tick it is easier to calculate the maximum drawdown.

Unfortunately, I don't have enough brains to write it myself.