missed trades on buffer calls

Hannah Wanjiku Kimari -
292
#property copyright""
#property link ""     
#property description ""
#property strict

//#property icon "\\Images\\HSJ.ico";
#define ea_name "Trend_Line"
#define my_version "1.03"
bool Print_Log = true;
bool debug = true;
bool Hide_Indicators = true;

#property version   my_version

#include "cvt.mqh"

sort_orders sort_a;
enum tp_type
{
    indicator_tp1,
    indicator_tp2,
    indicator_tp3,
    custom_tp,
};
enum sl_type
{
    indicator_sl,
    custom_sl,
};

input string EA_Version = my_version;
input datetime Compile_time = __DATETIME__;
input tp_type tp=indicator_tp1;
input int custom_tp_point=30;
input sl_type sl=indicator_sl;
input int custom_sl_point=100;
input double fix_lots=0.01;
input string               str1="=== TREND LINE SETTINGS ===";//-
input string               NameTrendLine= "Market\\TrendLine PRO MT5";//Indicator Name
input string               Separator0="";
input string               PathName="TL_Optimizer_Settings";
input bool                 UseAutoSetting=false;
input int                  iAmplitude=18;
input int                  iDays=50;
input double               iLevelTP1=0.2;
input double               iLevelTP2=0.7;
input double               iLevelTP3=1.2;
input double               iLevelSL=1.2;
input bool                 iUseFilter=false;
input ENUM_TIMEFRAMES      iTimeFrameF=PERIOD_CURRENT;
input bool                 iTimeFilter_Use=false;
input string               iTimeStart="10:00";
input string               iTimeEnd="21:00";
input color                TimeFilterColor=8421504;
input string               Separator3="";
input bool                 AlertON=false;
input bool                 PushON=true;
input bool                 EmailON=false;
input string               Separator5="";
input bool                 ShowPanel=false;
input bool                 ShowTPSLline=true;
input color                _TextColor=16777215;
input color                TPcolor=9470064;
input color                TPRcolor=42495;
input color                SLcolor=255;
input color                DealColor=11829830;
input int                  TPSize=8;
input int                  SLSize=8;
input string comment = ea_name + "_V" + my_version;
input int magic = 20220729;

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double buy_tp,sell_tp,buy_sl,sell_sl;
int HandleTrendLine;
int OnInit()
{
    //Comment(ea_name + " On Init!!!");
    //HideTestIndicators(Hide_Indicators);
    HandleTrendLine = iCustom(Symbol(), PERIOD_CURRENT, NameTrendLine,
                              Separator0,
                              PathName,
                              UseAutoSetting,
                              iAmplitude,
                              iDays,
                              iLevelTP1,
                              iLevelTP2,
                              iLevelTP3,
                              iLevelSL,
                              iUseFilter,
                              iTimeFrameF,
                              iTimeFilter_Use,
                              iTimeStart,
                              iTimeEnd,
                              TimeFilterColor,
                              Separator3,
                              AlertON,
                              PushON,
                              EmailON,
                              Separator5,
                              ShowPanel,
                              ShowTPSLline,
                              _TextColor,
                              TPcolor,
                              TPRcolor,
                              SLcolor,
                              DealColor,
                              TPSize,
                              SLSize,
                              PRICE_CLOSE
                              );
    if(HandleTrendLine == INVALID_HANDLE)
        return INIT_FAILED;
    return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
    Comment("");
    EventKillTimer();
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTick()
{
    main();
}
//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer()
{
    main();
}
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
{
    if(id == CHARTEVENT_KEYDOWN)
    {
        if(lparam == 'M')
        {
        }
        if(lparam == 'S')
        {
        }
    }
}
//+------------------------------------------------------------------+
bool reduce()
{
    if(
        true
        && sort_a.ord.buy_orders>0
        && (SymbolInfoDouble(Symbol(),SYMBOL_ASK)>buy_tp || SymbolInfoDouble(Symbol(),SYMBOL_BID)<buy_sl)
    )
    {
        close_by_type(Symbol(),magic,0);
        return true;
    }
    if(
        true
        && sort_a.ord.sell_orders>0
        && (SymbolInfoDouble(Symbol(),SYMBOL_BID)<sell_tp || SymbolInfoDouble(Symbol(),SYMBOL_ASK)>sell_sl)
    )
    {
        close_by_type(Symbol(),magic,1);
        return true;
    }
    return false;
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool add()
{
    return false;
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool creat()
{
    int ind_up=7;
    int ind_down=8;
    int ind_sl=9;
    int ind_tp1=10;
    int ind_tp2=11;
    int ind_tp3=12;
    int o;
    int x=1;
    double buy_signal = indiHT(ind_up, x);
    double sell_signal = indiHT(ind_down, x);
    if(
        true
        && sort_a.ord.buy_orders==0
        && buy_signal>0
        && buy_signal != EMPTY_VALUE
    )
    {
        if(tp==indicator_tp1) buy_tp=indiHT(ind_tp1,x);
        if(tp==indicator_tp2) buy_tp=indiHT(ind_tp2,x);
        if(tp==indicator_tp3) buy_tp=indiHT(ind_tp3,x);
        double vask=SymbolInfoDouble(Symbol(),SYMBOL_ASK);
        if(tp==custom_tp) buy_tp=vask+custom_tp_point*SymbolInfoDouble(Symbol(),SYMBOL_POINT);
        if(sl==indicator_sl) buy_sl=indiHT(ind_sl,x);
        if(buy_tp>vask && buy_sl<vask)
        {
            o=egOrderCreat(Symbol(), 0, fix_lots, comment, magic, 0, 0);
            egPrint(debug,"========== buy_tp:"+DoubleToStr(buy_tp,5)+"--- buy_sl: "+DoubleToStr(buy_sl,5));
            return true;
        }
    }
    if(
        true
        && sort_a.ord.sell_orders==0
        && sell_signal>0
        && sell_signal != EMPTY_VALUE
    )
    {
        if(tp==indicator_tp1) sell_tp=indiHT(ind_tp1,x);
        if(tp==indicator_tp2) sell_tp=indiHT(ind_tp2,x);
        if(tp==indicator_tp3) sell_tp=indiHT(ind_tp3,x);
        double vbid=SymbolInfoDouble(Symbol(),SYMBOL_BID);
        if(tp==custom_tp) sell_tp=vbid-custom_tp_point*SymbolInfoDouble(Symbol(),SYMBOL_POINT);
        if(sl==indicator_sl) sell_sl=indiHT(ind_sl,x);
        if(sell_tp<vbid && sell_sl>vbid)
        {
            o=egOrderCreat(Symbol(), 1, fix_lots, comment, magic, 0, 0);
            egPrint(debug,"========== sell_tp:"+DoubleToStr(sell_tp,5)+"--- sell_sl: "+DoubleToStr(sell_sl,5));
        }
        return true;
    }
    return false;
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void fresh_data()
{
    sort_a.load_orders(Symbol(), magic);
    if(sort_a.ord.buy_orders>0)
        sort_a.sort_buy();
    if(sort_a.ord.sell_orders>0)
        sort_a.sort_sell();
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool main()
{
    //Comment(ea_name + " Running!!! " + TimeToString(TimeCurrent(), TIME_DATE | TIME_SECONDS));
    fresh_data();
    if(
        reduce()
        || add()
        || creat()
    )
        return true;
    return false;
}
//+------------------------------------------------------------------+
/*
double egIdc_trend_line(string              symbol,
                        ENUM_TIMEFRAMES     period,
                        int                 out,
                        int                 k
                       )
{
    int handle=iCustom(symbol, period, NameTrendLine,
                       Separator0,
                       PathName,
                       UseAutoSetting,
                       iAmplitude,
                       iDays,
                       iLevelTP1,
                       iLevelTP2,
                       iLevelTP3,
                       iLevelSL,
                       iUseFilter,
                       iTimeFrameF,
                       iTimeFilter_Use,
                       iTimeStart,
                       iTimeEnd,
                       TimeFilterColor,
                       Separator3,
                       AlertON,
                       PushON,
                       EmailON,
                       Separator5,
                       ShowPanel,
                       ShowTPSLline,
                       _TextColor,
                       TPcolor,
                       TPRcolor,
                       SLcolor,
                       DealColor,
                       TPSize,
                       SLSize);
    double myidc[];
    CopyBuffer(handle,out,0,k+1,myidc);
    ArraySetAsSeries(myidc,true);
    return(myidc[k]);
}
*/
//+------------------------------------------------------------------+
bool egPrint(bool    isout=true,
             string  text=""
            )
{
    if (isout) Print(text);
    return(true);
}
//+------------------------------------------------------------------+
double indiHT(int buffer, int shift)
{
    double val[];
    CopyBuffer(HandleTrendLine, buffer, shift, 1, val);
    return val[0];
}
//+------------------------------------------------------------------+
Documentation on MQL5: Language Basics / Preprocessor / Program Properties (#property)
Documentation on MQL5: Language Basics / Preprocessor / Program Properties (#property)
  • www.mql5.com
Program Properties (#property) - Preprocessor - Language Basics - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
Files:
cvt.mqh  51 kb
William Roeder
28365
William Roeder  
  1. We can't verify the iCustom since you haven't provided the code/link.

  2. Do you really expect an answer? There are no mind readers here and our crystal balls are cracked. Always post all relevant code (using Code button) or attach the source file.
         How To Ask Questions The Smart Way. (2004)
              Be precise and informative about your problem

    We can't see your broken code.

    Use the debugger or print out your variables, including _LastError and prices and find out why. Do you really expect us to debug your code for you?
              Code debugging - Developing programs - MetaEditor Help
              Error Handling and Logging in MQL5 - MQL5 Articles (2015)
              Tracing, Debugging and Structural Analysis of Source Code - MQL5 Articles (2011)
              Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator - MQL5 Articles (2010)

Hannah Wanjiku Kimari -
292
the indicator is  free  the ea code is mine  or which seller are you asking me to call? why do you sound biter     uhhg  infact i just realized i pasted a wrong code   no one is special we are all humans and we make mistakes  if you have a solution check the whole code  i posted the correct file
Sergey Golubev
Moderator
126620
Sergey Golubev  

When you post code please use the CODE button (Alt-S)!

Use the CODE button

Hannah Wanjiku Kimari -
292
Sergey Golubev #:

When you post code please use the CODE button (Alt-S)!

thank you i have   reposted

William Roeder
28365
William Roeder  
  1. Hannah Wanjiku Kimari - #: thank you i have   reposted

    You did not use the code button properly.
        if(
            reduce()
            || add()
            || creat()
        )
            return true;
        return false;
    
    See the difference?
        if(
            reduce()
            || add()
            || creat()
        )
            return true;
        return false;
    
  2. Hannah Wanjiku Kimari - #: the indicator is  free 

    What part of “we can't verify the iCustom since you haven't provided the indicator code/link.” was unclear?

Hannah Wanjiku Kimari -
292
William Roeder #:
  1. You did not use the code button properly.
    See the difference?
  2. What part of “we can't verify the iCustom since you haven't provided the indicator code/link.” was unclear?

ooh i get it now check

Hannah Wanjiku Kimari -
292

the ea mises to take trades sometime exmple there will  be sell arrow but ea mises  to call for sell    not all the time but sometimes so am not sure  where the error is

Hannah Wanjiku Kimari -
292
does this  forum realy help?          as no one  has even tried to identify the problem in my code i shared as guided 
William Roeder
28365
William Roeder  
Hannah Wanjiku Kimari - #: does this  forum realy help?          as no one  has even tried to identify the problem in my code i shared as guided 

You have provided no useful information for that.

Use the debugger or print out your variables, including _LastError and prices and find out why. Do you really expect us to debug your code for you?
          Code debugging - Developing programs - MetaEditor Help
          Error Handling and Logging in MQL5 - MQL5 Articles (2015)
          Tracing, Debugging and Structural Analysis of Source Code - MQL5 Articles (2011)
          Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator - MQL5 Articles (2010)