Need help on CloseOrder at SAR cross - page 3

 

Hy phy, thanks for your answer. Could you please also explain the meaning of "shift" parameter in the indicators and "ma_shift" in iMA specifically?

Shift = Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago). From my so-so English and poor uderstanding of coding, terms like "shift", "buffer", "index" has something to do with the calculation speeds or memory allocated to the calculation of indicators etc. Then what sense does it make from the trading perspective to set "shift" other than 0?

ma_shift = Indicators line offset relate to the chart by timeframe. Say ma_shit = 5, is it to shift the MA line on the chart backward by 5 bars? Then again what is its trading purpose because I assume that calculations of indicators and execution of EA have nothing to do with what appears (line) on the chart.

All the above concerns derive from my not understanding some particular terms in English used in this coding context, e.g "offset", "index", "buffer" etc.

Thank you very much and best regards,

 
double iMA ( string symbol, int timeframe, int period, int ma_shift, int ma_method, int applied_price, int shift)
Calculates the Moving average indicator and returns its value.
Parameters:
symbol - Symbol the data of which should be used to calculate indicator. NULL means the current symbol.
timeframe - Timeframe. It can be any of Timeframe enumeration values. 0 means the current chart timeframe.
period - Averaging period for calculation.
ma_shift - MA shift. Indicators line offset relate to the chart by timeframe.
ma_method - MA method. It can be any of the Moving Average method enumeration value.
applied_price - Applied price. It can be any of Applied price enumeration values.
shift - Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago).

ma_shift:

the displayed indicator is offset (moved, shifted) to the past or future.

Put two MA on a chart (manually). Use the same parameters. You will see one line on the chart.
Now change the shift of one, and there will be two lines, identical shape, but one is moved (shifted or offset) to the future or past.

Why? Some people like it... Try shift of 1 on one MA, and make one Red and one Green. Now one color is on top in uptrend, the
other color on top in downtrend.


shift:

The bar at which you calculate the value. 0 = calculate indicator value for current bar. 1 = calculate for next newest bar, and so on. Usually
used in a loop, where you put the loop counter in the shift parameter, to calculate the indicato value for many bars.


index:

Usually same meaning as bar number.

Indicator Index usually means which indicator buffer (0-7)

 
mastermedea wrote >>

Hi phy,

Could you please explain what does the error 145 "order is too close to market" mean?

Thank you very much,

cheers

Dear Mastermedea,

I faced the same problem with you. However, it was solved. I will explained to you based on my knowledge. See the following codes:-

for (cnt = 0; cnt < OrdersTotal()-1; cnt++)
for (cnt = 0; cnt < OrdersTotal()-1; cnt--)

The 1st one is for opening order and Trailing whereas the 2nd ones for closing order. The most important things that coder need to know is the standardization of code in your EA. It is possible to use the following code as well:

for (cnt = 0; cnt < OrdersTotal(); cnt++)//open positions

Again, standardization is most important. Otherwise, you will get error 145 "order is too close to market"

Regards,

azizan8

 

"Could you please explain what does the error 145 "order is too close to market" mean?"

ERR_TRADE_MODIFY_DENIED 145 Modification denied because order too close to market.

Check MarketInfo(Symbol(), MODE_FREEZELEVEL)

MODE_FREEZELEVEL 33 Order freeze level in points. If the execution price lies within the range defined by the freeze level, the order cannot be modified, cancelled or closed.

Just another tool the Dealer can use to defeat your strategies.

Reason: