This one I believe is a trend line based entry and exit system that draws trend lines over a series of candles to pin point entries and exits.
I believe this one is meta...
//+------------------------------------------------------------------+ //| Calculate optimal lot size | //+------------------------------------------------------------------+ double LotsOptimized() { double lot=Lots; int orders=HistoryTotal(); // history orders total int losses=0; // number of losses orders without a break //---- select lot size lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/1000.0,1); //---- calcuulate number of losses orders without a break if(DecreaseFactor>0) { for(int i=orders-1;i>=0;i--) { if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) { Print("Error in history!"); break; } if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL) continue; //---- if(OrderProfit()>0) break; if(OrderProfit()<0) losses++; } if(losses>1) lot=NormalizeDouble(lot-lot*losses/DecreaseFactor,1); } //---- return lot size if(lot<0.1) lot=0.1; return(lot); } int init() { if(StopOrderTLs) { //###################### STOP ORDER TREND LINES ##################### ObjectCreate("BuyStop", OBJ_TREND, 0, CurTime()-(Period()*60*30), High[Highest(NULL,0,MODE_HIGH,10,1)]+5*Point,CurTime(),High[Highest(NULL,0,MODE_HIGH,10,1)]+5*Point); ObjectSet("BuyStop",6,LimeGreen); ObjectSet("BuyStop",7,STYLE_DOT); ObjectSet("BuyStop",10,0); ObjectSetText("BuyStop","BuyStop"); ObjectCreate("SellStop", OBJ_TREND, 0, CurTime()-(Period()*60*30), Low[Lowest(NULL,0,MODE_LOW,10,1)]-5*Point,CurTime(),Low[Lowest(NULL,0,MODE_LOW,10,1)]-5*Point); ObjectSet("SellStop",6,HotPink); ObjectSet("SellStop",7,STYLE_DOT); ObjectSet("SellStop",10,0); ObjectSetText("SellStop","SellStop"); ObjectCreate("BuyStopSL", OBJ_TREND, 0, CurTime()-(Period()*60*30), High[Highest(NULL,0,MODE_HIGH,10,1)],CurTime(),High[Highest(NULL,0,MODE_HIGH,10,1)]); ObjectSet("BuyStopSL",6,Blue); ObjectSet("BuyStopSL",7,STYLE_DOT); ObjectSet("BuyStopSL",10,0); ObjectSetText("BuyStopSL","BuyStopSL"); ObjectCreate("SellStopSL", OBJ_TREND, 0, CurTime()-(Period()*60*30), Low[Lowest(NULL,0,MODE_LOW,10,1)],CurTime(),Low[Lowest(NULL,0,MODE_LOW,10,1)]); ObjectSet("SellStopSL",6,FireBrick); ObjectSet("SellStopSL",7,STYLE_DOT); ObjectSet("SellStopSL",10,0); ObjectSetText("SellStopSL","SellStopSL"); ObjectCreate("BuyStopTP", OBJ_TREND, 0, CurTime()-(Period()*60*30), High[Highest(NULL,0,MODE_HIGH,10,1)]+10*Point,CurTime(),High[Highest(NULL,0,MODE_HIGH,10,1)]+10*Point); ObjectSet("BuyStopTP",6,Aqua); ObjectSet("BuyStopTP",7,STYLE_DOT); ObjectSet("BuyStopTP",10,0); ObjectSetText("BuyStopTP","BuyStopTP"); ObjectCreate("SellStopTP", OBJ_TREND, 0, CurTime()-(Period()*60*30), Low[Lowest(NULL,0,MODE_LOW,10,1)]-10*Point,CurTime(),Low[Lowest(NULL,0,MODE_LOW,10,1)]-10*Point); ObjectSet("SellStopTP",6,Tomato); ObjectSet("SellStopTP",7,STYLE_DOT); ObjectSet("SellStopTP",10,0); ObjectSetText("SellStopTP","SellStopTP"); }//end if(StopOrderTLs)
Should anyone convert have fun, but please post the results for all.
Comment