I'm learning to write an advisor... - page 3

 
There is still 1 OrderSend error 130... What does it depend on?
 
paukas >> :

Download minute candles (e.g. from Alpari) and do a test on minute candles.

How am I going to do a test on minutes if I have an MTS for H4...?

You can't test on 4hourly candlesticks with 5 pips stop.

Why not?
 

In the article Automated Trading Championship 2007: Common Errors in Experts
I have read that OrderSend error 130 (ERR_INVALID_STOPS) is wrong or too close stops.

Called the DC, asked at what minimum distance a stop can be set - they said no such limit... Strange!

I also do not understand one thing. If I manually open an order, I can't actually set stop and profit in it... Then how does OrderSend() do this?

I checked if I manually place an order and then place a stop... A minimum of 4 pips should be set from the open price - i.e., the current price...

Now I have to twist OrderModify(). Why do we need stoploss in OrderSend() then ?

 
ALex2008 >> :

How am I going to do a test on minutes if I have an MTS for H4...?

Why not?

The test on the smallest TF is done as follows

You write calls like this (for example)

   wpr[1] =   iWPR ( Symbol(), 10, PERIOD_H4, 1 );
   wpr[2] =   iWPR ( Symbol(), 20, PERIOD_H4, 1 );
   wpr[3] =   iWPR ( Symbol(), 40, PERIOD_H4, 1 );
   wpr[4] =   iWPR ( Symbol(), 60, PERIOD_H4, 1 );


We will try to use any timeframe and it will be the most efficient and correct test on minutes!

it will be the most correct!

---

Unfortunately, you can't do it on ticks! Because there's no tick history in the MT4 tester


---

Learn to write the TF right away! And then your EA will not care what TF it was run on!

it is reasonable to write parameters instead of constants - for simpler code and clearer perception I put constants

 

Yuri) I'm not a pro at this...) At least describe what it means to me. wpr[1] = iWPR ( Symbol(), 10, PERIOD_H4, 1 );

 
ALex2008 >> :

Yury) I'm not a pro in this business...) At least describe what it means. wpr[1] = iWPR ( Symbol(), 10, PERIOD_H4, 1 );

iWPR is a built-in indicator

double iWPR( string symbol, int timeframe, int period, int shift)
Larry Williams' Percent Range indicator calculation.
Parameters:
symbol - Symbol name of instrument, on data of which this indicator will be calculated. NULL means current symbol.
timeframe - Period. Can be one of the chart periods. 0 means the period of the current chart.
period - Period (number of bars) to calculate the indicator.
shift - Index of the value received from the indicator buffer (shift relative to the current bar back by a specified number of periods).


Example:
if(iWPR(NULL,0,14,0)>iWPR(NULL,0,14,1)) return(0);

it is described in the FAQ, have a look

wpr[...] is the array where results of each indicator with a different period are summarized

( you can name the array whatever you want)

double wpr[5] ;

wpr[1] = iWPR ( Symbol(), 10, PERIOD_H4, 1 );
wpr[2] = iWPR ( Symbol(), 20, PERIOD_H4, 1 );
wpr[3] = iWPR ( Symbol(), 40, PERIOD_H4, 1 );
wpr[4] = iWPR ( Symbol(), 60, PERIOD_H4, 1 );


I just showed a call with different periods...

The idea was to put a period in indicators so that you could test it on any TF

 
If the idea was to write a period in the indicators at once! so you could test it on any TF, I get it... -The Expert Advisor has no indicators, it only has H4 candles (as an indicator). -TF I will now try to consider everywhere in the code and then you can test it on any TF)
 

Decided to do an open order modification...

Right after OrderSend

      if (OrderSelect(0,SELECT_BY_POS)==true)
        if (OrderType()==OP_BUY)
          OrderModify(OrderTicket(),OrderOpenPrice(), Stop, Take, colorBaySell);


There is an error in the log:

invalid ticket for OrderModify function
11:43:54 2005.01.26 13:12 EURUSD: OrderModify error 4051
Please advise what is wrong?

 

The new stop values must be set as follows: :

OrderModify(OrderTicket(), OrderOpenPrice(), Bid- Stop*Point,.....
                                                    
where the new stop is set - in pips (in whole numbers)
 

Is MarketInfo() used for OrderClose needed for OrderModify?