Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 835

 
woin2110:
It's all about the dumb broker who draws Monday as a Sunday candle on the daily chart, but instead of Monday some xxx artist drew his own candle. Now I think how to use correct data of previous days. I have to make an Expert Advisor for all brokers. And specifically to find the freaking minimum and maximum of the last working day.
Well, then we should look for the last bar of Friday, preferably a minute. And Monday is Monday from the first bar of M1, for which DayOfWeek()=1 (or on difference of time zones to count).
 
Kirill875:

Sorry for any scribbles, this is my first one.

Everything in it suits me except one, I would like to see indicators from hourly chart on m5.

int sh = iBarShift(NULL, 60, Time[i], false);

Close[i] => iClose(NULL,60,sh)

iMA(NULL,60,....,sh)

 
evillive:

Using iHighest(),iLowest(), how many M5 bars in a day is known, the offset to the end of the previous day, I think, can also be calculated.

I did the calculation on the hour hand, problem solved, thank you very much.

   int Min=iLowest(NULL, PERIOD_H1, MODE_LOW , 24, Hour());

   int Max=iHighest(NULL, PERIOD_H1, MODE_HIGH, 24, Hour());

   price1=iLow(NULL, PERIOD_H1,Min);

   price2=iHigh(NULL,PERIOD_H1,Max);

And here's such a small question, how to determine the situation when the terminal has just started.

I need to run del=ObjectsDeleteAll(0,OBJ_HLINE); at next start of terminal

 
woin2110:

And here's a small question, how to determine the situation when the terminal has just started.

I need to run del=ObjectsDeleteAll(0,OBJ_HLINE); at next start of terminal

So you need to run script after terminal start, with this line in it. Autorun is discussed here.
 
woin2110:
But, it is only possible through the daily chart data.

What do you mean by daily chart data? Switching the chart? There is no need to switch.

хай_вчерашнего_дня = iHigh(_Symbol, PERIOD_D1, 1);
 
Kirill875:
evillive, Thanks for the response, could you please poke me in which part of the code this needs to be inserted.
int sh = iBarShift(NULL, 60, Time[i], false); - in main calculation loop, the rest - replacement everywhere it occurs.
 

Hello to all participants! Please help me to set up the indicators. I'm not very good at this science.

1. Indicator SimpleBars - does not save settings (colour, lines, etc.) when changing timeframe, increasing or decreasing the graph, etc.. The settings are also lost in the template. When I run MT4, always have to correct. (( I use it simply as an indicator, not in my EA. Help to adjust who can.

 

And another indicator is the 2MA with clouds. It doesn't save the settings either. It's a real trouble. Somehow no problems with other indicators, but this one glitches one after another. Help me, please fix it.

//+------------------------------------------------------------------+

//| ytg_DveMashki_ind.mq4

//| Yuriy Tokman |

//| yuriytokman@gmail.com |

//+------------------------------------------------------------------+

#property copyright "Yuriy Tokman"

#property link "yuriytokman@gmail.com"


#property indicator_chart_window

#property indicator_buffers 2

//#property indicator_color1 //Green

//#property indicator_color2 //Red

//#property indicator_width1 //4

//#property indicator_width2 //4

//----

extern color color1 = Green;

extern colour colour2 = Red;

extern int width1 = 0;

extern int width2 = 0;

extern int style1 = 0;

extern int style2 = 0;

extern int ma_1 = 25;

extern int ma_2 = 50;

extern int method = 0;

extern int price = 0;

//---- buffers

double ExtMapBuffer1[];

double ExtMapBuffer2[];

//----

int ExtCountedBars=0;

//\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n

int init()

{

//---- indicators

SetIndexStyle(0,DRAW_HISTOGRAM, style1, width1, color1);

SetIndexBuffer(0,ExtMapBuffer1);

SetIndexStyle(1,DRAW_HISTOGRAM, style2, width2, color2);

SetIndexBuffer(1,ExtMapBuffer2);

IndicatorShortName("yuriytokman@gmail.com");

SetIndexLabel(0, "yuriytokman@gmail.com");

SetIndexLabel(1, "yuriytokman@gmail.com");

//----

SetIndexDrawBegin(0,10);

SetIndexDrawBegin(1,10);

//---- indicator buffers mapping

SetIndexBuffer(0,ExtMapBuffer1);

SetIndexBuffer(1,ExtMapBuffer2);

Comment("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n yuriytokman@gmail.com");


return(0);

}

//\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n

int start()

{

if(Bars<=10) return(0);

ExtCountedBars=IndicatorCounted();

//---- check for possible errors

if(ExtCountedBars<0) return(-1);

//---- last counted bar will be recounted

if (ExtCountedBars>0) ExtCountedBars--;

int=Bars-ExtCountedBars-1;

while(pos>=0)

{

ExtMapBuffer1[pos]=iMA(Symbol(),0,ma_1,0,method,price,pos);

ExtMapBuffer2[pos]=iMA(Symbol(),0,ma_2,0,method,price,pos);

pos--;

}

//----

return(0);

}

//\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n

 
Roman_Bryansk:

Hello to all participants! Please help me set up the indicators. I'm not good at this science.

1. Indicator SimpleBars - does not save settings (colour, lines, etc.) when changing timeframe, increasing or decreasing the graph, etc.. The settings are also lost in the template. When I run MT4, always have to correct. (( I use it simply as an indicator, not in my EA. Help to adjust who can.


For the code there is a button at the top of the message editing panel or the Ctrl+Alt+M combination, the code becomes nice and readable. And about loss, f-function SetIndexStyle() has a parameter colour, use it, do not hesitate.
 

Thanks for the tip. That's what I thought the message was like, it doesn't look good. Good to know. Correcting the message.

//+------------------------------------------------------------------+
//|                                                    SimpleBars.mq4|
//|                                                  excelf@gmail.com|
//+------------------------------------------------------------------+
#property copyright "Copyright © 2012, Ivan Kornilov. All rights reserved."
#property link "excelf@gmail.com"

#property indicator_chart_window
#property indicator_buffers 4
#property  indicator_color1 Red
#property  indicator_color2 Green
#property  indicator_color3 Red
#property  indicator_color4 Green

#define  SIGNAL_NONE        0//Пустой сигнал
#define  SIGNAL_BUY         1//Сигнал на покупку 
#define  SIGNAL_SELL       -1//Сигнал на продажу 
#define  SIGNAL_TRADE_ALLOW 3//Сигнал разрешающий торговлю


extern int period = 6;
extern bool useClose = true;
extern int width = 1;

double bufferRed1[];
double bufferGreen1[];
double bufferRed2[];
double bufferGreen2[];
double trand[];

int init() {
    IndicatorBuffers(5);
 
    SetIndexBuffer(0, bufferRed1);
    SetIndexBuffer(1, bufferGreen1);
    SetIndexBuffer(2, bufferRed2);
    SetIndexBuffer(3, bufferGreen2);
    SetIndexBuffer(4, trand);
    
    IndicatorDigits(Digits+1);
    SetIndexStyle(0, DRAW_HISTOGRAM, 0, 1);
    SetIndexStyle(1, DRAW_HISTOGRAM, 0, 1);
    SetIndexStyle(2, DRAW_HISTOGRAM, 0, width);
    SetIndexStyle(3, DRAW_HISTOGRAM, 0, width);
}


int start() {
   int counted_bars=IndicatorCounted();

   if(counted_bars > 0) {
       counted_bars--;
   }
   int limit = Bars - counted_bars;

   int j;
   double buyPrice;
   double sellPrice;
   for(int i = limit - 1; i >= 0; i--) {
        if(useClose) {
            buyPrice = Close[i];
            sellPrice = Close[i];
        } else {
            buyPrice = Low[i];
            sellPrice = High[i];
        }
        if(trand[i + 1] == SIGNAL_NONE || trand[i + 1] == EMPTY_VALUE) {
            if(Close[i] > Open[i]) {
               trand[i] = SIGNAL_BUY;
           } else {
               trand[i] = SIGNAL_SELL;
           }
        } else {
            if(trand[i + 1] == SIGNAL_BUY) {
                if(buyPrice > Low[i + 1]) {
                   trand[i] = SIGNAL_BUY;
                } else {
                   for(j = 2; j <= period; j++) {
                        if(buyPrice > Low[i + j]) {
                           trand[i] = SIGNAL_BUY;
                        break;
                        } else {
                           trand[i] = SIGNAL_SELL;
                        }
                   }
                }
            } else if(trand[i + 1] == SIGNAL_SELL) {
                if(sellPrice < High[i + 1]) {
                   trand[i] = SIGNAL_SELL;
                } else {
                    for(j = 2; j <= period; j++) {
                        if(sellPrice < High[i + j]) {
                           trand[i] = SIGNAL_SELL;
                           break;
                        } else {
                           trand[i] = SIGNAL_BUY;
                        }
                   }
                }
            }   
        }

        if(trand[i] == SIGNAL_SELL) {//RED BAR 
            bufferRed1[i]  = High[i];
            bufferGreen1[i] = Low[i]; 
            bufferRed2[i]  = MathMax(Open[i], Close[i]); 
            bufferGreen2[i] = MathMin(Open[i], Close[i]);   
        } else if(trand[i] == SIGNAL_BUY)  {
            bufferRed1[i]  = Low[i];
            bufferGreen1[i] = High[i]; 
            bufferRed2[i]  = MathMin(Open[i], Close[i]);  
            bufferGreen2[i] = MathMax(Open[i], Close[i]);    
        } 
    }
}
Reason: