Please help. I can not understand the for() loop, all the time after the update, because of the offset(iMA(NULL,PERIOD_M1,1,1,MODE_SMA,PRICE_OPEN,i)) The indicator redraws!
//+------------------------------------------------------------------+//| help.mq4 |//| Copyright 2014, MetaQuotes Software Corp. |//| http://www.mql5.com |//+------------------------------------------------------------------+#property copyright"2005-2014, MetaQuotes Software Corp."#property link"http://www.mql4.com"#property strict#include <MovingAverages.mqh>
//--- indicator settings#property indicator_separate_window#property indicator_buffers2#property indicator_color1 clrSilver#property indicator_color2 clrRed#property indicator_width1 2//--- indicator parametersinputint SignalSMA=8; // Signal SMA Period//--- indicator buffersdouble ExtBuffer[];
double ExtSignalBuffer[];
//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+intOnInit(void)
{
IndicatorDigits(Digits+1);
//--- drawing settingsSetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexStyle(1,DRAW_LINE);
//--- indicator buffers mappingSetIndexBuffer(0,ExtBuffer);
SetIndexBuffer(1,ExtSignalBuffer);
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+//| Moving Averages Convergence/Divergence |//+------------------------------------------------------------------+intOnCalculate(constint rates_total,
constint prev_calculated,
constdatetime &time[],
constdouble &open[],
constdouble &high[],
constdouble &low[],
constdouble &close[],
constlong &tick_volume[],
constlong &volume[],
constint &spread[])
{
int i,limit;
//--- last counted bar will be recounted
limit=rates_total-prev_calculated;
if(prev_calculated>0)
limit++;
//--- counted in the 1-st bufferfor(i=0;i<limit;i++)
ExtBuffer[i]=(
iMA(NULL,PERIOD_CURRENT,1,0,MODE_SMA,PRICE_HIGH,i)
+iMA(NULL,PERIOD_M1,1,1,MODE_SMA,PRICE_OPEN,i)
);
//--- signal line counted in the 2-nd buffer
SimpleMAOnBuffer(rates_total,prev_calculated,0,SignalSMA,ExtBuffer,ExtSignalBuffer);
//--- donereturn(rates_total);
}
//+------------------------------------------------------------------+
In my opinion, the approach is not logical at all. Why define the day of the week? What difference does it make what day it is, if the condition should say "do not open more than xxx orders today"?
It seems more logical to me to count the orders opened today and specify the corresponding condition.
there is no date of order opening.
If you know, please write how to do it) I do not understand how to make sure that on any given day no more than n-th number of orders are opened during the whole day.
Please help. I can not understand the for() loop, all the time after the update, because of the offset(iMA(NULL,PERIOD_M1,1,1,MODE_SMA,PRICE_OPEN,i)) The indicator redraws!
I thank you in advance.
The MAs have different TFs. You need to sort of fit the higher timeframe into the M1 TF, i.e. count the MAs twice with different numbers of ticks. In this case one and the same value of the older period will be added to different values of the younger one.
If you look through i you get, for example, 10 candles of period D1 and 10 M1. Logically something is wrong....
Another thing, if the indicator is set on M1, it will work without re-brisings most likely
cripple: Yes you are right, but my mind is still not enough to understand how to make M1 count correctly
Try
intBars(
string symbol_name, // имя символаENUM_TIMEFRAMES timeframe, // периодdatetimestart_time, // с какой датыdatetime stop_time // по какую дату
);
time of the i-th bar and put the resulting bar number instead of i.
LRA: Dear novikov433!!! Teach you programming, or write you a free Expert Advisor or both!!! In exchange, teach me how loss-making orders are translated into no-loss. You can use a simple example. I give my wife an order (order): buy a bucket of potatoes early in the morning at the market, and by 10 o'clock (fundamental analysis) the price goes up - sell. But sometimes a truckload of potatoes arrives at 10:30 (news). And the price (on the news) instantly goes down and it lasts till the end of the day, or even for the whole week. I place a Stop Loss - if the price falls by 10 rubles, I sell as soon as I can (at the market price). How to change the order, to avoid losses. If this variant is interesting - send us your e-mail.
The problem is that the market went slightly to the required side and then went back, so you need to close the deal at breakeven and open it for a reverse. i got addicted to it as soon as i start. once again i got convinced that it is bullshit to trade with hands. how do i understand why i need to write so many components in my code?
ax00071: Thank you for your attention )) I am a sucker ... ... at closing I had the condition to close the deal at 22:00 on Friday, without any additional conditions to check the deal type. The deal itself closed a couple of hours earlier. Well, when 22:00 p.m. came, the Expert Advisor started sending orders to close an order that was already closed ... .
You should hardly call yourself a plant. If you have managed to locate, understand and correct such an error, you are getting closer to the level of a programmer!
Please help. I can not understand the for() loop, all the time after the update, because of the offset(iMA(NULL,PERIOD_M1,1,1,MODE_SMA,PRICE_OPEN,i)) The indicator redraws!
Many thanks in advance.
In my opinion, the approach is not logical at all. Why define the day of the week? What difference does it make what day it is, if the condition should say "do not open more than xxx orders today"?
It seems more logical to me to count the orders opened today and specify the corresponding condition.
there is no date of order opening.If you know, please write how to do it)
I do not understand how to make sure that on any given day no more than n-th number of orders are opened during the whole day.
Please help. I can not understand the for() loop, all the time after the update, because of the offset(iMA(NULL,PERIOD_M1,1,1,MODE_SMA,PRICE_OPEN,i)) The indicator redraws!
I thank you in advance.
The MAs have different TFs. You need to sort of fit the higher timeframe into the M1 TF, i.e. count the MAs twice with different numbers of ticks. In this case one and the same value of the older period will be added to different values of the younger one.
If you look through i you get, for example, 10 candles of period D1 and 10 M1. Logically something is wrong....
Another thing, if the indicator is set on M1, it will work without re-brisings most likely
the MAs have different TFs. you have to sort of fit the higher timeframe into the M1 TF, i.e. count the MAs twice with different numbers of ticks.
By going through i you are now taking for example 10 candles of period D1 and 10 M1. Logically something is wrong....
Yes you are right, but my mind is still not enough to figure out how to get M1 to count correctly
Besides, I need to synchronize M1 with a higher timeframe, because 1 bar of M5 will not necessarily correspond to 5 candles of M1, it may be 4 or 1.
Yes you are right, but my mind is still not enough to understand how to make M1 count correctly
Try
time of the i-th bar and put the resulting bar number instead of i.
Dear novikov433!!! Teach you programming, or write you a free Expert Advisor or both!!! In exchange, teach me how loss-making orders are translated into no-loss. You can use a simple example. I give my wife an order (order): buy a bucket of potatoes early in the morning at the market, and by 10 o'clock (fundamental analysis) the price goes up - sell. But sometimes a truckload of potatoes arrives at 10:30 (news). And the price (on the news) instantly goes down and it lasts till the end of the day, or even for the whole week. I place a Stop Loss - if the price falls by 10 rubles, I sell as soon as I can (at the market price). How to change the order, to avoid losses. If this variant is interesting - send us your e-mail.
Try
the time of the i-th bar and put the resulting bar number instead of i.
Have you thought of something like this?
Thank you for your attention )) I am a sucker ... ... at closing I had the condition to close the deal at 22:00 on Friday, without any additional conditions to check the deal type. The deal itself closed a couple of hours earlier. Well, when 22:00 p.m. came, the Expert Advisor started sending orders to close an order that was already closed ... .