PositionSizer icon indicating copy to clipboard operation
PositionSizer copied to clipboard

PSC getting removed from the chart by itself ,mt5

Open paymanz opened this issue 11 months ago • 19 comments

PSC keeps getting removed for no apparent reason , every 1 hour or so... i attached screenshot of expert tab showing some error. can you please help? thanks build number is 4778

Image

paymanz avatar Mar 03 '25 19:03 paymanz

What are messages before those? Because those are post-crash messages, they don't tell much about why the EA crashed...

EarnForex avatar Mar 03 '25 21:03 EarnForex

What are messages before those? Because those are post-crash messages, they don't tell much about why the EA crashed...

nothing from PSC , attached another screenshot:

Image

paymanz avatar Mar 05 '25 06:03 paymanz

Unfortunately, it's impossible to tell what causes this. It doesn't provide any info on the cause of the crash. My best guess currently is that it is somehow connected with some quirk of the build 4778. Would it be possible for you to try and downgrade it to 4755 to see if this helps?

EarnForex avatar Mar 05 '25 08:03 EarnForex

Unfortunately, it's impossible to tell what causes this. It doesn't provide any info on the cause of the crash. My best guess currently is that it is somehow connected with some quirk of the build 4778. Would it be possible for you to try and downgrade it to 4755 to see if this helps?

i had the same issue long time ago , maybe it has something to do with the settings i use?! because i customize everything and apparently this issue only happening to me. the issue i opened previously: https://github.com/EarnForex/PositionSizer/issues/58 here is my settings if you think it can help find the reason: https://www.sendspace.com/file/bcjqyh

paymanz avatar Mar 05 '25 09:03 paymanz

That previous issue seems to be a little different. Anyway, I will run the EA with your settings and see if I can reproduce this on 4755.

By the way, are you using any indicators on the same chart?

EarnForex avatar Mar 05 '25 11:03 EarnForex

That previous issue seems to be a little different. Anyway, I will run the EA with your settings and see if I can reproduce this on 4755.

By the way, are you using any indicators on the same chart?

thanks! yes i do have multiple indicators on the chart , candle timer , pip show and stuff like that. please let me know if you want to look into them , i can upload them.

Image

paymanz avatar Mar 05 '25 15:03 paymanz

Did you try loading the Position Sizer on a separate chart with no other indicator and checking if it also fails the same way?

EarnForex avatar Mar 05 '25 16:03 EarnForex

Did you try loading the Position Sizer on a separate chart with no other indicator and checking if it also fails the same way?

no , didn't know it can cause that , i will try. btw i had other EAs and indicators didn't cause this issue with them....

paymanz avatar Mar 05 '25 16:03 paymanz

Did you try loading the Position Sizer on a separate chart with no other indicator and checking if it also fails the same way?

no , didn't know it can cause that , i will try. btw i had other EAs and indicators didn't cause this issue with them....

That shouldn't be the case (other indicators causing an issue with the PS), but that could be result of some quirk either with the PS's code or of the MT5 build.

EarnForex avatar Mar 05 '25 17:03 EarnForex

its the session event mark indicator that causes the problem. but it doesnt happen with other EAs. i post the code maybe you can kindly suggest which part of the code can cause this issue? https://www.sendspace.com/file/wwmawc `//+------------------------------------------------------------------+ //| Vertical Time Lines.mq4 | //| Copyright 2014, MetaQuotes Software Corp. | //| http://www.mql5.com //| //| Author: File45 //+------------------------------------------------------------------+ #property copyright "Copyright 2014, MetaQuotes Software Corp." #property link "http://www.mql5.com" #property version "1.00" #property strict #property indicator_chart_window #property indicator_plots 0

/*enum LW { One = 1, Two = 2, Three = 3, Four = 4, Five = 5, }; */

// DEFAULT INPUTS : START //----------------------------------------------------- input bool Indicator_ON = true;//indicator ON? input int Historical_Days = 10; // Historical days input int LabelsOffset = 30;//Offset time(local vs server time) in minutes(+/-) input string Event_1_Dscr = "Pre London 09:30"; // Event 1 Description
input bool Event_1_Visible = false; // Event 1 Visible input string Event_1_Time = "09:30"; // Event 1 Time //input LW Line_1_Width = One; // Event 1 Width //input ENUM_LINE_STYLE Line_1_Style = STYLE_DASHDOTDOT; // Event 1 Style input color Event_1_Color = clrPowderBlue; // Event 1 Color

input string Event_2_Dscr = "London Open 11:30"; // Event 2 Description input bool Event_2_Visible = true; // Event 2 Visible input string Event_2_Time = "11:30"; // Event 2 Time //input LW Line_2_Width = One; // Event 2 Width //input ENUM_LINE_STYLE Line_2_Style = STYLE_DASHDOTDOT; // Event 2 Style input color Event_2_Color = clrDodgerBlue; // Event 2 Color

input string Event_3_Dscr = "No Trade time 13:00"; // Event 3 Description input bool Event_3_Visible = false; // Event 3 Visible input string Event_3_Time = "13:00"; // Event 3 Time //input LW Line_3_Width = One; // Event 3 Width //input ENUM_LINE_STYLE Line_3_Style = STYLE_DOT; // Event 3 Style input color Event_3_Color = clrBlack; // Event 3 Color

input string Event_4_Dscr = "Pre NY 14:00"; // Event 4 Description input bool Event_4_Visible = false; // Event 4 Visible input string Event_4_Time = "14:00"; // Event 4 Time //input LW Line_4_Width = One; // Event 4 Width //input ENUM_LINE_STYLE Line_4_Style = STYLE_DOT; // Event 4 Style input color Event_4_Color = clrSandyBrown; // Event 4 Color

input string Event_5_Dscr = "NY Open 15:30"; // Event 5 Description input bool Event_5_Visible = false; // Event 5 Visible input string Event_5_Time = "15:30"; // Event 5 Time //input LW Line_5_Width = One; // Event 5 Width //input ENUM_LINE_STYLE Line_5_Style = STYLE_DOT; // Event 5 Style input color Event_5_Color = clrFireBrick; // Event 5 Color

input string Event_6_Dscr = "Usuall news release 16:00"; // Event 6 Description input bool Event_6_Visible = false; // Event 6 Visible input string Event_6_Time = "16:00"; // Event 6 Time //input LW Line_6_Width = One; // Event 6 Width //input ENUM_LINE_STYLE Line_6_Style = STYLE_DOT; // Event 6 Style
input color Event_6_Color = clrMaroon; // Event 6 Color

input string Event_7_Dscr = "Pre NYSE(30m before)"; // Event 7 Description input bool Event_7_Visible = true; // Event 7 Visible input string Event_7_Time = "16:30"; // Event 7 Time //input LW Line_7_Width = One; // Event 7 Width //input ENUM_LINE_STYLE Line_7_Style = STYLE_DOT; // Event 7 Style
input color Event_7_Color = clrPowderBlue; // Event 7 Color

input string Event_8_Dscr = "NYSE 17:00"; // Event 8 Description input bool Event_8_Visible = true; // Event 8 Visible input string Event_8_Time = "17:00"; // Event 8 Time //input LW Line_7_Width = One; // Event 8 Width //input ENUM_LINE_STYLE Line_7_Style = STYLE_DOT; // Event 8 Style
input color Event_8_Color = clrRoyalBlue; // Event 8 Color

input string Event_9_Dscr = "15-30m after the News release post NYSE(15-30m post NYSE)"; // Event 9 Description input bool Event_9_Visible = true; // Event 9 Visible input string Event_9_Time = "17:30"; // Event 9 Time //input LW Line_7_Width = One; // Event 9 Width //input ENUM_LINE_STYLE Line_7_Style = STYLE_DOT; // Event 9 Style
input color Event_9_Color = clrTurquoise; // Event 9 Color

input string Event_10_Dscr = "London Close 20:30"; // Event 10 Description input bool Event_10_Visible = true; // Event 10 Visible input string Event_10_Time = "20:30"; // Event 10 Time //input LW Line_7_Width = One; // Event 10 Width //input ENUM_LINE_STYLE Line_7_Style = STYLE_DOT; // Event 10 Style
input color Event_10_Color = clrDarkGray; // Event 10 Color //----------------------------------------------------- // DEFAULT INPUTS : END

string T1_End = "Time_Line_1"; string T2_End = "Time_Line_2"; string T3_End = "Time_Line_3";
string T4_End = "Time_Line_4"; string T5_End = "Time_Line_5";
string T6_End = "Time_Line_6";
string T7_End = "Time_Line_7";
string T8_End = "Time_Line_8"; string T9_End = "Time_Line_9"; string T10_End = "Time_Line_10"; string T1=Event_1_Dscr; string T2=Event_2_Dscr; string T3=Event_3_Dscr; string T4=Event_4_Dscr; string T5=Event_5_Dscr; string T6=Event_6_Dscr; string T7=Event_7_Dscr; string T8=Event_8_Dscr; string T9=Event_9_Dscr; string T10=Event_10_Dscr; void OnInit() { DeleteObjects(); for (int i=0; i<Historical_Days; i++) { CreateObjects(T1+ IntegerToString(i),Event_1_Color,0,0,Event_1_Dscr); CreateObjects(T2+IntegerToString(i), Event_2_Color, 0, 0,Event_2_Dscr); CreateObjects(T3+IntegerToString(i), Event_3_Color, 0, 0,Event_3_Dscr); CreateObjects(T4+IntegerToString(i), Event_4_Color, 0, 0,Event_4_Dscr); CreateObjects(T5+IntegerToString(i), Event_5_Color, 0, 0,Event_5_Dscr); CreateObjects(T6+IntegerToString(i), Event_6_Color,0, 0,Event_6_Dscr); CreateObjects(T7+IntegerToString(i), Event_7_Color,0, 0,Event_7_Dscr); CreateObjects(T8+IntegerToString(i), Event_8_Color,0, 0,Event_8_Dscr); CreateObjects(T9+IntegerToString(i), Event_9_Color,0, 0,Event_9_Dscr); CreateObjects(T10+IntegerToString(i), Event_10_Color,0, 0,Event_10_Dscr); } }

void OnDeinit(const int reason) { DeleteObjects(); }

void CreateObjects(string no, color cl, ENUM_LINE_STYLE st, int w, string dscr) { ObjectCreate(0, no, OBJ_EVENT,0,0,0,0,0); //ObjectSetInteger(0, no, OBJPROP_WIDTH, w); // ObjectSetInteger(0, no, OBJPROP_STYLE, st); ObjectSetInteger(0, no, OBJPROP_COLOR, cl); ObjectSetInteger(0, no, OBJPROP_BACK, true); ObjectSetString(0, no, OBJPROP_TEXT, dscr); }

void DeleteObjects() { for (int i=0; i<Historical_Days; i++) { ObjectDelete(0,T1+IntegerToString(i)); ObjectDelete(0,T2+IntegerToString(i)); ObjectDelete(0,T3+IntegerToString(i)); ObjectDelete(0,T4+IntegerToString(i)); ObjectDelete(0,T5+IntegerToString(i)); ObjectDelete(0,T6+IntegerToString(i)); ObjectDelete(0,T7+IntegerToString(i)); ObjectDelete(0,T8+IntegerToString(i)); ObjectDelete(0,T9+IntegerToString(i)); ObjectDelete(0,T10+IntegerToString(i)); } }

void DrawObjects(datetime dt, string no, string tb, string te) { datetime t1, t2; double p1, p2; int b1, b2;

t1=StringToTime(TimeToString(dt, TIME_DATE)+" "+tb); t2=StringToTime(TimeToString(dt, TIME_DATE)+" "+te); b1=iBarShift(_Symbol, PERIOD_CURRENT, t1); b2=iBarShift(_Symbol, PERIOD_CURRENT, t2); p1=iHigh( _Symbol, PERIOD_CURRENT, iHighest(_Symbol, PERIOD_CURRENT, MODE_HIGH, b1-b2, b2) ); p2=iLow(_Symbol, PERIOD_CURRENT, iLowest (_Symbol, PERIOD_CURRENT, MODE_LOW , b1-b2, b2) ); ObjectSetInteger(0, no, OBJPROP_TIME, 0 , t1+PeriodSeconds(PERIOD_M1)-LabelsOffset);//ObjectSetInteger(0, no, OBJPROP_TIME, 0 , t1); ObjectSetInteger(0, no, OBJPROP_TIME, 1 , t2+PeriodSeconds(PERIOD_M1)-LabelsOffset);//ObjectSetInteger(0, no, OBJPROP_TIME, 0 , t2); ObjectSetDouble(0, no, OBJPROP_PRICE, 0, p1); ObjectSetDouble(0, no, OBJPROP_PRICE, 1, p2); }

datetime decDateTradeDay (datetime dt) { MqlDateTime tm; TimeToStruct(dt,tm);

/* int ty=TimeYear(dt); int tm=TimeMonth(dt); int td=TimeDay(dt); int th=TimeHour(dt); int ti=TimeMinute(dt); */

tm.day--; if (tm.day==0) { tm.mon--; if (tm.mon==0) { tm.year--; tm.mon=12; } if (tm.mon==1 || tm.mon==3 || tm.mon==5 || tm.mon==7 || tm.mon==8 || tm.mon==10 || tm.mon==12) tm.day=31; if (tm.mon==2) if (MathMod(tm.year, 4)==0) tm.day=29; else tm.day=28; if (tm.mon==4 || tm.mon==6 || tm.mon==9 || tm.mon==11) tm.day=30; } //return(StringToTime(IntegerToString(ty)+"."+IntegerToString(tm)+"."+IntegerToString(td)+" "+IntegerToString(th)+":"+IntegerToString(ti))); return( StructToTime(tm) ); }

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[]) { MqlDateTime tm; datetime dt=TimeCurrent(); //CurTime(); if(Period()<PERIOD_D1) for (int i=0; i<Historical_Days; i++) { if(Indicator_ON==false) { break; } if(Event_1_Visible == true) { DrawObjects(dt, T1+IntegerToString(i), Event_1_Time, T1_End); } if(Event_2_Visible == true) { DrawObjects(dt, T2+IntegerToString(i), Event_2_Time, T2_End); } if(Event_3_Visible == true) { DrawObjects(dt, T3+IntegerToString(i), Event_3_Time, T3_End); } if(Event_4_Visible == true) { DrawObjects(dt, T4+IntegerToString(i), Event_4_Time, T4_End); } if(Event_5_Visible == true) { DrawObjects(dt, T5+IntegerToString(i), Event_5_Time, T5_End); } if(Event_6_Visible == true) { DrawObjects(dt, T6+IntegerToString(i), Event_6_Time, T6_End); } if(Event_7_Visible == true) { DrawObjects(dt, T7+IntegerToString(i), Event_7_Time, T7_End); } if(Event_8_Visible == true) { DrawObjects(dt, T8+IntegerToString(i), Event_8_Time, T8_End); } if(Event_9_Visible == true) { DrawObjects(dt, T9+IntegerToString(i), Event_9_Time, T9_End); } if(Event_9_Visible == true) { DrawObjects(dt, T10+IntegerToString(i), Event_10_Time, T10_End); } do { dt=decDateTradeDay(dt); TimeToStruct(dt,tm); } while( tm.day_of_week>5 );

}

return(rates_total); }`

paymanz avatar Oct 13 '25 07:10 paymanz

@paymanz Did you find the reason of its conflict with the Position Sizer? Because I ran that indicator for 3 days straight together with PS and switched chart timeframes regularly but not even once PS crashed with it. Perhaps, it's some other indicator that does that?

aamoraru avatar Oct 17 '25 18:10 aamoraru

@paymanz Did you find the reason of its conflict with the Position Sizer? Because I ran that indicator for 3 days straight together with PS and switched chart timeframes regularly but not even once PS crashed with it. Perhaps, it's some other indicator that does that?

Thanks, I'm pretty sure it's that indicator because I haven't had that issue since i removed it. Other indicators are still on the chart without problem.

paymanz avatar Oct 17 '25 19:10 paymanz

OK. It's probably some combination of the system specification and this indicator that causes this.

aamoraru avatar Oct 17 '25 19:10 aamoraru

OK. It's probably some combination of the system specification and this indicator that causes this.

Like windows settings or hardware specifications? My PC is overall a normal machine, i don't know.

paymanz avatar Oct 17 '25 19:10 paymanz

If I only knew! It could be a CPU or some Windows setting or some software installed.

aamoraru avatar Oct 18 '25 17:10 aamoraru

If I only knew! It could be a CPU or some Windows setting or some software installed.

can you please try the indicator with input parameter of "historical days=100" , i think it reproduces the issue

paymanz avatar Oct 24 '25 16:10 paymanz

Yes, I've been able to reproduce this with that input parameter setting. I will look into this in more detail now.

aamoraru avatar Oct 24 '25 16:10 aamoraru

Please try to comment out the DeleteObjects(); line inside the OnInit() function of your Vertical Lines indicator. Re-compile and let me know if it helps with the issue (it seems to have helped in my case).

aamoraru avatar Oct 24 '25 17:10 aamoraru

Please try to comment out the DeleteObjects(); line inside the OnInit() function of your Vertical Lines indicator. Re-compile and let me know if it helps with the issue (it seems to have helped in my case).

removed that line but the problem persists.

paymanz avatar Oct 24 '25 18:10 paymanz