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

 
RekkeR:
On this example, if it's not too difficult, could you poke your nose in.
:)))

int init()
{
int draw_begin;
string short_name;
//---- drawing settings
SetIndexStyle(0,DRAW_LINE);
SetIndexShift(0,MA_Shift);
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
if(MA_Period<2) MA_Period=13;
draw_begin=MA_Period-1;
//---- indicator short name
switch(MA_Method)
{
case 1 : short_name="EMA("; draw_begin=0; break;
case 2 : short_name="SMMA("; break;
case 3 : short_name="LWMA("; break;
default :
MA_Method=0;
short_name="SMA(";
}
IndicatorShortName("");
SetIndexDrawBegin(0,draw_begin);
//---- indicator buffers mapping
SetIndexBuffer(0,ExtMapBuffer);
SetIndexLabel(0,"");
//---- initialization done
return(0);
}
That should help.
 

Tried editing the post, it writes too much text and won't paste with changes.

Is this an edited part of the code or an extra portion?

 
dimon74:
Hi guys, could you please advise: slippage - The value of the maximum slippage in pips. What is it and what is it for? I always set it to zero. Maybe it makes sense to change it. Can it be changed by my brokerage company? Thank you in advance!

Slippage is the maximum slippage value when your broker opens a trade (i.e. you still want to make a trade at a price that is even worse for you), you should set it to 2 or 3 or 5. "0" is too small a tolerance that you define for the broker in real market conditions.

 
RekkeR:

Tried editing the post, it writes too much text and won't paste with changes.

Is this an edited part of the code or an extra portion?


It's only the init() function that needs to be fixed

And the SRC button is used to paste the code

 
Vinin:


It's only init() function, which needs to be fixed

And the SRC button is used to insert code

Thanks Victor, I'll study myself at the weekend, it's a funny thing, coding.

I will report to you with results!

 

Man, I understand that you're angry when you ask the same questions in this thread a hundred times,

As a beginner, I would certainly understand it myself, because it is interesting to do everything myself

I may be a beginner, but I'm still puzzled by the fact that the EA is being tested, but i don't want it to work on demo and real account.

I have always been interested in this, but I am still stuck when I look at the EA.

May be the problem is not in the EA but in the DC?

extern double StopLoss=1000.0;
extern double TakeProfit=1000.0;
extern double Lots=1.0;
extern int total;


int start() {

int dg;
double Price_1,Price_2,min,max,pa,pb,pt;

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,2,slB,tpB,"My order#",16384,0,Green);

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

}

Help?

 
artmedia70:

Look for the order in the history, and if you find it, compare its closing price OrderClosePrice() with its StopLoss OrderStopLoss() level

If they are equal, it means that position was closed at Stop Loss.

approximately understood, thanks, I will deal with it after I solve the first problem
 
gheka:

I understand that you guys are pissed off when the same questions are asked a hundred times in this thread,


What kind of errors do you get when you don't open a position? You could try this

 if(total<1) 
  {
   if(Price_1>max)
      OrderSend(Symbol(),OP_BUY,Lots,Ask,100,slB,tpB,"My order#",16384,0,Green);

   if(Price_2<min)
      OrderSend(Symbol(),OP_SELL,Lots,Bid,100,slS,tpS,"My order#",16384,0,Green);
  }
 
gheka:

Man, I understand that you're angry when you ask the same questions in this thread a hundred times,

As a beginner, I would certainly understand it myself, because it is interesting to do everything myself

I may be a beginner, I would figure it out myself, it's interesting to do everything myself.

I have always been interested in this, but I am still stuck when I look at the EA.

May be the problem is not in the EA but in the DC?

Help?


Maybe your brokerage company does not allow explicit specifying of take and stop positions, check it - put zeros in the opening order function in their places.
 
gheka:

Man, I understand that you're angry when you ask the same questions in this thread a hundred times,

As a beginner, I would certainly understand it myself, because it is interesting to do everything myself

I may be a beginner, I would figure it out myself, it's interesting to do everything myself.

I have always been interested in this, but I am still stuck when I look at the EA.

May be the problem is not in the EA but in the DC?

Help?


If at least one position is open (any - by hand, by another EA) this EA will not work