Buy at the Low, Sell at the high

 

Hey everyone,

I've coded an indicator that draws the previous and current high and low. But now i want to enter into a position at those points.

I've tried - If (ask == high) trade.Sell() ...... and other variations and it doesnt work. I've looked through codebase as well and i cant seem to find anything that isnt breakout.

This is NOT a breakout strategy i must add. I also tried adding the indicator into the EA but i failed at that as well. 

I'm just asking for some assistance. I will not be paying anyone. I've attached a screenshot of the indicator as well as the code for it.

Screenshot of HighLow indicator

The green line is the High. The white line is the Median. The Red line is the low.

#property indicator_chart_window

#property indicator_buffers 4
#property indicator_plots 3

#property indicator_type1 DRAW_LINE
#property indicator_color1 clrGreen

#property indicator_type2 DRAW_LINE
#property indicator_color2 clrRed

#property indicator_type3 DRAW_LINE
#property indicator_color3 clrWhite

double prevMonthHigh[], prevMonthLow[], prevMonthMedian[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   SetIndexBuffer(0,prevMonthHigh,INDICATOR_DATA);
   SetIndexBuffer(1,prevMonthLow,INDICATOR_DATA);
   SetIndexBuffer(2,prevMonthMedian,INDICATOR_DATA);
   
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int 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[])
                
  {
      for(int i = prev_calculated; i < rates_total; i++)
      {
       int shift = iBarShift(_Symbol,PERIOD_MN1,time[i]);
       double highD1 = iHigh(_Symbol,PERIOD_MN1,shift);
       double lowD1 = iLow(_Symbol,PERIOD_MN1,shift);
       double Median = (highD1 + lowD1) / 2;
      
       prevMonthHigh[i] = highD1;
       prevMonthLow[i] = lowD1;
       prevMonthMedian[i] = Median;
      }
   
   return(rates_total);
  }
//+------------------------------------------------------------------+  
 
Vengeance Seeker:

Hey everyone,

I've coded an indicator that draws the previous and current high and low. But now i want to enter into a position at those points.

I've tried - If (ask == high) trade.Sell() ...... and other variations and it doesnt work. I've looked through codebase as well and i cant seem to find anything that isnt breakout.

This is NOT a breakout strategy i must add. I also tried adding the indicator into the EA but i failed at that as well. 

I'm just asking for some assistance. I will not be paying anyone. I've attached a screenshot of the indicator as well as the code for it.

The green line is the High. The white line is the Median. The Red line is the low.

get buy sell code from this 

Buy Sell on your Price
Buy Sell on your Price
  • www.mql5.com
Buy Sell on your price, Choose Market order, Pending Limit order or Pending Stop Order
 
  1. Vengeance Seeker: I'm just asking for some assistance. I will not be paying anyone. I've attached a screenshot of the indicator as well as the code for it.

    So where is your EA code that you are asking for assistance? Show us your attempt (using the CODE button) and state the nature of your difficulty.
              No free help (2017)

    Or pay someone. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum (2018)

    We're not going to code it for you (although it could happen if you are lucky or the issue is interesting).
              No free help (2017)


  2. Vengeance Seeker: I've tried - If (ask == high) trade.Sell()

    Doubles are rarely equal. Understand the links in:
              The == operand. - MQL4 programming forum #2 (2013)


 
Arpit T #:

get buy sell code from this 

Thank you

 
This indicator looks great