//+------------------------------------------------------------------+ //| Manual backtester | //+------------------------------------------------------------------+ #property copyright "sorrex" #property link "" // #property show_confirm //+------------------------------------------------------------------+ //| script vytvorí 2 VL, ktorými hýbete a prestavujete ostatné | //+------------------------------------------------------------------+ int start() { datetime from_position,to_position; int from_shift, to_shift; CurTime(); if (ObjectFind("BUY")<0) CreateVLine("BUY", Time[10], STYLE_SOLID, 1, Blue); if (ObjectFind("SELL") <0) CreateVLine("SELL", CurTime(), STYLE_SOLID, 1, Red); while (true) { from_position = ObjectGet("BUY",OBJPROP_TIME1); from_shift = iBarShift(NULL,0,from_position); CreateHLine("BUY_PRICE", Close[from_shift], STYLE_DASH, 1, Blue); to_position = ObjectGet("SELL",OBJPROP_TIME1); to_shift = iBarShift(NULL,0,to_position); CreateHLine("SELL_PRICE", Close[to_shift], STYLE_DASH, 1, Red); Comment ( "Aktívny ManualProfit skript - pre jeho ukončenie, vymaž zvislú linku FROM (modrú) \n", "Profit = ", (Close[to_shift]-Close[from_shift])/Point); if (ObjectFind("BUY")<0) { ObjectDelete("SELL"); ObjectDelete("BUY_PRICE"); ObjectDelete("SELL_PRICE"); return (0); } Sleep (500); } return(0); } //+------------------------------------------------------------------+ void CreateHLine(string name, double p1, int style, int width, color col) { if (ObjectFind(name)>=0)ObjectDelete(name); ObjectCreate(name, OBJ_HLINE, 0, CurTime(), p1); ObjectSet(name, OBJPROP_COLOR , col); ObjectSet(name, OBJPROP_STYLE , style); ObjectSet(name, OBJPROP_WIDTH , width); } void CreateVLine(string name, datetime t1, int style, int width, color col) { ObjectDelete(name); ObjectCreate(name, OBJ_VLINE, 0, t1, 0); ObjectSet(name, OBJPROP_COLOR , col); ObjectSet(name, OBJPROP_STYLE , style); ObjectSet(name, OBJPROP_WIDTH , width); }