[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 924

 
The main thing is to set the direction of thought... :)

Correct it just so the man doesn't get lost... :)

Could you correct me, simply?
 
T.H.C.:
Could you please correct me, just?

I gave an example:

If 5 is greater than 2, it means that 5 is greater than 2.

And comparing the difference of these values is if 5-2 is greater than zero, then 5 is greater than 2

Is that clear? The point remains - it's all the same first grade maths, only derived from it...

 
extern double Lot=0.01; // Жестко заданное колич. лотов
datetime time;
//--------------------------------------------------------------- 2 --
int start()
{
int Total;


bool
Ans =false, // Ответ сервера после закрытия
Cls_B=false, // Критерий для закрытия Buy
Cls_S=false, // Критерий для закрытия Sell
Opn_B=false, // Критерий для открытия Buy
Opn_S=false; // Критерий для открытия Sell

//--------------------------------------------------------------- 3 --
// Учёт ордеров


for(int i=OrdersTotal()-1;i>=0;i--)
if (OrderSelect(i,SELECT_BY_POS)&&OrderSymbol()==Symbol()&&OrderType()>1)Total++;

if(Total!=0 || time==Time[1])return;

static int KolBars;



if (Close[0]-Open[0] > Point && Close[1]-Open[1] > Point && Bars == KolBars)


{

KolBars=Bars ; // запоминаем кол-во бар при которых совершались действия

}




// Торговые критерии

// Критерий откр. Buy


Opn_B=true;

//--------------------------------------------------------------- 7 --


if (Opn_B)
{OrderSend(Symbol(),OP_BUY,Lot,Ask,0,0,0);time=Time[1];}

}




Please help, someone, I'm asking for the fourth time. I spent 3 days looking for an answer, the book does not say how to do it, I couldn't find any EA with such a condition. The elementary advisor opens a buy position at the appearance of a new candle (provided that the previous 2 candles are green), and closes the position at the close of the candle, on which the position was opened, or at the close of the next candle.

The one you see above opens a position every time a new candle appears, without reacting to the opening criteria, and I don't get how to close the position, I couldn't find it in the tutorial or on the forums.

 
artmedia70:

Sort it out... :)

And do not forget about the existence of StopLev - int StLev=MarketInfo(Symbol(), MODE_STOPLEVEL);

Check the minimum distance for setting stops and takeaways, so that it is not less than this value


I actually composed it correctly, but-- "StLev=MarketInfo(Symbol(),MODE_STOPLEVEL);" I don't know where to put it,
now...

The thing is, I'm constantly at work (I can't install mql4 program here, so I have to do it all in my head

extern double StopLoss=100.0;
extern double TakeProfit=100.0;
extern double Lots=0.01;
extern int total;
extern int SetOrderDistance=50;

int start() {

int pt,dg,StLev;
double Price_1,Price_2,min,max,pa,pb;
RefreshRates();

pt=MarketInfo(Symbol(),MODE_POINT);
dg=MarketInfo(Symbol(),MODE_DIGITS);
pa=MarketInfo(Symbol(),MODE_ASK);
pb=MarketInfo(Symbol(),MODE_BID);
Price_1=pb;
Price_2=pa;
min=iLow(NULL,0,2);
max=iHigh(NULL,0,2);
total=OrdersTotal();
double slB=NormalizeDouble(pa-StopLoss*pt,dg);
double tpB=NormalizeDouble(pa+TakeProfit*pt,dg);
double slS=NormalizeDouble(pb+StopLoss*pt,dg);
double tpS=NormalizeDouble(pb-TakeProfit*pt,dg)

if(total<1) {

if(Price_1>max)
OrderSend(Symbol(),OP_BUY,Lots,pa,5,slB,tpB, "My order#,16384,0,Green);

if(Price_2<min)
OrderSend(Symbol(),OP_SELL,Lots,pb,5,slS,tpS, "My order#,16384,0,Green);
}
}return(0);

 
T.H.C.:

I just sketched it out. It could be a mess.

#define Mag 464564564
extern double Lot=0.01;

int start()
{
int Total;

for(int i=OrdersTotal()-1;i>=0;i--)
if (OrderSelect(i,SELECT_BY_POS)&&OrderSymbol()==Symbol()&&OrderType()<2&&OrderMagicNumber()==Mag)
       {Total++;
       if(Volume[0]<4)close();
       }

if(Total!=0)return;
if(Close[1]>Open[1]&&Close[2]>Open[2]&&Volume[0]>4)bue();
if(Close[1]<Open[1]&&Close[2]<Open[2]&&Volume[0]>4)sell();

}
void bue()
{
OrderSend(Symbol(),0,Lot,NormalizeDouble(Ask,Digits),5,0,0,0,Mag);
}
//----
void sell()
{
OrderSend(Symbol(),1,Lot,NormalizeDouble(Bid,Digits),5,0,0,0,Mag);
}
void close()
{
double pr;if(OrderType()==0)pr=Bid;if(OrderType()==1)pr=Ask;
OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(pr,Digits),5);
}
 
Techno:

I just sketched it out. It could be a little messy.

Thank you very much, very helpful.

How did you learn to program? Where did you start?

 
T.H.C.:

Thank you very much, very helpful.

How did you learn to program? Where did you start?

I studied from textbooks, starting with C++
 
Is C++ much different from mql?
 
T.H.C.:
Is C++ much different from mql?
except for some features (trade orientation) Mql is just a highly stripped down copy of c++
 
Techno:
except for some features (trading orientation) Mql is just a highly stripped-down copy of c++
Oh, thanks for the advice and the time you've given me
Reason: