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

 
extern double SL=20; // SL для открываемого ордера
extern double TP=20; // ТР для открываемого ордера
extern double Lot=0.01; // Жестко заданное колич. лотов
datetime time;
//--------------------------------------------------------------- 2 --
int start()
{
int Total;

double
M_0,
M_1;


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;


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

M_0=iOsMA(NULL,0,13,34,8,0,0); // 0 бар
M_1=iOsMA(NULL,0,13,34,8,0,1); // 1 бар



if (M_1<0 && M_0>0)
Opn_B=true;

if (M_1>0 && M_0<0)
Opn_S=true;

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


if (Opn_B)
{OrderSend(Symbol(),OP_BUY,Lot,Ask,0,Bid-SL*Point,Bid+TP*Point);time=Time[1];}

if (Opn_S)
{OrderSend(Symbol(),OP_SELL,Lot,Bid,0,Ask+SL*Point,Ask-TP*Point);time=Time[1];}
}


An EA that opens a position when the OsMA crosses the zero line. It is not clear where it opens and it is not clear why. Can someone look, maybe an error in iOsMA(NULL,0,13,34,8,0,0)?
 
T.H.C.:

An EA that opens a position when the OsMA crosses the zero line. It is not clear where it opens and it is not clear why. Can someone check if there is an error in iOsMA(NULL,0,13,34,8,0,0)?

Are you testing on all ticks?
 
001:


Thanks for the reply. Sketched out a rudimentary EA. Still doesn't work.


in this code, look for errors, OrderSend function press F1 will bring up help in the standard editor, look at the order of incoming parameters there is an error.

+ use Print / Alert to go through the variable values, insert it in the code section after ( assignments / execute )

and remember to normalize the output, DoubletoSt..NormalizeDouble..TimeToStr

Attached here are 2 free libraries with code by kimIV.

The code is simple, ready made functions, very good for beginners.

Files:
_lib2.zip  10 kb
 

// Hardly a set number of lots :)

 
T.H.C.:
Yes

Then you have a chattering effect on the zero bar.
 
Vinin:

Testing on all the ticks?
Yes
 

How to "stop" the flow of displeasure to DCs?

Below is an extract from the log:

10:00:25 Old tick EURUSD30 1.38730/1.38740
10:00:25 Old tick EURUSD240 1.38730/1.38740
10:00:25 Old tick EURUSD1440 1.38730/1.38740
10:00:25 Old tick EURUSD15 1.38730/1.38740
10:00:25 Old tick EURUSD1 1.38730/1.38740
10:00:25 Old tick EURUSD60 1.38730/1.38740
10:00:25 Old tick EURUSD5 1.38730/1.38740
11:00:34 Old tick EURUSD30 1.38847/1.38863
11:00:34 Old tick EURUSD240 1.38847/1.38863
11:00:34 Old tick EURUSD1440 1.38847/1.38863
11:00:34 Old tick EURUSD15 1.38847/1.38863
11:00:34 Old tick EURUSD1 1.38847/1.38863
11:00:34 Old tick EURUSD60 1.38847/1.38863
11:00:34 Old tick EURUSD5 1.38847/1.38863
11:25:06 Old tick EURUSD30 1.38707/1.38722
11:25:06 Old tick EURUSD240 1.38707/1.38722
11:25:06 Old tick EURUSD1440 1.38707/1.38722
11:25:06 Old tick EURUSD15 1.38707/1.38722
11:25:06 Old tick EURUSD1 1.38707/1.38722
11:25:06 Old tick EURUSD60 1.38707/1.38722

 
Vinin:

Then you have a chattering effect on the zero bar.
So what to do? A less accurate method? Is there no other way out? Will there be chatter when this EA works too?
 

Does the test give you a headache ?

 

//Trading criteria

M_0 ={ iOsMA(0,0,13,34,8,0,1) }; //| 1bar
M_1 ={ iOsMA(0,0,13,34,8,0,2) }; //| 2bar

Opn_B ={ (((M_1<0)==1) &&((M_0>0)==1) ) };
Opn_S ={ (((M_1>0)==1) &&((M_0<0)==1) ) };

try it this way, but without the jarring:)