I managed to create a quick prototype.
I would have loved if the bool input interface was a checkbox instead of a pulldown for true/false.
I couldnt find the native ENUM so I created a custom one.
I prolly didnt need to use OnCalculate, but im still a bit lost on MT4
Any observations / comments are welcome.
// This script will run on all objects of the chart. // Very slow to run on calculate per ticks. enum ENUM_TF{ M1=OBJ_PERIOD_M1, M5=OBJ_PERIOD_M5, M15=OBJ_PERIOD_M15, M30=OBJ_PERIOD_M30, H1=OBJ_PERIOD_H1, H4=OBJ_PERIOD_H4, D1=OBJ_PERIOD_D1, W1=OBJ_PERIOD_W1, MN=OBJ_PERIOD_MN1 }; input ENUM_TF InpHideTF=M1; input bool InpHideSellLoss=0; input bool InpHideSellWin =0; input bool InpHideBuyLoss =0; input bool InpHideBuyWin =0; int count; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void OnInit(){ } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ 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[]) { Process(); return rates_total; } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void Process(){ for( int i = ObjectsTotal() - 1 ; i >=0 ; i = i - 5){ int orderid, a; double priceopen, priceclose, tp, sl; string split[], type; string name = ObjectName( i ); //Print( name ); // // GET ORDER ID a = StringSplit( name, StringGetCharacter(" ",0) , split); StringReplace( split[0], "#","" ); orderid = int(split[0]); // // GET PROFIT tp = double( split[ ArraySize(split) - 1 ] ); // // GET TYPE type = split[ 1 ]; // // GET LOSS name = ObjectName( i - 1 ); a = StringSplit( name, StringGetCharacter(" ",0) , split); sl = double( split[ ArraySize(split) - 1 ] ); // // GET CLOSE name = ObjectName( i - 2 ); a = StringSplit( name, StringGetCharacter(" ",0) , split); priceclose = double( split[ ArraySize(split) - 1 ] ); // // GET OPEN name = ObjectName( i - 3 ); a = StringSplit( name, StringGetCharacter(" ",0) , split); priceopen = double( split[ ArraySize(split) - 1 ] ); // // GET TREND LINE name = ObjectName( i - 4 ); ObjSet( i , OBJ_ALL_PERIODS, count); if(InpHideSellLoss == 1 ){ if( type == "sell" && priceclose > priceopen ){ ObjSet( i , InpHideTF, count); } } if(InpHideSellWin == 1 ){ if( type == "sell" && priceclose < priceopen ){ ObjSet( i , InpHideTF, count); } } if(InpHideBuyLoss == 1 ){ if( type == "buy" && priceclose < priceopen ){ ObjSet( i , InpHideTF, count); } } if(InpHideBuyWin == 1 ){ if( type == "buy" && priceclose > priceopen ){ ObjSet( i , InpHideTF, count); } } } Print( "PROCESSED: " , count ); } void ObjSet( int i, int vis, int count){ ObjectSet( ObjectName(i) , OBJPROP_TIMEFRAMES, vis ); ObjectSet( ObjectName(i-1), OBJPROP_TIMEFRAMES, vis ); ObjectSet( ObjectName(i-2), OBJPROP_TIMEFRAMES, vis ); ObjectSet( ObjectName(i-3), OBJPROP_TIMEFRAMES, vis ); ObjectSet( ObjectName(i-4), OBJPROP_TIMEFRAMES, vis ); count++; }
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello gang, hope you all well.
Im trying to debug my EA and itd be very helpful to isolate objects the tester created per trades. For example, hiding loser trader, or winners, or just hide sells/just buys.
Im not sure if is it necessary to create Struct for it, and if so, i imagine i need to keep track of all objects from that Ticket order, as I would need to loop thru these 5 anyways.. would you have any suggestions or ideas ?
its seems a bit tricky to do that with just 1 loop across all objects.
Many thanks
Mag