learning mql5

manual traders are often visual traders........ so the information must be presented visual in some manner...... bar charts, candlestick, heatmaps and so on.....

when using the heat map type approach, my trouble is now i must convert the colors to the represented number......

in the simplest form, 3 colors can suffice....... lime==buy,...... red==sell....... yellow==wait........ easy for me to see....... but kinda need more than that......

if you get much beyond 6 colors, for me it becomes less clear....... matching shades of colors is not my forte.......

if using the segmented led bar graph approach, the colors are visible but also the numbers of lights....... again easy for me........

coding segmented color bars on every symbol on every timeframe to reflect the sum total of dozens of indicators is a quite task......

a cheap way out would be to use the tooltip and include the count.......

consider me cheap.....h

//-------

MQL5:
               Display(symbol+tfs[k]+"en masse",  10+(k*50), 100+(i*50));                     
               ObjectSetText(symbol+tfs[k]+"en masse", "ÛÛ",size,"Terminal", clr);
               ObjectSetString(0, symbol+tfs[k]+"en masse", OBJPROP_TOOLTIP, symbol+" en masse >< en masse "+IntegerToString(tfs[k])+" "+IntegerToString(cnt));

//------

Screenshot 2025-11-08 064815.png

//--------

Screenshot 2025-11-08 064907.png

//------

Screenshot 2025-11-08 070458.png
 
metatrader appears to only return integer values correctly up to a certain size........ not sure of that max size, it's very big,...... but at some point the values which should all be positive will be negative and incorrect...... if continuing, the numbers might be positive while still incorrect.......

to get the correct value you must change the integer to a double........ using the decimal format, double class, allows for exponential or scientific expressions......

universal formatted data to string....... ....h
//-----

MQL5:
#property script_show_inputs
 
 
input int days = 10;
 
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
 
 
 double total = 1;          // can not be   int total = 1;     
 int    i     = 0;
 
 for(i = 1;i<days;i++)
    {
 
     total += total*500;
 
 
     Print(IntegerToString(i)); 
 
     Print(total);
 
     Print(DoubleToString(total, -2));
 
     Print("");
 
    }
       Print("a   "+DoubleToString(total, -2));
 
       Print("b  "+StringFormat("%.2e", total));
 
  }
//+---------

//---------

errors in values when total is a integer......
//-----

Screenshot 2025-11-08 202216.png

//--------

correct values when total is a double......

//-------

Screenshot 2025-11-08 202146.png
 
metatrader appears to only return integer values correctly up to a certain size........ not sure of that max size, it's very big,...... but at some point the values which should all be positive will be negative and incorrect...... if continuing, the numbers might be positive while still incorrect.......

to get the correct value you must change the integer to a double........ using the decimal format, double class, allows for exponential or scientific expressions......

universal formatted data to string....... ....h
//-----

MQL5:
#property script_show_inputs
 
 
input int days = 10;
 
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
 
 
 double total = 1;          // can not be   int total = 1;    
 int    i     = 0;
 
 for(i = 1;i<days;i++)
    {
 
     total += total*500;
 
 
     Print(IntegerToString(i));
 
     Print(total);
 
     Print(DoubleToString(total, -2));
 
     Print("");
 
    }
       Print("a   "+DoubleToString(total, -2));
 
       Print("b  "+StringFormat("%.2e", total));
 
  }
//+---------

//---------

errors in values when total is a integer......
//-----

View attachment 34939

//--------

correct values when total is a double......

//-------

View attachment 34940
You can use long instead of int to avoid overflow errors but still use integer values.
 
calculating end return for various darwin boosters......h
//-----


MQL5:
#property script_show_inputs
 
 
input bool threemonths = true;
input bool sixmonths   = false;
input bool yearly      = false;
 
 
 
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
 
 double balance    =   0;           
 double cost       = 520;
 int    tf         =   3;
 int    purchases  =   1;
 
 
 if(threemonths) {cost = 520;   tf =  3;}
 if(sixmonths)   {cost = 810;   tf =  6;}
 if(yearly)      {cost = 1265;  tf = 12;}
 
 
     balance = -(cost+(tf*63));
 
     balance = balance + (tf*500);
 
 
    Print(DoubleToString(cost,0)+"$ purchase price of  "+IntegerToString(tf)+"  month 100k allocation.....   with  subscription charges of  "+DoubleToString(tf*63,0)+".......  leaves final balance of  "+  DoubleToString(balance,0)+".....   monthly profit target of 500$"); 
  }
//+--
 
not completely sure about this .......

it seems at times when i click on a button, the alert notifying i clicked on it will sound but the intended action will not fulfill.....

other times i must click on the button multiple times before even the alert will sound......

this happens more often when i have to several platforms reduced in size on a single monitor......

i will rush through clicking some button like buy ym, later to notice 1 might not have......

zorder sounds like it might help.....

added OBJPROP_ZORDER to each button........ that property was new to me......

now need to monitor to see if it clears the issue......h
//------

priority of objects......

types of chart events......


object property integer.......



MQL5:
 ObjectCreate(0,"Buy All Index",OBJ_BUTTON,0,0,0);
 
 ObjectSetInteger(0,"Buy All Index",OBJPROP_XDISTANCE,700);
 
 ObjectSetInteger(0,"Buy All Index",OBJPROP_YDISTANCE,100);
 
 ObjectSetInteger(0,"Buy All Index",OBJPROP_XSIZE,250);
 
 ObjectSetInteger(0,"Buy All Index",OBJPROP_YSIZE,40);
 
 ObjectSetInteger(0,"Buy All Index",OBJPROP_CORNER,0);
 
 ObjectSetString(0,"Buy All Index",OBJPROP_TEXT,"Buy All Index");
 
 ObjectSetInteger(0,"Buy All Index",OBJPROP_BGCOLOR,clrLime);
 
 ObjectSetInteger(0,"Buy All Index",OBJPROP_BACK,false);
 
 ObjectSetInteger(0,"Buy All Index",OBJPROP_ZORDER,0);    //-----  https://www.mql5.com/en/docs/constants/objectconstants/enum_object_property

Screenshot 2025-11-24 133741.png
 
......h
//----
MQL5:
//    if(tradexist("YM_Z",0))  {Print("YM_Z buy exists");}
//    if(tradexist("RTY_Z",0)) {Alert("RTY_Z buy exists");}
 
 
 
 bool tradexist(string sym,int typ)         //  tradexist("YM_Z",1)
  {
   bool res=false;
   uint total=PositionsTotal();
//---
   for(uint i=0; i<total; i++)
     {
      string symbol = PositionGetSymbol(i);
      int    type   =  PositionGetInteger(POSITION_TYPE);
 
      if(symbol == sym && type == typ)
        {
         res=true;
         break;
        }
     }
//---
   return(res);
  }
 
uses tradeexist() function above to alert if new trade will be opposing existing trade, in other words a hedge..... ok or cancel will give the option to proceed or not.....

sometimes i click buy when i meant to click sell.....

if my true intention was to hedge, clicking ok should allow hedge trade.....

usually it is not.....h
//-------

MQL5:
    //  need to include counter trend alert.....   
 
    if(sparam == "Buy YM")
    {
 
    string text= " all clear";
 
    if(tradexist("YM_Z",1)) {text = " warning sells exist";}  // idea is to verify hedge....
 
    int BuyYM = MessageBox("Buy YM"+text,"0",MB_OKCANCEL);   
 
    if(BuyYM != IDOK) return;
 
 
 
    Alert(sparam+ " was pressed  "+ AccountInfoString(ACCOUNT_NAME));
 
    trade.Buy(contracts,"YM_Z",0,0,0,NULL);
 
    }
 
most scripts take seconds to run...... like in the blink of an eye.....

some of mine take much longer....... it's the math they are doing..... so long in fact i often wonder if their through........ do i have time to take a nap......

just noticed, in the top right there is a orange symbol with the scripts name..... it remains until the script is done......

guess someone at metaquotes got tired of wondering the same thing......h
//--------


Screenshot 2025-12-06 010220.png
 
new monitors resolution forced me to recode the buttons...... text size was far to small.......

all this time somehow i overlooked OBJPROP_FONTSIZE.......

no more squinting......h

//------

MQL5:
 //------  https://www.mql5.com/en/docs/constants/objectconstants/enum_object_property
 
 ObjectCreate(0,"Sell All Currency",OBJ_BUTTON,0,0,0);
 
 ObjectSetInteger(0,"Sell All Currency",OBJPROP_XDISTANCE,1300);
 
 ObjectSetInteger(0,"Sell All Currency",OBJPROP_YDISTANCE,200);
 
 ObjectSetInteger(0,"Sell All Currency",OBJPROP_XSIZE,250);
 
 ObjectSetInteger(0,"Sell All Currency",OBJPROP_YSIZE,40);
 
 ObjectSetInteger(0,"Sell All Currency",OBJPROP_CORNER,0);
 
 ObjectSetInteger(0,"Sell All Currency",OBJPROP_FONTSIZE,14);   //  https://www.mql5.com/en/docs/constants/objectconstants/enum_object_property
 
 ObjectSetString(0,"Sell All Currency",OBJPROP_TEXT,"Sell All Currency");
 
 ObjectSetInteger(0,"Sell All Currency",OBJPROP_BGCOLOR,clrViolet); 
 
 ObjectSetInteger(0,"Sell All Currency",OBJPROP_BACK,false);
 
 ObjectSetInteger(0,"Sell All Currency",OBJPROP_ZORDER,0);   
 
 
 
 
//---
 
MODE_HIGH and PRICE_HIGH are not interchangeable even though both use the high........

learnt that the hard way......h

//------

MQL5:
    for(int j = 0; j < 8; j++)
      { 
 
      high34[j] = iMA(symbol,tf[j],34,0,MODE_EMA,PRICE_HIGH);       
      low34[j]  = iMA(symbol,tf[j],34,0,MODE_EMA,PRICE_LOW);       
      clos[j]   = iMA(symbol,tf[j],1,0,MODE_EMA,PRICE_CLOSE);       
 
      bars        = iBars(symbol,tf[j]);
 
      }  //-----    for(int j = 0; j < 7; j++)

//----

Screenshot 2026-01-11 231516.png

//------

Screenshot 2026-01-11 231924.png
 
linda raschke said she likes to look everyday for what to trade...... that changes......


in the picture above, 6e_h is last.....

this is because in the symbolist it's last......... SymbolName(i,true);
sometimes it's nice to arrange the list to your liking...... even if it's a temporary liking.....

if your trading oil, maybe you want the oils at the top...... or maybe gold at the top..... silver.......

a trend trader might want those symbols that are trending at the top....... a momentum trader might want,,,,,,, on and on.......

this way your not scratchin through a stirred up list in a hurry and only to choose the wrong symbol......

to reorder SymbolName(i,true); , go to the market watch..... click and hold on a symbol then drag it to where you want in the list.....

i imagine linda does something similar..... the top of the her list is what she is trading......

linda raschke.........h

//------

Screenshot 2026-01-12 093847.png

//------

Screenshot 2026-01-12 093925.png
 
3 dimensional array..... [symbol][timeframe][indicator].......

int signals[20][20][20];

might allow for pin pointing timing of entries......h
//------

MQL5:
        double jjmas[];                                          
 
        ArraySetAsSeries(jjmas,true);   
 
        CopyBuffer(jjma[k],0,0,4,jjmas);
 
 
        double stochs[];
 
        ArraySetAsSeries(stochs,true);   
 
        CopyBuffer(stoch[k],0,0,4,stochs);
 
 
//------    int   signals[20][20][20];
 
 
 
            if(almas[0]  > almas[1])                             {signals[i][k][0] = 0;} 
 
            if(almas[0]  < almas[1])                             {signals[i][k][0] = 1;} 
 
            if(hmas[0]   > hmas[1])                              {signals[i][k][1] = 0;} 
 
            if(hmas[0]   < hmas[1])                              {signals[i][k][1] = 1;} 
 
            if(jfatls[0] > jfatls[1])                            {signals[i][k][2] = 0;} 
 
            if(jfatls[0] < jfatls[1])                            {signals[i][k][2] = 1;} 
 
            if(jjmas[0]  > jjmas[1])                             {signals[i][k][3] = 0;} 
 
            if(jjmas[0]  < jjmas[1])                             {signals[i][k][3] = 1;} 
 
 
        }  //-----  for(int k = 0; k < 7; k++)
//----
 
             for(int n = 0; n < 7; n++)
             {
             if( (signals[i][n][0] == 0) && (signals[i][n][1] == 0) && (signals[i][n][2] == 0) ) {Alert("Buy "+ tfs[n]+ "  "+   symbol);}           
 
             if( (signals[i][n][0] == 1) && (signals[i][n][1] == 1) && (signals[i][n][2] == 1) ) {Alert("Sell "+ tfs[n]+ "  "+  symbol);}             
             }
 
 
       }   //-----      for(int i = 0; i < total; i++)
 
might allow for pin pointing timing of entries......h
//------

[/CODE]
//------

as an example, suppose gold was under a buy alert on multiple higher timeframes and the 1 minute stochastic fell below 5 ......

the idea would be to look for higher timeframe agreements with an extreme opposing stochastic signal on the 1 minute chart......

the 3 dimensional array mentioned above would allow for specific conditions......

taking only the best of the best might increase our odds......h

//-------

MQL5:
             for(int n = 0; n < 8; n++)
 
 
             {
             if( (signals[i][n][0] == 0) && (signals[i][n][1] == 0) && (signals[i][n][2] == 0) && (signals[i][n][3] == 0) && (signals[i][0][4] <  5.00) ) {Alert("Buy "+ tfs[n]+ "  "+   symbol+ "  "+DoubleToString(signals[i][0][4],2));}          
 
             if( (signals[i][n][0] == 1) && (signals[i][n][1] == 1) && (signals[i][n][2] == 1) && (signals[i][n][3] == 1) && (signals[i][0][4] > 95.00) ) {Alert("Sell "+ tfs[n]+ "  "+  symbol+ "  "+DoubleToString(signals[i][0][4],2));}            
             }

//------

Screenshot 2026-01-13 224056.png


Screenshot 2026-01-13 223316.png


Screenshot 2026-01-13 222501.png
 
Last edited:
  • 👍
Reactions: Enivid
turtles..... richard dennis system......

1 minute thru week timeframes......

aqua breaking above 20 bar high..... blue breaking above 55 bar high....

magenta breaking below 20 bar low...... red breaking below 55 bar low......

work in progress.......

will post full code after a little verification.....h

//------
Screenshot 2026-01-22 202713.png

MQL5:
//------
//------
 
 
  bool brokehigh(string symbol, int t, int bars)
          {
           ENUM_TIMEFRAMES tf[]   = {PERIOD_M1, PERIOD_M5, PERIOD_M15, PERIOD_M30, PERIOD_H1, PERIOD_H4, PERIOD_D1, PERIOD_W1};  //PERIOD_M1, PERIOD_M2, PERIOD_M3, PERIOD_M4,
 
 
           int    shift = 0;
           double his[];
 
 
           ArraySetAsSeries(his,true);
 
           CopyHigh(symbol,tf[t],1,bars,his);
 
           shift = ArrayMaximum(his,0,bars);
 
 
 
           if(iHigh(symbol,tf[t],0) > his[shift])  return(true);    
                                                   return(false);
          }
 
//------
//------
 
 
  bool brokelow(string symbol, int t, int bars)
          {
           ENUM_TIMEFRAMES tf[]   = {PERIOD_M1, PERIOD_M5, PERIOD_M15, PERIOD_M30, PERIOD_H1, PERIOD_H4, PERIOD_D1, PERIOD_W1};  //PERIOD_M1, PERIOD_M2, PERIOD_M3, PERIOD_M4,
 
 
           int    shift = 0;
           double los[];
 
 
           ArraySetAsSeries(los,true);
 
           CopyLow(symbol,tf[t],1,bars, los); 
 
           shift = ArrayMinimum(los,0,bars);
 
           if(iLow(symbol,tf[t],0) < los[shift]) return(true);    
                                                 return(false);
          }

//------
Post automatically merged:

.....h

//------

MQL5:
    for(int k = 0; k < 8; k++)
      { 
 
 
 
 
//------
            color clr   = clrYellow;
 
            int   size  = 10;
 
 
            if(brokehigh(symbol,k, 20))     { clr = clrAqua;      }                                                               
            if(brokelow(symbol,k, 20))      { clr = clrMagenta;   }                                                               
 
            if(brokehigh(symbol,k, 55))     { clr = clrBlue;      }                                                               
            if(brokelow(symbol,k, 55))      { clr = clrRed;       }                                                               
 
 
//-----           
 
               Display(symbol+tfs[k]+" turtle ",  horizontal+(k*45), cvertical+(i*45));                               
               ObjectSetText(symbol+tfs[k]+" turtle ", "ÛÛ",size,"Terminal", clr);
               ObjectSetString(0, symbol+tfs[k]+" turtle ", OBJPROP_TOOLTIP, symbol+"  "+IntegerToString(tfs[k])+" turtle");                               
 
 
        }  //-----  for(int k = 0; k < 7; k++)
//----
 
       }   //-----      for(int i = 0; i < total; i++)
 
 
       }  //------        if(NewBar() || weekend)
 
 
 
  return rates_total;
}
 

Attachments

terminalinfointerger........h


//------

MQL5:
 int  build = TerminalInfoInteger(TERMINAL_BUILD);
 bool x64   = TerminalInfoInteger(TERMINAL_X64);
 
 
 ObjectCreate(0,"Build",OBJ_BUTTON,0,0,0);
 
 ObjectSetInteger(0,"Build",OBJPROP_XDISTANCE,10);
 
 ObjectSetInteger(0,"Build",OBJPROP_YDISTANCE,750);
 
 ObjectSetInteger(0,"Build",OBJPROP_XSIZE,250);
 
 ObjectSetInteger(0,"Build",OBJPROP_YSIZE,40);
 
 ObjectSetInteger(0,"Build",OBJPROP_CORNER,0);
 
 ObjectSetString(0,"Build",OBJPROP_TEXT, "platform build  "+build);
 
 ObjectSetInteger(0,"Build",OBJPROP_BGCOLOR,clrAqua); 
 
 ObjectSetInteger(0,"Build",OBJPROP_BACK,false);

//-----

MQL5:
 /*
 int m   = TerminalInfoInteger(TERMINAL_MEMORY_USED);
 
 int n  = TerminalInfoInteger(TERMINAL_MEMORY_AVAILABLE);
 
 int o = TerminalInfoInteger(TERMINAL_MEMORY_TOTAL);
 
 int p = TerminalInfoInteger(TERMINAL_DISK_SPACE);
 
 int q = TerminalInfoInteger(TERMINAL_MEMORY_PHYSICAL);
 
 
//--- get the build number of the running terminal and its "64-bit terminal" property
   int  build = TerminalInfoInteger(TERMINAL_BUILD);
   bool x64   = TerminalInfoInteger(TERMINAL_X64);
 
//--- print the obtained terminal data in the journal
   PrintFormat("MetaTrader 5 %s build %d", (x64 ? "x64" : "x32"), build);
   /*
   result:
   MetaTrader 5 x64 build 4330
 
  }
 
 Print("used "+IntegerToString(m)+" , available "+IntegerToString(n)+" , total "+IntegerToString(o)+"   , disk space "+IntegerToString(p)+" , memory physcal "+IntegerToString(q));
 
 
 
   Print("TERMINAL_PATH = ",TerminalInfoString(TERMINAL_PATH));
   Print("TERMINAL_DATA_PATH = ",TerminalInfoString(TERMINAL_DATA_PATH));
   Print("TERMINAL_COMMONDATA_PATH = ",TerminalInfoString(TERMINAL_COMMONDATA_PATH));
 */


Screenshot 2026-02-01 085513.png
 
the idea would be to look for higher timeframe agreements with an extreme opposing stochastic signal on the 1 minute chart......

the 3 dimensional array mentioned above would allow for specific conditions......
//------

.....h
//---

MQL5:
            if( (signals[i][2][13] && signals[i][3][13] && signals[i][4][13] && signals[i][5][13] && signals[i][6][13]) && ((signals[i][0][15]) || (signals[i][1][15]) || (signals[i][2][15]) || (!signals[i][0][0]) || (!signals[i][0][4]) || (!signals[i][0][5]) || (!signals[i][0][6]) || (!signals[i][0][7]) ) )              {Alert(symbol+" reversal guassin buy ");}
 
            if( (signals[i][2][14] && signals[i][3][14] && signals[i][4][14] && signals[i][5][14] && signals[i][6][14]) && ((signals[i][0][16]) || (signals[i][1][16]) || (signals[i][2][16]) || ( signals[i][0][0]) || ( signals[i][0][4]) || ( signals[i][0][5]) || ( signals[i][0][6]) || ( signals[i][0][7]) ) )              {Alert(symbol+" reversal guassin sell ");}
            }
 
//-----   darwin array 2 3 2026.mq5 emailed.....  no alerts yet..... might be too restrictive.....
 
 
       }  //------        if(NewBar() || weekend)
 
 
  return rates_total;
}
 
uses tradeexist() function above to alert if new trade will be opposing existing trade, in other words a hedge..... ok or cancel will give the option to proceed or not.....

sometimes i click buy when i meant to click sell.....


MQL5:
    //  need to include counter trend alert.....  
 
    if(sparam == "Buy YM")
    {
 
    string text= " all clear";
//-----

and sometimes need to be made aware of which account i'm placing the trade in........ as is, have to click ok first...... not good......

added AccountInfoString(ACCOUNT_NAME) at the outset so i know in advance......

still need to add countertrend notification......h

//------

MQL5:
    if(sparam == "Buy ZL_H")
    {
 
    string text= " all clear  "+ AccountInfoString(ACCOUNT_NAME); //   gives me the account name in the yes/no prompt box
 
    if(tradexist("ZL_H",1)) {text = " warning sells exist";}  // idea is to verify hedge....
 
    int BuyZL_H = MessageBox("Buy ZL_H"+text,"0",MB_OKCANCEL);   
 
    if(BuyZL_H != IDOK) return;
 
 
 
    Alert(sparam+ " was pressed  "+ AccountInfoString(ACCOUNT_NAME));
 
    trade.Buy(contracts,"ZL_H",0,0,0,NULL);
 
    }

//-------

Screenshot 2026-02-10 102510.png