Hi, anyone wanna modify this function a little ?
Its a very useful tool for testing / debugging / visualizing stuff.
Problem is that it places multiple Vlines at the same bar (typically on for each tick)
and even a short testrun can result in thousands of lines ontop of eachother, which is very
slow and eats memory. The fix would be to first check if the bar already has one of these lines, and if so just return.
To make it a little easier for you here is a test EA that uses the function to mark the upslope of an MA:
int ObjCnt; int start() { double MAc =iMA(NULL,0,30,0,MODE_SMMA,PRICE_MEDIAN,1); double MAp =iMA(NULL,0,30,0,MODE_SMMA,PRICE_MEDIAN,2); if( (MAc > MAp) ) DrawVline(Yellow, Time[0]); //---- return(0); } //---------- //----------------------------------------------------------- void DrawVline (color Color, datetime time) { ObjCnt++; /* //------------ int ObjectsAll = ObjectsTotal(); int i = 0; while(i < ObjectsAll) { ObjectDelete("RecIa"+i);//Background for the InfoField ObjectDelete("RecIb"+i);//Background for the InfoField ObjectDelete("RecW"+i);//Background for the WarningField i++; } //------------ */ ObjectCreate( "UpLine"+ObjCnt, OBJ_VLINE, 0, time, 0); ObjectSet("UpLine"+ObjCnt, OBJPROP_COLOR, Color); ObjectSet("UpLine"+ObjCnt, OBJPROP_BACK,true); return(0); } //-----------------------------------------------------------
To make it a little easier for you here is a test EA that uses the function to mark the upslope of an MA:
Seems I'm mostly communicating with myself here... Anyhow here is the simple fix:
//----------------------------------------------------------- void DrawVline (color Color, datetime time) { static int ObjCnt; static double PrevVlineTime; if (time == PrevVlineTime) return(0);//Still on same bar ObjectCreate( "UpLine"+ObjCnt, OBJ_VLINE, 0, time, 0); ObjectSet("UpLine"+ObjCnt, OBJPROP_COLOR, Color); ObjectSet("UpLine"+ObjCnt, OBJPROP_BACK,true); ObjCnt++; PrevVlineTime = time;//Store bar time of last drawn line return(0); } //-----------------------------------------------------------

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi, anyone wanna modify this function a little ?
Its a very useful tool for testing / debugging / visualizing stuff.
Problem is that it places multiple Vlines at the same bar (typically on for each tick)
and even a short testrun can result in thousands of lines ontop of eachother, which is very
slow and eats memory. The fix would be to first check if the bar already has one of these lines, and if so just return.