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));



#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)); } //+---------


You can usemetatrader 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
long instead of int to avoid overflow errors but still use integer values.//-----You can uselonginstead ofintto avoid overflow errors but still use integer values.
#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$"); } //+--
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

if(sparam == "Buy YM") { int BuyYM = MessageBox("Buy YM","0",MB_OKCANCEL); //---https://www.mql5.com/en/docs/common/messagebox if(BuyYM != IDOK) return; Alert(sparam+ " was pressed "+ AccountInfoString(ACCOUNT_NAME)); trade.Buy(contracts,"YM_Z",0,0,0,NULL); }
// 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); }
// 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); }

//------ 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); //---




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]
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));} }




//------ //------ 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); }
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; }
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);
/*
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));
*/

//------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......
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";
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); }
