Page 142 of 180

Re: Coding Help

Posted: Thu Feb 09, 2023 10:02 pm
by saishala
Hello Mr. Mladen (and all the other people here and
all other Code Wizards).

Sorry to bother with requests since I should already know how to do something with code but I'm a potato and I don't know anything.

I would like to ask that, if possible, small labels be added to the alert symbols of the zig zags that indicate the corresponding timeframe. So that I could know and calculate better the braking time (using my VSA) to open better my orders.
And also if it can be a field to be able to change the alert sound and thus be able to put my voice messages in wav format. So the laptop yells at me when I'm away.
But the most important thing for me are the labels. the field to change the sound is secondary.
I put here some photos of why and an analogy so that I can explain better.

https://www.drivingtests.co.nz/resource ... distances/

Now I'm thinking here and I'm a Dumb..... I mark the timeframes in the photo Upside down. Because 1 minute go at faster I velocity in the chart, One Day go slower..... Sorry about this horrendous mistake......

Re: Coding Help

Posted: Fri Feb 17, 2023 6:11 am
by FLICKERS
Hello great coders i need a single stable vertical line with alert that will not disappear on daily and weekly candle so that if i change to smaller time frames the line will still be there on that daily candle opening on lower time frame like 4hrs, if the candle is green the vertical line should be green and the alert will read BUY same goes for SELL scenario, i downloaded one by mladen but its not what i want. Many times if i draw it and change to another time frame it will just disappear please assist me.Rgds

Re: Coding Help

Posted: Wed Feb 22, 2023 2:51 am
by FLICKERS
FLICKERS wrote: Fri Feb 17, 2023 6:11 am Hello great coders i need a single stable vertical line with alert that will not disappear on daily and weekly candle so that if i change to smaller time frames the line will still be there on that daily candle opening on lower time frame like 4hrs, if the candle is green the vertical line should be green and the alert will read BUY same goes for SELL scenario, i downloaded one by mladen but its not what i want. Many times if i draw it and change to another time frame it will just disappear please assist me.Rgds
Image

Image
Great!! i eventually got what i wanted in respect of the vertical line i have been searching for,...... One up for great programmers here, Mladen you are wonderful and you make my day thaaaaanks so much for the attached please if im not asking for much kindly help in adding color change over plus alert to it i know it will help us a lot believe me . The idea is to place the vertical line on DAILY CANDLE and if you trade the WEEKLY OR MONTHLY it will still display on those candles but the beauty of it is its ability to switch over to a new DAILY CANDLE everyday yes thats all i needed. So if the DAILY CANDLE TURNS BLUE an alert and a blue vertical line should display and also SELL mode, please kindly assist in tooshing it up . When you place it on daily chart like me i trade 4hrs and 1hr i will just go and look for trade set up either for buy or sell . Thanks

Coding Help: can anyone get this to work

Posted: Wed Mar 15, 2023 7:23 pm
by kenshin281180#
Hello fellow traders I was wondering if @mrtools, @Kvak or any other coderscould help with this code for identifying wedges. I'm no coder and was wondering if at all possible that either of you could take a look and see if it can be completed. Here is the code below....

Code: Select all

/+------------------------------------------------------------------+
//|                                            Wedge Detector.mq4    |
//|                                                    ChatGPT        |
//|                                                     2023-03-16   |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red      // Bearish Wedge
#property indicator_color2 LimeGreen // Bullish Wedge
//--- input parameters
extern int    WedgePeriod = 14;     // Period for calculating the wedges
extern double WedgeSlope  = 0.05;   // Minimum slope required for a valid wedge
//--- buffers
double BearishWedgeBuffer[];
double BullishWedgeBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
   //--- indicator buffers mapping
   SetIndexBuffer(0, BearishWedgeBuffer);
   SetIndexStyle(0, DRAW_ARROW, STYLE_SOLID, 2);
   SetIndexArrow(0, 233);
   SetIndexLabel(0, "Bearish Wedge");
   SetIndexBuffer(1, BullishWedgeBuffer);
   SetIndexStyle(1, DRAW_ARROW, STYLE_SOLID, 2);
   SetIndexArrow(1, 234);
   SetIndexLabel(1, "Bullish Wedge");
   //---
   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   int i, limit;
   double trend1, trend2, slope1, slope2, slope3, slope4, high, low;
   //--- determine the limit of bars to be calculated
   limit = Bars - WedgePeriod - 1;
   if (limit < 1) return(0);
   //--- main loop
   for (i = limit; i >= 0; i--)
   {
      //--- calculate the trend lines
      trend1 = iMA(NULL, 0, WedgePeriod, 0, MODE_EMA, PRICE_HIGH, i);
      trend2 = iMA(NULL, 0, WedgePeriod, 0, MODE_EMA, PRICE_LOW, i);
      slope1 = (iHigh(NULL, 0, i + WedgePeriod) - trend1) / WedgePeriod;
      slope2 = (trend1 - iLow(NULL, 0, i + WedgePeriod)) / WedgePeriod;
      slope3 = (iLow(NULL, 0, i + WedgePeriod) - trend2) / WedgePeriod;
      slope4 = (trend2 - iHigh(NULL, 0, i + WedgePeriod)) / WedgePeriod;
      high = iHigh(NULL, 0, i);
      low = iLow(NULL, 0, i);
      //--- detect bullish wedge
      if (slope1 < -WedgeSlope && slope2 > WedgeSlope && high > trend1 && low > trend2)
      {
         BullishWedgeBuffer[i] = low - 10 * Point;
      }
      else
      {
         BullishWedgeBuffer[i] = EMPTY_VALUE;
      }
      //--- detect bearish wedge
      if (slope3 > WedgeSlope && slope4 < -WedgeSlope && high < trend2 && low < trend1)
      {
         BearishWedgeBuffer[i] = high + 10 * Point;
      }
      else
      {
         BearishWedgeBuffer[i] =
         // Bullish Rising Wedge Indicator
double A, B, C, D, E, F, G, H, I, J, K, L, M, N;
double x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6;
double SlopeAB, SlopeCD, SlopeEF, SlopeGH, SlopeIJ;
double p1, p2, p3, p4, p5, p6;
int i, shift;
void OnInit()
{
    SetIndexStyle(0,DRAW_LINE);
    SetIndexBuffer(0,NULL);
}
void OnCalculate(const int rates_total,
                 const int prev_calculated,
                 const datetime &time[],
                 const double &open[],
                 const double &high[],
                 const double &low[],
                 const double &close[],
                 const long &tick_volume[],
                 const long &volume[],
                 const int &spread[])
{
    shift = Bars-IndicatorCounted();
    for(i=shift; i>=0; i--)
    {
        A = High[i+2];
        B = Time[i+2];
        C = High[i+1];
        D = Time[i+1];
        E = High[i];
        F = Time[i];
        G = Low[i+2];
        H = Low[i+1];
        I = Low[i];
        J = High[i+3];
        K = High[i+4];
        L = Low[i+3];
        M = Low[i+4];
        N = Low[i+5];
        SlopeAB = (A-C)/(B-D);
        SlopeCD = (C-E)/(D-F);
        SlopeEF = (G-I)/(F-H);
        SlopeGH = (G-K)/(H-J);
        SlopeIJ = (L-N)/(J-M);
        if(SlopeAB<SlopeCD && SlopeEF<SlopeGH && SlopeGH<SlopeIJ && MathAbs(SlopeAB)>MathAbs(SlopeEF))
        {
            x1 = B;
            y1 = A;
            x2 = D;
            y2 = C;
            x3 = F;
            y3 = E;
            x4 = H;
            y4 = G;
            x5 = J;
            y5 = K;
            x6 = M;
            y6 = L;
            p1 = iCustom(NULL,0,"Point",x1,y1);
            p2 = iCustom(NULL,0,"Point",x2,y2);
            p3 = iCustom(NULL,0,"Point",x3,y3);
            p4 = iCustom(NULL,0,"Point",x4,y4);
            p5 = iCustom(NULL,0,"Point",x5,y5);
            p6 = iCustom(NULL,0,"Point",x6,y6);
            if(p1!=0 && p2!=0 && p3!=0 && p4!=0 && p5!=0 && p6!=0)
            {
                SetIndexShift(0,shift);
                IndicatorBuffer[0][shift] = 0;
                for(int j=0;j<=6;j++)
                {
                    ObjectCreate("line"+j,OBJ_TREND,0,x1-j*(x1-x6)/6,y1+j*(y6-y1)/6,x6-j*(x1-x6)/6,y6+j*(y6-y1)/6);
                    ObjectSet("line"+j,
#property indicator_chart_window

extern int wedge_size = 20;
extern int look_back = 100;

void find_wedges()
{
    double top[]; // array for wedge tops
    double bottom[]; // array for wedge bottoms
    int top_count = 0; // number of wedge tops found
    int bottom_count = 0; // number of wedge bottoms found
    
    for (int i = look_back; i >= wedge_size; i--)
    {
        double highest_high = High[i];
        double lowest_low = Low[i];
        int last_peak_index = 0;
        int last_trough_index = 0;
        bool is_rising_wedge = false;
        bool is_falling_wedge = false;
        
        // look for the highest high and lowest low within wedge size
        for (int j = i; j >= i - wedge_size; j--)
        {
            if (High[j] > highest_high)
            {
                highest_high = High[j];
                last_peak_index = j;
            }
            if (Low[j] < lowest_low)
            {
                lowest_low = Low[j];
                last_trough_index = j;
            }
        }
        
        // check if the wedge is rising or falling
        if (highest_high - Low[last_trough_index] < High[last_peak_index] - lowest_low)
        {
            is_rising_wedge = true;
        }
        else
        {
            is_falling_wedge = true;
        }
        
        // check if the wedge has been broken
        bool is_wedge_broken = false;
        for (int j = last_peak_index; j >= last_trough_index; j--)
        {
            if (High[j] > highest_high || Low[j] < lowest_low)
            {
                is_wedge_broken = true;
                break;
            }
        }
        
        // add the wedge to the array if it hasn't been broken
        if (!is_wedge_broken)
        {
            if (is_rising_wedge)
            {
                top[top_count] = highest_high;
                bottom[bottom_count] = lowest_low;
                top_count++;
                bottom_count++;
            }
            else if (is_falling_wedge)
            {
                top[top_count] = highest_high;
                bottom[bottom_count] = lowest_low;
                top_count++;
                bottom_count++;
            }
        }
    }
    
    // plot the wedges
    for (int i = 0; i < top_count; i++)
    {
        ObjectCreate("Rising Wedge "+i, OBJ_TREND, 0, Time[top_count-i-1], top[i], Time[bottom_count-i-1], bottom[i]);
        ObjectSet("Rising Wedge "+i, OBJPROP_COLOR, Green);
    }
    for (int i = 0; i < bottom_count; i++)
    {
        ObjectCreate("Falling Wedge "+i, OBJ_TREND, 0, Time[bottom_count-i-1], bottom[i], Time[top_count-i-1], top[i]);
        ObjectSet("Falling Wedge "+i, OBJPROP_COLOR, Red);
    }
}

int init()
{
    return(0);
}

int start()
{
    find_wedges();
    return(0);
}
// --- indicator parameters
extern int LookBackBars=500;  // Number of bars to look back for wedge formation
extern double WedgeThreshold=0.1;  // Minimum slope of wedge pattern
extern color BullWedgeColor=Green;  // Color of bullish wedge pattern
extern color BearWedgeColor=Red;  // Color of bearish wedge pattern

// --- indicator buffers
double BullishWedge[];
double BearishWedge[];

// --- indicator initialization function
int init()
{
   // --- indicator buffers mapping
   SetIndexBuffer(0, BullishWedge);
   SetIndexBuffer(1, BearishWedge);
   
   // --- set indicator labels
   SetIndexLabel(0, "Bullish Wedge");
   SetIndexLabel(1, "Bearish Wedge");
   
   // --- set indicator colors
   SetIndexStyle(0, DRAW_ARROW, 0, 2, BullWedgeColor);
   SetIndexStyle(1, DRAW_ARROW, 0, 2, BearWedgeColor);
   
   return(0);
}

// --- indicator calculation function
int start()
{
   // --- get the number of bars on the chart
   int limit=Bars-LookBackBars-1;
   
   // --- loop through the bars to find wedge patterns
   for(int i=limit; i>=0; i--)
   {
      // --- calculate the slope of the wedge
      double slope=(iMA(NULL, 0, 5, 0, MODE_LWMA, PRICE_CLOSE, i)-iMA(NULL, 0, 30, 0, MODE_LWMA, PRICE_CLOSE, i))/(30-5);
      
      // --- check if the slope meets the threshold for a wedge pattern
      if(MathAbs(slope)<=WedgeThreshold)
      {
         // --- check if the wedge is bullish or bearish
         if(slope>0)
         {
            // --- set the bullish wedge buffer to the low of the wedge pattern
            BullishWedge[i]=Low[i]-Point*2;
         }
         else
         {
            // --- set the bearish wedge buffer to the high of the wedge pattern
            BearishWedge[i]=High[i]+Point*2;
         }
      }
   }
   
   return(0);
}

Re: Coding Help: can anyone get this to work

Posted: Wed Mar 15, 2023 7:31 pm
by Jimmy
kenshin281180# wrote: Wed Mar 15, 2023 7:23 pm Hello fellow traders I was wondering if @mrtools or @Kvak could help with this code for identifying wedges. I'm no coder and was wondering if at all possible that either of you could take a look and see if it can be completed. Here is the code below....
Hi, in future please help us out by wrapping your code using this guide to keep things neat on the forum and easier for coders to read.

Re: Coding Help: can anyone get this to work

Posted: Wed Mar 15, 2023 10:14 pm
by kenshin281180#
Jimmy wrote: Wed Mar 15, 2023 7:31 pm Hi, in future please help us out by wrapping your code using this guide to keep things neat on the forum and easier for coders to read.
Thank you

Re: I need a programmer

Posted: Thu Mar 16, 2023 1:46 pm
by tonnogueira
hello, I'm from Brazil, I don't speak English, we can use google translator to understand each other.
I need someone to code a risk management EA (Robot), based on an excel spreadsheet that I use. I use some parameters, SL size, TP, risk per operation according to total capital, etc. With all the correct parameters, the only thing I need is to know the size of the Stop Loss order, when this information is placed, the spreadsheet automatically places it, the TP, the size of the lots to be used, etc.

Re: Coding Help

Posted: Sun Mar 19, 2023 8:26 am
by pin12
Coding error

This robot works in the opposite direction to what is seen in the video. Can a mql4 programming expert check what is wrong please?

Thanks


Re: Coding Help

Posted: Sun Mar 19, 2023 12:22 pm
by FoxFoxicle
Hello great coders of all time.

Can you help me how can we turn this indi to show something like in the picture.

Basically an ADR but instead of daily range, an average hourly range with H4 and H1 average high/low lines for "n" or a number of previous candles.

The picture only shows the manually drawn H4 range but I also hope to see the average H1 range.

It's like a continuous H4 high/low lines but it should be the average of previous H4 candles plotted like that.

Re: Coding Help

Posted: Sun Mar 19, 2023 7:30 pm
by andrei-1
FoxFoxicle wrote: Sun Mar 19, 2023 12:22 pm
One of them is ordinary. The second one is yours.

ATR_lim how many bars to take for averaging.

It may show a strange picture. Don't be surprised, it's MTF. You need to download the history of the desired timeframe.