learning mql5

....h

//----

MQL5:
   double coppocks[];
 
   if(CopyBuffer(handlecoppock, 0, 0, 3,coppocks) <= 0)
     {
      Print("failed to get coppock data!");
      return;
     }
 
 
//+--
//------

correction....... forgot ArraySetAsSeries(coppocks,true);

......h
//-----


MQL5:
   double coppocks[];
   ArraySetAsSeries(coppocks,true);  //----- <------    !!!!!!
   if(CopyBuffer(handlecoppock, 0, 0, 4,coppocks) <= 0)
     {
      Print("failed to get coppock data!");
      return;
     }
 
  bool buy  = false;
  bool sell = false;
 
  if(usealma)
  {
    buy  = (almas[1] > almas[2]) && (almas[2] < almas[3]);
    sell = (almas[1] < almas[2]) && (almas[2] > almas[3]);
  }
 
  if(usehma)
  {
    buy  = (htfhmas[1] > htfhmas[2]) && (hmas[1] > hmas[2]) && (hmas[2] < hmas[3]);    // ----  htfhmas ....  higher time frame hma's as  additional filter
    sell = (htfhmas[1] < htfhmas[2]) && (hmas[1] < hmas[2]) && (hmas[2] > hmas[3]);
  } 
 
  if(usecoppock)
  {
    buy  = (coppocks[1] > 0.0) && (coppocks[2] < 0.0);
    sell = (coppocks[1] < 0.0) && (coppocks[2] > 0.0);
  }
 
trailingstop......h
//-----

MQL5:
void TrailingStop(double ask, double bid)                      //-----  stoploss set in inputs                               
{ 
    for(int i = PositionsTotal() - 1; i >= 0; i--)
       {
        string symbol = PositionGetSymbol(i);
 
     if(_Symbol == symbol)
        {
         ulong  ticket    = PositionGetInteger(POSITION_TICKET);
         double loss      = PositionGetDouble(POSITION_SL);
         double profit    = PositionGetDouble(POSITION_TP);
 
 
        if((PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY) && (NormalizeDouble(bid-(stoploss*_Point),_Digits) > loss))   
           {
           trade.PositionModify(ticket,NormalizeDouble(bid-(stoploss*_Point),_Digits),profit);
           }
 
 
        if((PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL) && (NormalizeDouble(ask+(stoploss*_Point),_Digits) < loss))         
          {
           trade.PositionModify(ticket,NormalizeDouble(ask+(stoploss*_Point),_Digits) ,profit);
          }
 
 
       }
       }
}
 
......h

//------

MQL5:
  if(choice == 12) {usetema            = true;}
  if(choice == 13) {usetemahtf         = true;}
 
  if(choice == 14) {usedema            = true;}
  if(choice == 15) {usedemahtf         = true;}
 
  if(choice == 16) {usetrix            = true;}
  if(choice == 17) {usetrixhtf         = true;}
 
  if(choice == 18) {uservi            = true;}
  if(choice == 19) {uservihtf         = true;}
 
 
 
  bool buy  = false;
  bool sell = false;
 
  if(usealma)
  {
    buy  = (almas[1] > almas[2]) && (almas[2] < almas[3]);
    sell = (almas[1] < almas[2]) && (almas[2] > almas[3]);
  }
 
  if(usealmahtf)
  {
    buy  = (almas[1] > almas[2]) && (almas[2] < almas[3]) && (htfhmas[1] > htfhmas[2]);
    sell = (almas[1] < almas[2]) && (almas[2] > almas[3]) && (htfhmas[1] < htfhmas[2]);
  }
//-------
 
  if(usehma)
  {
    buy  = (hmas[1] > hmas[2]) && (hmas[2] < hmas[3]);
    sell = (hmas[1] < hmas[2]) && (hmas[2] > hmas[3]);
  } 
 
  if(usehmahtf)
  {
    buy  = (htfhmas[1] > htfhmas[2]) && (hmas[1] > hmas[2]) && (hmas[2] < hmas[3]);
    sell = (htfhmas[1] < htfhmas[2]) && (hmas[1] < hmas[2]) && (hmas[2] > hmas[3]);
  } 
//----
 
//-----
 
 
//---------   
   if(sell)
     {
 
      double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);
      double sl = bid + stoploss * _Point;
      double tp = bid - profittarget * _Point;
      MqlTradeRequest request;                                         //----   https://www.mql5.com/en/book/automation/experts/experts_mqltraderequest
      MqlTradeResult  result;                                          //----   https://www.mql5.com/en/docs/constants/structures/mqltraderesult
      ZeroMemory(request);                                             //----   https://www.mql5.com/en/docs/common/zeromemory
      ZeroMemory(result);
 
      request.action    = TRADE_ACTION_DEAL;
      request.symbol    = _Symbol;
      request.volume    = contracts;
      request.type      = ORDER_TYPE_SELL;
      request.price     = bid;
      request.sl        = sl;
      request.tp        = tp;
      request.deviation = Slippage;
      request.magic     = 77777;
 
      if(!OrderSend(request, result))
      {
         Print("OrderSend failed: ", result.retcode);
      }
      else
      {
         Print("Sell order placed successfully.");
      }
      }
 
//------
 
 
   if(buy)
     {
      double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
      double sl = ask - stoploss * _Point;
      double tp = ask + profittarget * _Point;
 
      MqlTradeRequest request;
      MqlTradeResult  result;
      ZeroMemory(request);
      ZeroMemory(result);
 
      request.action    = TRADE_ACTION_DEAL;
      request.symbol    = _Symbol;
      request.volume    = contracts;
      request.type      = ORDER_TYPE_BUY;
      request.price     = ask;
      request.sl        = sl;
      request.tp        = tp;
      request.deviation = Slippage;
      request.magic     = 123456;
 
      if(!OrderSend(request, result))
      {
         Print("OrderSend failed: ", result.retcode);
      }
      else
      {
         Print("Buy order placed successfully.");
      }
      }
 
loading all symbols, all timeframes and all current indicator signals into a single multidimensional array......

GlobalVariableGet......... h
//-------


MQL5:
 ENUM_TIMEFRAMES tf[]     = {PERIOD_M1, PERIOD_M5, PERIOD_M15, PERIOD_M30, PERIOD_H1, PERIOD_H4, PERIOD_D1};  //PERIOD_M1, PERIOD_M2, PERIOD_M3, PERIOD_M4,
 
          string tfs[14]  = {"1", "5", "15", "30", "60", "240", "1440"};   //"1","2","3","4",
 
          string sym[9]   = {"MYMM25", "MESM25", "MNQM25", "M2KM25", "MGCQ25", "SILN25", "M6EM25", "M6BM25", "M6AM25"};   
 
          string signals[10][10][10];
 
          string indi[30]  = {"alma", "hma", "coppock", "jfatl", "jjma", "ao", "tema", "dema", "trix"}; 
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   for(int i = 0; i < 5; i++)
       {
        signals[i][0][0] = sym[i];
       }
 
       Print(signals[3][0][0]);  // should be m2km25
 
 
 
   for(int j = 0; j < 6; j++)
       {
        signals[0][j][0] = tfs[j];
       } 
 
       Print(signals[0][5][0]);  // should be 240
 
 
 
   for(int k = 0; k < 8; k++)
       {
   for(int l = 0; l < 6; l++)
       {
   for(int m = 0; m < 5; m++)
       {
        signals[k][l][m] = GlobalVariableGet(sym[k]+tfs[l]+indi[m]);
       }
       }
       }
 
       Print(signals[0][0][2]);         
       Print(signals[0][1][2]);         
       Print(signals[0][2][2]);         
 
       Print(signals[0][3][2]);         
       Print(signals[0][4][2]);         
       Print(signals[0][5][2]);         
 
       Print(signals[1][0][2]);         
       Print(signals[1][1][2]);         
       Print(signals[1][2][2]);         
 
 
  }
//+------------------------------------------------------------------+
 
method for comparing various moving averages in macd histogram style.....h
//------

MQL5:
//--- shortname for sub window
   string choice = "hma vs hma";
   if(satlvsfatl)  {choice = "satl vs fatl";}
   if(demavstema)  {choice = "dema vs tema";}
   if(jjmavsjfatl) {choice = "jjma vs jfatl";}
 
   //if() {choice = "";}
 
   IndicatorSetString(INDICATOR_SHORTNAME,choice); 
 
//--- handles              true false examples
 
 
 if(hmavshma)
   {
   fast  =  iCustom(_Symbol,0,"hma",fastperiods,2.0);
   slow  =  iCustom(_Symbol,0,"hma",slowperiods,2.0);
   }
 
 if(demavstema)
   {
   fast  =  iCustom(_Symbol,0,"tema", fastperiods); 
   slow  =  iCustom(_Symbol,0,"dema", fastperiods);
   }
 
 
 if(satlvsfatl)
   {
   fast  =  iCustom(_Symbol,0,"fatl");   
   slow  =  iCustom(_Symbol,0,"satl"); 
   }
 
 if(jjmavsjfatl)
   {
   fast  =  iCustom(_Symbol,0,"jjma");   
   slow  =  iCustom(_Symbol,0,"jfatl"); 
   }


Screenshot 2025-06-07 225645.png



//----
 

Attachments

comparing fast stochastic against slower stochastic......h

//------

MQL5:
 if(stochvsstoch)
   {                             // k,d,slowing
   fast  =  iStochastic(_Symbol,0,10,3,6,MODE_SMA,STO_CLOSECLOSE);   
   slow  =  iStochastic(_Symbol,0,20,3,6,MODE_SMA,STO_CLOSECLOSE);
   }

//-----

Screenshot 2025-06-08 012236.png

//-----
 
arrows, lines and flames, on signals........h

//-----

Screenshot 2025-06-08 123027.png

//----- example target buffer is coppock crossing 0.0

MQL5:
for(int i=start; i<rates_total && !IsStopped(); i++)
    {
 
    if(vertical)
    {
    if((targetbuffer[i] > 0.0)  && (targetbuffer[i+1] < 0.0)) {vlines(i,"buy");}                                                                      
 
    if((targetbuffer[i] < 0.0)  && (targetbuffer[i+1] > 0.0)) {vlines(i,"sell");}                                                                                  
    }
 
 
    if(horizontal)
    {
    if((targetbuffer[i] > 0.0)  && (targetbuffer[i+1] < 0.0) && (i < 50)) {hlines(i,"buy");}                                                                  
 
    if((targetbuffer[i] < 0.0)  && (targetbuffer[i+1] > 0.0) && (i < 50)) {hlines(i,"sell");}                                                                              
    }
 
 
    if(arrow)
    {
    if((targetbuffer[i] > 0.0)  && (targetbuffer[i+1] < 0.0)) {arrows(i,"buy");}                                                                     
 
    if((targetbuffer[i] < 0.0)  && (targetbuffer[i+1] > 0.0)) {arrows(i,"sell");}                                                                                
    }
 
 
 
 
 
    if(flame)      // not working as intended
    {  
 
    }
 
 
 
 
 
    }  //   for(int i=start;



//--------


MQL5:
void arrows(int i, string signal)
{
 
    datetime bar    = iTime(Symbol(), 0, i); 
    double   price  = iLow(NULL,PERIOD_CURRENT,i);
    int      wings  = 241;
    string   name   = "buy";
    color    clr    = clrLime;
 
    if(signal == "sell")
      {
       price  = iHigh(NULL,PERIOD_CURRENT,i);
       wings  =  242;
       name   =  "sell";
       clr    =  clrMagenta;
      }
 
    ObjectCreate(0, "arrow"+IntegerToString(i), OBJ_ARROW, 0, bar, price);
    ObjectSetInteger(0, "arrow"+IntegerToString(i), OBJPROP_COLOR, clr);
    ObjectSetInteger(0, "arrow"+IntegerToString(i), OBJPROP_ARROWCODE, wings);
    ObjectSetInteger(0, "arrow"+IntegerToString(i), OBJPROP_WIDTH, 10);
    ObjectSetInteger(0, "arrow"+IntegerToString(i), OBJPROP_STYLE, STYLE_SOLID);
 
}
 
 
void vlines(int i, string signal)   // ObjectSetInteger(chart_ID,name,OBJPROP_RAY,ray);
{
 
    datetime bar    = iTime(Symbol(), 0, i); 
    double   price  = iLow(NULL,PERIOD_CURRENT,i);
    int      wings  = 241;
    string   name   = "vline buy";
    color    clr    = clrLime;
 
    if(signal == "sell")
      {
       price  = iHigh(NULL,PERIOD_CURRENT,i);
       wings  =  242;
       name   =  "vline sell";
       clr    =  clrMagenta;
      }
 
    ObjectCreate(0, name+IntegerToString(i), OBJ_VLINE, 0, bar, 0); 
    ObjectSetInteger(0, name+IntegerToString(i), OBJPROP_COLOR, clr);
    ObjectSetInteger(0, name+IntegerToString(i), OBJPROP_RAY, true);
    ObjectSetInteger(0, name+IntegerToString(i), OBJPROP_WIDTH, 2);
    ObjectSetInteger(0, name+IntegerToString(i), OBJPROP_STYLE, STYLE_SOLID);
 
}
 
 
 
 
void hlines(int i, string signal)   // ObjectSetInteger(chart_ID,name,OBJPROP_RAY,ray);   const bool  hidden=true,       // hidden in the object list
{
 
    datetime bar    = iTime(Symbol(), 0, i); 
    double   price  = iOpen(NULL,PERIOD_CURRENT,i);
    int      wings  = 241;
    string   name   = "hline buy";
    color    clr    = clrLime;
 
    if(signal == "sell")
      {
       price  = iOpen(NULL,PERIOD_CURRENT,i);
       wings  =  242;
       name   =  "hline sell";
       clr    =  clrMagenta;
      }
 
    ObjectCreate(0, name+IntegerToString(i), OBJ_HLINE, 0, 0, price); 
    ObjectSetInteger(0, name+IntegerToString(i), OBJPROP_COLOR, clr);
    ObjectSetInteger(0, name+IntegerToString(i), OBJPROP_RAY, true);
    ObjectSetInteger(0, name+IntegerToString(i), OBJPROP_WIDTH, 2);
    ObjectSetInteger(0, name+IntegerToString(i), OBJPROP_STYLE, STYLE_SOLID);
 
}


//Screenshot 2025-06-08 131849.png------
 
Last edited:
vertical lines only when multiple conditions agree.....h
//-------

Screenshot 2025-06-10 195536.png

//--------
MQL5:
double jjmabuffer[];
int    jjmahandle;
 
 
double jfatlbuffer[];
int    jfatlhandle;
 
 
 
double almabuffer[];
int    almahandle;
 
double hmabuffer[];
int    hmahandle;
 
 
double coppockbuffer[];
int    coppockhandle;
 
 
double spearbuffer[];
int    spearhandle;
 
 
 
double temabuffer[];
int    temahandle;
 
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
 
 
  ObjectsDeleteAll(0,-1,-1);  //  https://www.mql5.com/en/docs/objects/objectdeleteall
 
 
//--- indicator buffers mapping
 
 
   SetIndexBuffer(0,temabuffer,INDICATOR_DATA);
   ArraySetAsSeries(temabuffer,true);
 
 
   SetIndexBuffer(1,almabuffer,INDICATOR_DATA);
   ArraySetAsSeries(almabuffer,true);
 
 
 
   SetIndexBuffer(2,hmabuffer,INDICATOR_DATA);
   ArraySetAsSeries(hmabuffer,true);
 
 
 
   SetIndexBuffer(3,coppockbuffer,INDICATOR_DATA);
   ArraySetAsSeries(coppockbuffer,true);
 
 
 
   SetIndexBuffer(4,spearbuffer,INDICATOR_DATA);
   ArraySetAsSeries(spearbuffer,true);
 
 
 
   SetIndexBuffer(5,jjmabuffer,INDICATOR_DATA);
   ArraySetAsSeries(jjmabuffer,true);
 
 
 
 
 
   almahandle     = iCustom(_Symbol,0,"alma");
   coppockhandle  = iCustom(_Symbol,0,"Coppock");  //,10,14,11);
   hmahandle      = iCustom(_Symbol,0,"hma",10,2.0);
   spearhandle    = iCustom(_Symbol,0,"Spear");
   jjmahandle     = iCustom(_Symbol,0,"jjma");
   jfatlhandle    = iCustom(_Symbol,0,"jfatl");  
 
 
   //-----
 
 
int OnCalculate(const int rates_total,
 
   //-----
 
   //--- try to copy
   if(CopyBuffer(almahandle,0,0,to_copy,almabuffer)<=0) return(0);
   if(CopyBuffer(hmahandle,0,0,to_copy,hmabuffer)<=0) return(0);
   if(CopyBuffer(coppockhandle,0,0,to_copy,coppockbuffer)<=0) return(0);
   if(CopyBuffer(spearhandle,0,0,to_copy,spearbuffer)<=0) return(0);
   if(CopyBuffer(jjmahandle,0,0,to_copy,jjmabuffer)<=0) return(0);
   if(CopyBuffer(jfatlhandle,0,0,to_copy,jfatlbuffer)<=0) return(0);
 
 
//-----
 
//--- the main loop of calculations
   for(int i=start; i<rates_total && !IsStopped(); i++)
    {
 
    if(vertical)
    {
    if( ((coppockbuffer[i] > 0.0)  && (almabuffer[i] > almabuffer[i+1])  && (hmabuffer[i] > hmabuffer[i+1])  &&  (jjmabuffer[i] > jjmabuffer[i+1]) && (spearbuffer[i] > 0.0))  &&  ((coppockbuffer[i+1] < 0.0) || (almabuffer[i+1] < almabuffer[i+2])  || (hmabuffer[i+1] < hmabuffer[i+2])  || (jjmabuffer[i+1] < jjmabuffer[i+2]) || (spearbuffer[i+1] < 0.0) ))  {vlines(i,"buy");}                                                                      
 
    if( ((coppockbuffer[i] < 0.0)  && (almabuffer[i] < almabuffer[i+1])  && (hmabuffer[i] < hmabuffer[i+1])  &&  (jjmabuffer[i] < jjmabuffer[i+1]) && (spearbuffer[i] < 0.0))  &&  ((coppockbuffer[i+1] > 0.0) || (almabuffer[i+1] > almabuffer[i+2])  || (hmabuffer[i+1] > hmabuffer[i+2])  || (jjmabuffer[i+1] > jjmabuffer[i+2]) || (spearbuffer[i+1] > 0.0) ))  {vlines(i,"sell");}                                                                                  
    }
 
 
 
 
    }  //   for(int i=start;
 
horizontal lines in sub window......h
//-----

MQL5:
void hlines(double i)   
{
 
    ObjectCreate(0, "hline"+IntegerToString(i), OBJ_HLINE, ChartWindowFind(0,shortname), 0, i);                         // 1 is first subwindow  //https://www.mql5.com/en/docs/chart_operations/chartwindowfind
    ObjectSetInteger(0, "hline"+IntegerToString(i), OBJPROP_COLOR, clrYellow);
    ObjectSetInteger(0, "hline"+IntegerToString(i), OBJPROP_RAY, true);
    ObjectSetInteger(0, "hline"+IntegerToString(i), OBJPROP_WIDTH, 2);
    ObjectSetInteger(0, "hline"+IntegerToString(i), OBJPROP_STYLE, STYLE_SOLID);
 
}

//------

Screenshot 2025-06-15 170156.png
 
symbol select from any chart......

multiple symbol view.....h

//-----

MQL5:
input string symbol = "MNQM25";
 
//
 
   alma      =  iCustom(symbol,Period(),"alma");                               checkhandle(alma);      //--- create handle of the indicator alma        //--- checkhandle(alma);     if the handle is  created
 
   hma       =  iCustom(symbol,Period(),"hma",10,2.0);                         checkhandle(hma);       //--- create handle of the indicator hma         //--- checkhandle(hma);      if the handle is  created                 
 
   coppock   =  iCustom(symbol,Period(),"Coppock");                            checkhandle(coppock);   //--- create handle of the indicator coppock     //--- checkhandle(coppock);  if the handle is  created

//--------

Screenshot 2025-06-19 001857.png
 
microsoft enumeration.....

mq5 enumeration.......

enumtostring.....

enum get values microsoft......


note to me, verify spaces and encapsulated values enum list......


......h

//------

MQL5:
//input string symbol = "MYMM25";
// more common enum method better
 
 
enum symbols
   {
    Current = 0,
 
    MYMM25  = 1,
 
    MESM25  = 2,
 
    MNQM25  = 3,
 
    M2KM25  = 4
   };
 
 
input symbols SelectedSymbol;
 
 
string getSymbol()
 
{
 
   if(SelectedSymbol == Current)
 
      return _Symbol;
 
   return EnumToString(SelectedSymbol);
 
}
 
string symbol;
 
 
 
 
int OnInit()
  {
 
   symbol = getSymbol();
 
 
 
   alma      =  iCustom(symbol,Period(),"alma");                               checkhandle(alma);      //--- create handle of the indicator alma        //--- checkhandle(alma);     if the handle is  created
 
   hma       =  iCustom(symbol,Period(),"hma",10,2.0);                         checkhandle(hma);       //--- create handle of the indicator hma         //--- checkhandle(hma);      if the handle is  created                 
 
   coppock   =  iCustom(symbol,Period(),"Coppock");                            checkhandle(coppock);   //--- create handle of the indicator coppock     //--- checkhandle(coppock);  if the handle is  created

//-------

Screenshot 2025-06-19 101945.png

//-----
 
sub window text.....

need to verify during open market.....h
//-----


MQL5:
  void write(int b, int s)                                   //---  write(buy,sell);
 
    {    
    ObjectCreate(0,"count",OBJ_LABEL,1,0,0.0);
    ObjectSetInteger(0,"count",OBJPROP_CORNER,CORNER_RIGHT_UPPER);   
    ObjectSetInteger(0,"count",OBJPROP_XDISTANCE,1000);     
    ObjectSetInteger(0,"count",OBJPROP_YDISTANCE,20);     
    ObjectSetInteger(0,"count",OBJPROP_FONTSIZE,10);     
    ObjectSetInteger(0,"count",OBJPROP_COLOR,clrWhite); 
    ObjectSetString(0,"count",OBJPROP_FONT,"Verdana");   
    ObjectSetString(0,"count",OBJPROP_TEXT," buy == "+IntegerToString(b) + "  sell ==   "+IntegerToString(s));
    ObjectSetInteger(0,"count",OBJPROP_SELECTABLE,true);   
 
    }

Screenshot 2025-06-20 235634.png
 
.......h

//------

MQL5:
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[])
  {
   if(isaerror)
      return(0);
   if(rates_total <= mininumbars)
      return(0);
//---
   int bars;
 
 
  if(NewBar())   //-----
    {
 
conditional bar color.....h

//------

MQL5:
/
 
double abuffer[];
double bbuffer[];
double cbuffer[];
double dbuffer[];
double ebuffer[];
double fbuffer[];
 
//--- handles of indicators
int    ahandle;
int    bhandle;
int    chandle;
int    dhandle;
int    ehandle;
int    fhandle;
 
 
/--- get handles
 
 ahandle  =  iCustom(_Symbol,Period(),"hma",10,2.0);              // iCustom(_Symbol,Period(),"jfatl");                     
 bhandle  =  iCustom(_Symbol,Period(),"hma",20,2.0);              // iCustom(_Symbol,Period(),"jjma");                         
 chandle  =  iCustom(_Symbol,Period(),"hma",89,2.0);              // iCustom(_Symbol,Period(),"Coppock");             
 dhandle  =  iCustom(_Symbol,Period(),"hma",50,2.0);             // iCustom(_Symbol,Period(),"alma");                   
 ehandle  =  iCustom(_Symbol,Period(),"hma",100,2.0);          // iTEMA(_Symbol,Period(),20,0,PRICE_CLOSE);                             
 fhandle  =  iCustom(_Symbol,Period(),"hma",150,2.0);          // iDEMA(_Symbol,Period(),20,0,PRICE_CLOSE);                               
 
 
 
 
//------
 
 
      //--- set color for candle
      ExtColorBuffer[i] = 2.0;  // set gray Color
 
      //--- aqua
      if(abuffer[i] > abuffer[i-1] && bbuffer[i] > bbuffer[i-1] && cbuffer[i] > cbuffer[i-1] && dbuffer[i] > dbuffer[i-1] && ebuffer[i] > ebuffer[i-1] && fbuffer[i] > fbuffer[i-1])    ExtColorBuffer[i] = 0.0;
 
      //--- magenta
      if(abuffer[i] < abuffer[i-1] && bbuffer[i] < bbuffer[i-1] && cbuffer[i] < cbuffer[i-1] && dbuffer[i] < dbuffer[i-1] && ebuffer[i] < ebuffer[i-1] && fbuffer[i] < fbuffer[i-1])    ExtColorBuffer[i] = 1.0;

//-----


Screenshot 2025-06-28 075902.png

//------


Screenshot 2025-06-28 075053.png//------
 
conditional bar color.....h
//----

conditional bar color with minimum number in agreement..... majority with a minimum......

need to include a atr override veto......

possible 4th color....... h

//-----


MQL5:
input int minimum = 8;
 
//--- indicator buffers
 
int OnCalculate(const int rates_total,
 
 
 
 
      //--- aqua
      if(  ((abuffer[i] > abuffer[i-1]) + (bbuffer[i] > bbuffer[i-1]) + (cbuffer[i] > cbuffer[i-1]) + (dbuffer[i] > dbuffer[i-1]) + (ebuffer[i] > ebuffer[i-1]) + (fbuffer[i] > fbuffer[i-1]) + (gbuffer[i] > gbuffer[i-1]) + (hbuffer[i] > hbuffer[i-1]) + (ibuffer[i] > ibuffer[i-1])) >= minimum)    ExtColorBuffer[i] = 0.0;
 
      //--- magenta
      if(  ((abuffer[i] < abuffer[i-1]) + (bbuffer[i] < bbuffer[i-1]) + (cbuffer[i] < cbuffer[i-1]) + (dbuffer[i] < dbuffer[i-1]) + (ebuffer[i] < ebuffer[i-1]) + (fbuffer[i] < fbuffer[i-1]) + (gbuffer[i] < gbuffer[i-1]) + (hbuffer[i] < hbuffer[i-1]) + (ibuffer[i] < ibuffer[i-1])) >= minimum)    ExtColorBuffer[i] = 1.0;
 
Last edited:
added conditional yellow ......

in a vain attempt to avoid my favorite practice of buying the top and selling the bottom......

why is that so easy......h

//------

MQL5:
#property indicator_color1  clrGray,clrDarkBlue,clrOrchid,clrAqua,clrMagenta,clrBlue,clrRed,clrYellow
 
 
//------
 
      //--- aqua
      if(  ((abuffer[i] > abuffer[i-1]) + (bbuffer[i] > bbuffer[i-1]) + (cbuffer[i] > cbuffer[i-1]) + (dbuffer[i] > dbuffer[i-1]) + (ebuffer[i] > ebuffer[i-1]) + (fbuffer[i] > fbuffer[i-1]) + (gbuffer[i] > gbuffer[i-1]) + (hbuffer[i] > hbuffer[i-1]) + (ibuffer[i] > ibuffer[i-1]) + (jbuffer[i] > jbuffer[i-1]) + (kbuffer[i] > kbuffer[i-1]) + (lbuffer[i] > lbuffer[i-1]) + (mbuffer[i] > mbuffer[i-1]) + (nbuffer[i] > nbuffer[i-1]) + (obuffer[i] > obuffer[i-1]) + (pbuffer[i] > pbuffer[i-1]) + (qbuffer[i] > qbuffer[i-1]) + (rbuffer[i] > rbuffer[i-1]) ) >= minimum)    ExtColorBuffer[i] = 3.0;  // aqua
 
      //--- magenta
      if(  ((abuffer[i] < abuffer[i-1]) + (bbuffer[i] < bbuffer[i-1]) + (cbuffer[i] < cbuffer[i-1]) + (dbuffer[i] < dbuffer[i-1]) + (ebuffer[i] < ebuffer[i-1]) + (fbuffer[i] < fbuffer[i-1]) + (gbuffer[i] < gbuffer[i-1]) + (hbuffer[i] < hbuffer[i-1]) + (ibuffer[i] < ibuffer[i-1]) + (jbuffer[i] < jbuffer[i-1]) + (kbuffer[i] < kbuffer[i-1]) + (lbuffer[i] < lbuffer[i-1]) + (mbuffer[i] < mbuffer[i-1]) + (nbuffer[i] < nbuffer[i-1]) + (obuffer[i] < obuffer[i-1]) + (pbuffer[i] < pbuffer[i-1]) + (qbuffer[i] < qbuffer[i-1]) + (rbuffer[i] < rbuffer[i-1]) ) >= minimum)    ExtColorBuffer[i] = 4.0;  // magenta
 
 
 
      //--- blue
      if(  ((abuffer[i] > abuffer[i-1]) + (bbuffer[i] > bbuffer[i-1]) + (cbuffer[i] > cbuffer[i-1]) + (dbuffer[i] > dbuffer[i-1]) + (ebuffer[i] > ebuffer[i-1]) + (fbuffer[i] > fbuffer[i-1]) + (gbuffer[i] > gbuffer[i-1]) + (hbuffer[i] > hbuffer[i-1]) + (ibuffer[i] > ibuffer[i-1]) + (jbuffer[i] > jbuffer[i-1]) + (kbuffer[i] > kbuffer[i-1]) + (lbuffer[i] > lbuffer[i-1]) + (mbuffer[i] > mbuffer[i-1]) + (nbuffer[i] > nbuffer[i-1]) + (obuffer[i] > obuffer[i-1]) + (pbuffer[i] > pbuffer[i-1]) + (qbuffer[i] > qbuffer[i-1]) + (rbuffer[i] > rbuffer[i-1]) ) == 17)    ExtColorBuffer[i] = 5.0;  // blue
 
      //--- red
      if(  ((abuffer[i] < abuffer[i-1]) + (bbuffer[i] < bbuffer[i-1]) + (cbuffer[i] < cbuffer[i-1]) + (dbuffer[i] < dbuffer[i-1]) + (ebuffer[i] < ebuffer[i-1]) + (fbuffer[i] < fbuffer[i-1]) + (gbuffer[i] < gbuffer[i-1]) + (hbuffer[i] < hbuffer[i-1]) + (ibuffer[i] < ibuffer[i-1]) + (jbuffer[i] < jbuffer[i-1]) + (kbuffer[i] < kbuffer[i-1]) + (lbuffer[i] < lbuffer[i-1]) + (mbuffer[i] < mbuffer[i-1]) + (nbuffer[i] < nbuffer[i-1]) + (obuffer[i] < obuffer[i-1]) + (pbuffer[i] < pbuffer[i-1]) + (qbuffer[i] < qbuffer[i-1]) + (rbuffer[i] < rbuffer[i-1]) ) == 17)    ExtColorBuffer[i] = 6.0;   // red
 
 
      //--- yellow
      if(  ((abuffer[i] > abuffer[i-1]) + (bbuffer[i] > bbuffer[i-1]) + (cbuffer[i] > cbuffer[i-1]) + (dbuffer[i] > dbuffer[i-1]) + (ebuffer[i] > ebuffer[i-1]) + (fbuffer[i] > fbuffer[i-1]) + (gbuffer[i] > gbuffer[i-1]) + (hbuffer[i] > hbuffer[i-1]) + (ibuffer[i] > ibuffer[i-1]) + (jbuffer[i] > jbuffer[i-1]) + (kbuffer[i] > kbuffer[i-1]) + (lbuffer[i] > lbuffer[i-1]) + (mbuffer[i] > mbuffer[i-1]) + (nbuffer[i] > nbuffer[i-1]) + (obuffer[i] > obuffer[i-1]) + (pbuffer[i] > pbuffer[i-1]) + (qbuffer[i] > qbuffer[i-1]) + (rbuffer[i] > rbuffer[i-1]) ) == 18)    ExtColorBuffer[i] = 7.0;     //  yellow
 
      //--- yellow
      if(  ((abuffer[i] < abuffer[i-1]) + (bbuffer[i] < bbuffer[i-1]) + (cbuffer[i] < cbuffer[i-1]) + (dbuffer[i] < dbuffer[i-1]) + (ebuffer[i] < ebuffer[i-1]) + (fbuffer[i] < fbuffer[i-1]) + (gbuffer[i] < gbuffer[i-1]) + (hbuffer[i] < hbuffer[i-1]) + (ibuffer[i] < ibuffer[i-1]) + (jbuffer[i] < jbuffer[i-1]) + (kbuffer[i] < kbuffer[i-1]) + (lbuffer[i] < lbuffer[i-1]) + (mbuffer[i] < mbuffer[i-1]) + (nbuffer[i] < nbuffer[i-1]) + (obuffer[i] < obuffer[i-1]) + (pbuffer[i] < pbuffer[i-1]) + (qbuffer[i] < qbuffer[i-1]) + (rbuffer[i] < rbuffer[i-1]) ) == 18)    ExtColorBuffer[i] = 7.0;     //  yellow
Screenshot 2025-06-28 180620.png
//-----
 
need to's.......

ranking(); ..... //----- sort all results for preferred symbol

suitableperiod(); ........ //---- select period of next best available signal......

direction(); ........ //---- trade direction

probability(); ...... //----- of success

lots(); ...... // calculate lots based on above.....

ptsl(); ..... //---- profit target and stoploss in points.....

barsleft(); ...... //---- average time/bars left in current trade

......h

//---- 19 tf's

Screenshot 2025-07-11 225932.png

//------ not mtf..... 1, 5, 15, 30, 60, 240, 1440 individually

Screenshot 2025-07-11 232332.png
 
need to's.......

ptsl(); ..... //---- profit target and stoploss in points.....
//------

correction, meant dollars......

in real world real person real accounts, 1 or 2% might apply to the full account balance......

the term real might not apply to the prop firm world......

in the prop firm challenge world, $ at risk must be based on trailing drawdown and not account size...... risking 1% of a 5k trailing draw down would be 50$...... risking 5% would be 250$......

thinking maybe 4%......h

//-----

Screenshot 2025-07-13 131408.png

//-----
 

Attachments

Last edited:
note to me......

1. code a atr triangle projection indicator....... this is something i do manually.....

today is a terrible example because it is working so well.....

first place both horizontal and vertical lines on the days close....... then place rays above and below, about 1% or the daily atr...... extend out 24 hours.....

you will have a chart such as below.....

the idea is the atr is the atr for a reason...... h
//-------

View attachment 31475
Hayseed, do you actively use this ATR convention? And is this something you began using in futures as opposed to your forex trades?

Last question, are you starting this at the Forex market turnover (5pm est)?