//+---------------------------------------------------------------------+ //| T101 v3.4.mq4 | //| Copyright © 2008, thomas liles. | //| http://www.trendchaser.org | //|added code to sort pairs in descending order: guiomdetalle, 28/09/08 | //+---------------------------------------------------------------------+ #property copyright "Copyright © 2008, thomas liles." #property link "http://www.trendchaser.org" extern bool alert= true; extern bool can_trade= false; extern bool equity_trail= true; extern double start_trail= 0.3; extern double trail= 0.3; extern double starting_target=-10; extern bool exit_on_reverse= true; extern double Lot= 0.01; extern double Maximum_Risk = 0.5; extern int tf=60; extern int look_back= 5; extern bool update_start= true; extern double pips_filter= 100; extern bool reset_ea_zero_pips= false; extern string long_basket= "enter 7 long symbols"; extern string long_basket1= "GBPUSDm"; extern double price1= 0; extern string long_basket2= "EURGBPm"; extern double price2= 0; extern string long_basket3= "GBPJPYm"; extern double price3= 0; extern string long_basket4= "USDCHFm"; extern double price4= 0; extern string long_basket5= "NZDUSDm"; extern double price5= 0; extern string long_basket6= "AUDJPYm"; extern double price6= 0; extern string long_basket7= "EURJPYm"; extern double price7= 0; extern string short_basket= "enter 7 short symbols"; extern string short_basket1= "EURUSDm"; extern double price8= 0; extern string short_basket2= "USDJPYm"; extern double price9= 0; extern string short_basket3= "AUDUSDm"; extern double price10= 0; extern string short_basket4= "NZDJPYm"; extern double price11= 0; extern string short_basket5= "GBPCHFm"; extern double price12= 0; extern string short_basket6= "CHFJPYm"; extern double price13= 0; extern string short_basket7= "EURCHFm"; extern double price14= 0; extern int profit_font_size =16; extern int slippage =100; bool time_restriction= false; extern string Trade_Hours= "Set Morning & Evening Hours 24hr"; extern string Trade_Hours_M= "Morning Hours 0-12"; extern int start_hourm = 0; extern int end_hourm = 12; extern string Trade_Hours_E= "Evening Hours 12-24"; extern int start_houre = 12; extern int end_houre = 24; double interval=1; bool use_ma= false; int ma_tf =240; int ma_period =20; bool trade_allowed=true; double minutes = 0; double pcnt,pcntd,interval2,target_dollars; double ma1,ma2,ma3,ma4,ma5,ma6,ma7,ma8,ma9,ma10,ma11,ma12,ma13,ma14; bool longs_allowed=true,short_alert=true,long_alert=true; bool shorts_allowed=true; double GBPUSDm,EURGBPm,GBPJPYm,USDCHFm,NZDUSDm,AUDJPYm,EURJPYm;double EURUSDm,USDJPYm,AUDUSDm,NZDJPYm,GBPCHFm,CHFJPYm,EURCHFm;double GBPUSDm_now,EURGBPm_now,GBPJPYm_now,USDCHFm_now,NZDUSDm_now,AUDJPYm_now,EURJPYm_now;double EURUSDm_now,USDJPYm_now,AUDUSDm_now,NZDJPYm_now,GBPCHFm_now,CHFJPYm_now,EURCHFm_now;double GBPUSDm_pips,EURGBPm_pips,GBPJPYm_pips,USDCHFm_pips,NZDUSDm_pips,AUDJPYm_pips,EURJPYm_pips;double EURUSDm_pips,USDJPYm_pips,AUDUSDm_pips,NZDJPYm_pips,GBPCHFm_pips,CHFJPYm_pips,EURCHFm_pips;double highest_long_pips=0, highest_short_pips=0,long_pips, short_pips;string signal; int gbpusd,eurgbp,gbpjpy,usdchf,nzdusd,audjpy,eurjpy,eurusd,usdjpy,audusd,nzdjpy,gbpchf,chfjpy,eurchf,blue,red,buys,sells; bool close_l= false; bool close_s= false; bool close_all= false; bool open_buys= false; bool open_sells= false; string stat= "waiting"; //+------------------------------------------------------------------+ //| TC //+------------------------------------------------------------------+ int init() { orders(); checkup(); run_statistics_longs(); run_statistics_shorts(); comments(); check_signal(); draw_objects(); return(0); } //+------------------------------------------------------------------+ //| TC //+------------------------------------------------------------------+ int deinit() { return(0); } //+------------------------------------------------------------------+ //| TC //+------------------------------------------------------------------+ int start() { orders(); if(open_buys&&sells==14)open_buys=false; if(open_sells&&buys==14)open_sells=false; if(close_l) {longs_allowed=false;close_longs();} if(close_s) {shorts_allowed=false;close_shorts();} if(close_all&&buys>0){longs_allowed=false; close();} if(close_all&&sells>0){longs_allowed=false; close();} if(update_start) checkup(); run_statistics_longs(); run_statistics_shorts(); comments(); check_signal(); check_exit(); if(open_buys&&close_l==false&&close_s==false&&close_all==false&&open_sells==false) {stat="opening buys";buy();} if(open_sells&&close_l==false&&close_s==false&&close_all==false&&open_buys==false) {stat="opening sells";sell();} orders(); if(use_ma==false&&open_buys&&buys==14) open_buys=false; if(use_ma==false&&open_sells&&sells==14) open_sells=false; if(close_l&&buys==0) close_l=false; if(close_s&&sells==0) close_s=false; if(close_all&&buys==0&&sells==0) close_all=false; orders(); draw_objects(); if(close_l==false&&close_s==false&&close_all==false&&open_buys==false&&open_sells==false) stat="waiting"; return(0); } //+------------------------------------------------------------------+ //| TC //+------------------------------------------------------------------+ void orders() { pcnt =( (AccountEquity()-AccountBalance()) / AccountBalance())*100; pcntd =AccountEquity()-AccountBalance() ; target_dollars =( (AccountBalance()/100) *starting_target); buys=0;sells=0;gbpusd=0;eurgbp=0;gbpjpy=0;usdchf=0;nzdusd=0;audjpy=0;eurjpy=0;eurusd=0;usdjpy=0;audusd=0;nzdjpy=0;gbpchf=0;chfjpy=0;eurchf=0; int totalorders = OrdersTotal(); for(int i=totalorders-1;i>=0;i--) { OrderSelect(i, SELECT_BY_POS); if ( OrderType() == OP_SELL ) {sells=sells+1;} if ( OrderType() == OP_BUY ) {buys=buys+1;} if ( OrderSymbol() == long_basket1 ) {gbpusd++;} if ( OrderSymbol() == long_basket2 ) {eurgbp++;} if ( OrderSymbol() == long_basket3 ) {gbpjpy++;} if ( OrderSymbol() == long_basket4 ) {usdchf++;} if ( OrderSymbol() == long_basket5 ) {nzdusd++;} if ( OrderSymbol() == long_basket6 ) {audjpy++;} if ( OrderSymbol() == long_basket7 ) {eurjpy++;} if ( OrderSymbol() == short_basket1 ) {eurusd++;} if ( OrderSymbol() == short_basket2 ) {usdjpy++;} if ( OrderSymbol() == short_basket3 ) {audusd++;} if ( OrderSymbol() == short_basket4 ) {nzdjpy++;} if ( OrderSymbol() == short_basket5 ) {gbpchf++;} if ( OrderSymbol() == short_basket6 ) {chfjpy++;} if ( OrderSymbol() == short_basket7 ) {eurchf++;} } return; } //+------------------------------------------------------------------+ //| TC //+------------------------------------------------------------------+ void checkup(){ if (price1==0)GBPUSDm= iOpen(long_basket1, tf, look_back);else GBPUSDm=price1; if (price2==0)EURGBPm= iOpen(long_basket2, tf, look_back);else EURGBPm=price2; if (price3==0)GBPJPYm= iOpen(long_basket3, tf, look_back);else GBPJPYm=price3; if (price4==0)USDCHFm= iOpen(long_basket4, tf, look_back);else USDCHFm=price4; if (price5==0)NZDUSDm= iOpen(long_basket5, tf, look_back);else NZDUSDm=price5; if (price6==0)AUDJPYm= iOpen(long_basket6, tf, look_back);else AUDJPYm=price6; if (price7==0)EURJPYm= iOpen(long_basket7, tf, look_back);else EURJPYm=price7; if (price8==0)EURUSDm= iOpen(short_basket1, tf, look_back);else EURUSDm=price8; if (price9==0)USDJPYm= iOpen(short_basket2, tf, look_back);else USDJPYm=price9; if (price10==0)AUDUSDm= iOpen(short_basket3, tf, look_back);else AUDUSDm=price10; if (price11==0)NZDJPYm= iOpen(short_basket4, tf, look_back);else NZDJPYm=price11; if (price12==0)GBPCHFm= iOpen(short_basket5, tf, look_back);else GBPCHFm=price12; if (price13==0)CHFJPYm= iOpen(short_basket6, tf, look_back);else CHFJPYm=price13; if (price14==0)EURCHFm= iOpen(short_basket7, tf, look_back);else EURCHFm=price14;} //+------------------------------------------------------------------+ //| TC //+------------------------------------------------------------------+ void run_statistics_longs() { GBPUSDm_now= iClose(long_basket1, 0, 0); EURGBPm_now= iClose(long_basket2, 0, 0); GBPJPYm_now= iClose(long_basket3, 0, 0); USDCHFm_now= iClose(long_basket4, 0, 0); NZDUSDm_now= iClose(long_basket5, 0, 0); AUDJPYm_now= iClose(long_basket6, 0, 0); EURJPYm_now= iClose(long_basket7, 0, 0); int spread1=MarketInfo(long_basket1,MODE_SPREAD); int spread2=MarketInfo(long_basket2,MODE_SPREAD); int spread3=MarketInfo(long_basket3,MODE_SPREAD); int spread4=MarketInfo(long_basket4,MODE_SPREAD); int spread5=MarketInfo(long_basket5,MODE_SPREAD); int spread6=MarketInfo(long_basket6,MODE_SPREAD); int spread7=MarketInfo(long_basket7,MODE_SPREAD); GBPUSDm_pips = (GBPUSDm_now-GBPUSDm)/MarketInfo(long_basket1,MODE_POINT)-spread1; //GBPUSDm_pips = GBPUSDm_pips*MarketInfo(long_basket1,MODE_TICKVALUE); EURGBPm_pips = (EURGBPm_now-EURGBPm)/MarketInfo(long_basket2,MODE_POINT)-spread2; //EURGBPm_pips = EURGBPm_pips*MarketInfo(long_basket2,MODE_TICKVALUE); GBPJPYm_pips = (GBPJPYm_now-GBPJPYm)/MarketInfo(long_basket3,MODE_POINT)-spread3; //GBPJPYm_pips = GBPJPYm_pips*MarketInfo(long_basket3,MODE_TICKVALUE); USDCHFm_pips = (USDCHFm_now-USDCHFm)/MarketInfo(long_basket4,MODE_POINT)-spread4; //USDCHFm_pips = USDCHFm_pips*MarketInfo(long_basket4,MODE_TICKVALUE); NZDUSDm_pips = (NZDUSDm_now-NZDUSDm)/MarketInfo(long_basket5,MODE_POINT)-spread5; //NZDUSDm_pips = NZDUSDm_pips*MarketInfo(long_basket5,MODE_TICKVALUE); AUDJPYm_pips = (AUDJPYm_now-AUDJPYm)/MarketInfo(long_basket6,MODE_POINT)-spread6; //AUDJPYm_pips = AUDJPYm_pips*MarketInfo(long_basket6,MODE_TICKVALUE); EURJPYm_pips = (EURJPYm_now-EURJPYm)/MarketInfo(long_basket7,MODE_POINT)-spread7; //EURJPYm_pips = EURJPYm_pips*MarketInfo(long_basket7,MODE_TICKVALUE); long_pips = GBPUSDm_pips + EURGBPm_pips + GBPJPYm_pips + USDCHFm_pips + NZDUSDm_pips + AUDJPYm_pips + EURJPYm_pips; if (long_pips>highest_long_pips) highest_long_pips=long_pips; return; } //+------------------------------------------------------------------+ //| TC //+------------------------------------------------------------------+ void run_statistics_shorts() { EURUSDm_now= iClose(short_basket1, 0, 0); USDJPYm_now= iClose(short_basket2, 0, 0); AUDUSDm_now= iClose(short_basket3, 0, 0); NZDJPYm_now= iClose(short_basket4, 0, 0); GBPCHFm_now= iClose(short_basket5, 0, 0); CHFJPYm_now= iClose(short_basket6, 0, 0); EURCHFm_now= iClose(short_basket7, 0, 0); int spread8=MarketInfo(short_basket1,MODE_SPREAD); int spread9=MarketInfo(short_basket2,MODE_SPREAD); int spread10=MarketInfo(short_basket3,MODE_SPREAD); int spread11=MarketInfo(short_basket4,MODE_SPREAD); int spread12=MarketInfo(short_basket5,MODE_SPREAD); int spread13=MarketInfo(short_basket6,MODE_SPREAD); int spread14=MarketInfo(short_basket7,MODE_SPREAD); EURUSDm_pips = (EURUSDm-EURUSDm_now)/MarketInfo(short_basket1,MODE_POINT)-spread8; //EURUSDm_pips = EURUSDm_pips*MarketInfo(short_basket1,MODE_TICKVALUE); USDJPYm_pips = (USDJPYm-USDJPYm_now)/MarketInfo(short_basket2,MODE_POINT)-spread9; //USDJPYm_pips = USDJPYm_pips*MarketInfo(short_basket2,MODE_TICKVALUE); AUDUSDm_pips = (AUDUSDm-AUDUSDm_now)/MarketInfo(short_basket3,MODE_POINT)-spread10; //AUDUSDm_pips = AUDUSDm_pips*MarketInfo(short_basket3,MODE_TICKVALUE); NZDJPYm_pips = (NZDJPYm-NZDJPYm_now)/MarketInfo(short_basket4,MODE_POINT)-spread11; //NZDJPYm_pips = NZDJPYm_pips*MarketInfo(short_basket4,MODE_TICKVALUE); GBPCHFm_pips = (GBPCHFm-GBPCHFm_now)/MarketInfo(short_basket5,MODE_POINT)-spread12; //GBPCHFm_pips = GBPCHFm_pips*MarketInfo(short_basket5,MODE_TICKVALUE); CHFJPYm_pips = (CHFJPYm-CHFJPYm_now)/MarketInfo(short_basket6,MODE_POINT)-spread13; //CHFJPYm_pips = CHFJPYm_pips*MarketInfo(short_basket6,MODE_TICKVALUE); EURCHFm_pips = (EURCHFm-EURCHFm_now)/MarketInfo(short_basket7,MODE_POINT)-spread14; //EURCHFm_pips = EURCHFm_pips*MarketInfo(short_basket7,MODE_TICKVALUE); short_pips = EURUSDm_pips + USDJPYm_pips + AUDUSDm_pips + NZDJPYm_pips + GBPCHFm_pips + CHFJPYm_pips + EURCHFm_pips; if (short_pips>highest_short_pips) highest_short_pips=short_pips; return; } //+------------------------------------------------------------------+ //| TC //+------------------------------------------------------------------+ void check_signal(){ signal = "Ranging"; if (reset_ea_zero_pips&& long_pips<=0&&short_pips<=0 &&buys==0&&sells==0) {longs_allowed=true; shorts_allowed=true;} if ( buys==14 ) {longs_allowed=false;} if ( sells==14 ) {shorts_allowed=false;} if ( buys==0&&sells==0 ) {starting_target=-10;} interval2 = interval*60; if (TimeCurrent()minutes) trade_allowed=true; if (long_pips>pips_filter) {signal = "long";} if (short_pips>pips_filter) {signal = "short";} if (long_pips<0 ){highest_long_pips=0;} if (short_pips<0){highest_short_pips=0;} if (Hour()>=start_hourm && Hour()=start_houre && Hour()=60) h=m/60; else h=0; k=m-(h*60); datetime m1=Time[0]+Period()*60-TimeCurrent(); datetime m5=Time[0]+5*60-TimeCurrent(); datetime m15=Time[0]+15*60-TimeCurrent(); datetime m30=Time[0]+30*60-TimeCurrent(); datetime m60=Time[0]+60*60-TimeCurrent(); datetime m240=Time[0]+240*60-TimeCurrent(); Comment("\n","bar timer= ",TimeToStr(m1,TIME_SECONDS), "\n","buys= ",buys, " sells= ",sells); } //+------------------------------------------------------------------+ //| TC //+------------------------------------------------------------------+ double LotsOptimized() { double minimum_lots=MarketInfo(Symbol(),MODE_MINLOT); double max_lots=MarketInfo(Symbol(),MODE_MAXLOT); double lot=Lot; if (minimum_lots==0.001){ lot=NormalizeDouble(AccountBalance()*Maximum_Risk/1000,3);{}} if (minimum_lots==0.01){ lot=NormalizeDouble(AccountBalance()*Maximum_Risk/10000,2);{}} if (minimum_lots==0.1){ lot=NormalizeDouble(AccountBalance()*Maximum_Risk/100000,1); {}} if (minimum_lots==1){ lot=NormalizeDouble(AccountBalance()*Maximum_Risk/1000000,0);{}} if (lot<=minimum_lots){lot = minimum_lots;{}} if (lot>=max_lots){lot = max_lots;{}} if (lot<=Lot){lot = Lot;{}} // prevent lots from decreasing if (Maximum_Risk==0){lot = Lot;{}} return(lot); } //+------------------------------------------------------------------+ //| TC //+------------------------------------------------------------------+ void buy() { close_l=false;close_s=false;close_all=false; ObjectSetText("status","status = opening buys", profit_font_size,"Times New Roman",Red); if (use_ma)ma1=iMA(long_basket1,ma_tf,ma_period,0,MODE_SMA,PRICE_CLOSE,0); if (use_ma)ma2=iMA(long_basket2,ma_tf,ma_period,0,MODE_SMA,PRICE_CLOSE,0); if (use_ma)ma3=iMA(long_basket3,ma_tf,ma_period,0,MODE_SMA,PRICE_CLOSE,0); if (use_ma)ma4=iMA(long_basket4,ma_tf,ma_period,0,MODE_SMA,PRICE_CLOSE,0); if (use_ma)ma5=iMA(long_basket5,ma_tf,ma_period,0,MODE_SMA,PRICE_CLOSE,0); if (use_ma)ma6=iMA(long_basket6,ma_tf,ma_period,0,MODE_SMA,PRICE_CLOSE,0); if (use_ma)ma7=iMA(long_basket7,ma_tf,ma_period,0,MODE_SMA,PRICE_CLOSE,0); if (use_ma)ma8=iMA(short_basket1,ma_tf,ma_period,0,MODE_SMA,PRICE_CLOSE,0); if (use_ma)ma9=iMA(short_basket2,ma_tf,ma_period,0,MODE_SMA,PRICE_CLOSE,0); if (use_ma)ma10=iMA(short_basket3,ma_tf,ma_period,0,MODE_SMA,PRICE_CLOSE,0); if (use_ma)ma11=iMA(short_basket4,ma_tf,ma_period,0,MODE_SMA,PRICE_CLOSE,0); if (use_ma)ma12=iMA(short_basket5,ma_tf,ma_period,0,MODE_SMA,PRICE_CLOSE,0); if (use_ma)ma13=iMA(short_basket6,ma_tf,ma_period,0,MODE_SMA,PRICE_CLOSE,0); if (use_ma)ma14=iMA(short_basket7,ma_tf,ma_period,0,MODE_SMA,PRICE_CLOSE,0); if (GBPUSDm_now>ma1&&use_ma&&longs_allowed&&gbpusd==0)OrderSend(long_basket1,OP_BUY, LotsOptimized(), MarketInfo(long_basket1,MODE_ASK), slippage, NULL, NULL, NULL, 0, 0, Blue); if (EURGBPm_now>ma2&&use_ma&&longs_allowed&&eurgbp==0)OrderSend(long_basket2,OP_BUY, LotsOptimized(), MarketInfo(long_basket2,MODE_ASK), slippage, NULL, NULL, NULL, 0, 0, Blue); if (GBPJPYm_now>ma3&&use_ma&&longs_allowed&&gbpjpy==0)OrderSend(long_basket3,OP_BUY, LotsOptimized(), MarketInfo(long_basket3,MODE_ASK), slippage, NULL, NULL, NULL, 0, 0, Blue); if (USDCHFm_now>ma4&&use_ma&&longs_allowed&&usdchf==0)OrderSend(long_basket4,OP_BUY, LotsOptimized(), MarketInfo(long_basket4,MODE_ASK), slippage, NULL, NULL, NULL, 0, 0, Blue); if (NZDUSDm_now>ma5&&use_ma&&longs_allowed&&nzdusd==0)OrderSend(long_basket5,OP_BUY, LotsOptimized(), MarketInfo(long_basket5,MODE_ASK), slippage, NULL, NULL, NULL, 0, 0, Blue); if (AUDJPYm_now>ma6&&use_ma&&longs_allowed&&audjpy==0)OrderSend(long_basket6,OP_BUY, LotsOptimized(), MarketInfo(long_basket6,MODE_ASK), slippage, NULL, NULL, NULL, 0, 0, Blue); if (EURJPYm_now>ma7&&use_ma&&longs_allowed&&eurjpy==0)OrderSend(long_basket7,OP_BUY, LotsOptimized(), MarketInfo(long_basket7,MODE_ASK), slippage, NULL, NULL, NULL, 0, 0, Blue); if (EURUSDm_now>ma8&&use_ma&&longs_allowed&&eurusd==0)OrderSend(short_basket1,OP_BUY, LotsOptimized(), MarketInfo(short_basket1,MODE_ASK), slippage, NULL, NULL, NULL, 0, 0, Blue); if (USDJPYm_now>ma9&&use_ma&&longs_allowed&&usdjpy==0)OrderSend(short_basket2,OP_BUY, LotsOptimized(), MarketInfo(short_basket2,MODE_ASK), slippage, NULL, NULL, NULL, 0, 0, Blue); if (AUDUSDm_now>ma10&&use_ma&&longs_allowed&&audusd==0)OrderSend(short_basket3,OP_BUY, LotsOptimized(), MarketInfo(short_basket3,MODE_ASK), slippage, NULL, NULL, NULL, 0, 0, Blue); if (NZDJPYm_now>ma11&&use_ma&&longs_allowed&&nzdjpy==0)OrderSend(short_basket4,OP_BUY, LotsOptimized(), MarketInfo(short_basket4,MODE_ASK), slippage, NULL, NULL, NULL, 0, 0, Blue); if (GBPCHFm_now>ma12&&use_ma&&longs_allowed&&gbpchf==0)OrderSend(short_basket5,OP_BUY, LotsOptimized(), MarketInfo(short_basket5,MODE_ASK), slippage, NULL, NULL, NULL, 0, 0, Blue); if (CHFJPYm_now>ma13&&use_ma&&longs_allowed&&chfjpy==0)OrderSend(short_basket6,OP_BUY, LotsOptimized(), MarketInfo(short_basket6,MODE_ASK), slippage, NULL, NULL, NULL, 0, 0, Blue); if (EURCHFm_now>ma14&&use_ma&&longs_allowed&&eurchf==0)OrderSend(short_basket7,OP_BUY, LotsOptimized(), MarketInfo(short_basket7,MODE_ASK), slippage, NULL, NULL, NULL, 0, 0, Blue); if (use_ma==false&&longs_allowed&&gbpusd==0)OrderSend(long_basket1,OP_BUY, LotsOptimized(), MarketInfo(long_basket1,MODE_ASK), slippage, NULL, NULL, NULL, 0, 0, Blue); if (use_ma==false&&longs_allowed&&eurgbp==0)OrderSend(long_basket2,OP_BUY, LotsOptimized(), MarketInfo(long_basket2,MODE_ASK), slippage, NULL, NULL, NULL, 0, 0, Blue); if (use_ma==false&&longs_allowed&&gbpjpy==0)OrderSend(long_basket3,OP_BUY, LotsOptimized(), MarketInfo(long_basket3,MODE_ASK), slippage, NULL, NULL, NULL, 0, 0, Blue); if (use_ma==false&&longs_allowed&&usdchf==0)OrderSend(long_basket4,OP_BUY, LotsOptimized(), MarketInfo(long_basket4,MODE_ASK), slippage, NULL, NULL, NULL, 0, 0, Blue); if (use_ma==false&&longs_allowed&&nzdusd==0)OrderSend(long_basket5,OP_BUY, LotsOptimized(), MarketInfo(long_basket5,MODE_ASK), slippage, NULL, NULL, NULL, 0, 0, Blue); if (use_ma==false&&longs_allowed&&audjpy==0)OrderSend(long_basket6,OP_BUY, LotsOptimized(), MarketInfo(long_basket6,MODE_ASK), slippage, NULL, NULL, NULL, 0, 0, Blue); if (use_ma==false&&longs_allowed&&eurjpy==0)OrderSend(long_basket7,OP_BUY, LotsOptimized(), MarketInfo(long_basket7,MODE_ASK), slippage, NULL, NULL, NULL, 0, 0, Blue); if (use_ma==false&&longs_allowed&&eurusd==0)OrderSend(short_basket1,OP_BUY, LotsOptimized(), MarketInfo(short_basket1,MODE_ASK), slippage, NULL, NULL, NULL, 0, 0, Blue); if (use_ma==false&&longs_allowed&&usdjpy==0)OrderSend(short_basket2,OP_BUY, LotsOptimized(), MarketInfo(short_basket2,MODE_ASK), slippage, NULL, NULL, NULL, 0, 0, Blue); if (use_ma==false&&longs_allowed&&audusd==0)OrderSend(short_basket3,OP_BUY, LotsOptimized(), MarketInfo(short_basket3,MODE_ASK), slippage, NULL, NULL, NULL, 0, 0, Blue); if (use_ma==false&&longs_allowed&&nzdjpy==0)OrderSend(short_basket4,OP_BUY, LotsOptimized(), MarketInfo(short_basket4,MODE_ASK), slippage, NULL, NULL, NULL, 0, 0, Blue); if (use_ma==false&&longs_allowed&&gbpchf==0)OrderSend(short_basket5,OP_BUY, LotsOptimized(), MarketInfo(short_basket5,MODE_ASK), slippage, NULL, NULL, NULL, 0, 0, Blue); if (use_ma==false&&longs_allowed&&chfjpy==0)OrderSend(short_basket6,OP_BUY, LotsOptimized(), MarketInfo(short_basket6,MODE_ASK), slippage, NULL, NULL, NULL, 0, 0, Blue); if (use_ma==false&&longs_allowed&&eurchf==0)OrderSend(short_basket7,OP_BUY, LotsOptimized(), MarketInfo(short_basket7,MODE_ASK), slippage, NULL, NULL, NULL, 0, 0, Blue); orders(); if (use_ma==false&&buys==14){ longs_allowed=false;open_buys=false;open_sells=false;} //orders(); return; } //+------------------------------------------------------------------+ //| TC //+------------------------------------------------------------------+ void sell() { close_l=false;close_s=false;close_all=false; ObjectSetText("status","status = opening sells", profit_font_size,"Times New Roman",Red); if (use_ma)ma1=iMA(long_basket1,ma_tf,ma_period,0,MODE_SMA,PRICE_CLOSE,0); if (use_ma)ma2=iMA(long_basket2,ma_tf,ma_period,0,MODE_SMA,PRICE_CLOSE,0); if (use_ma)ma3=iMA(long_basket3,ma_tf,ma_period,0,MODE_SMA,PRICE_CLOSE,0); if (use_ma)ma4=iMA(long_basket4,ma_tf,ma_period,0,MODE_SMA,PRICE_CLOSE,0); if (use_ma)ma5=iMA(long_basket5,ma_tf,ma_period,0,MODE_SMA,PRICE_CLOSE,0); if (use_ma)ma6=iMA(long_basket6,ma_tf,ma_period,0,MODE_SMA,PRICE_CLOSE,0); if (use_ma)ma7=iMA(long_basket7,ma_tf,ma_period,0,MODE_SMA,PRICE_CLOSE,0); if (use_ma)ma8=iMA(short_basket1,ma_tf,ma_period,0,MODE_SMA,PRICE_CLOSE,0); if (use_ma)ma9=iMA(short_basket2,ma_tf,ma_period,0,MODE_SMA,PRICE_CLOSE,0); if (use_ma)ma10=iMA(short_basket3,ma_tf,ma_period,0,MODE_SMA,PRICE_CLOSE,0); if (use_ma)ma11=iMA(short_basket4,ma_tf,ma_period,0,MODE_SMA,PRICE_CLOSE,0); if (use_ma)ma12=iMA(short_basket5,ma_tf,ma_period,0,MODE_SMA,PRICE_CLOSE,0); if (use_ma)ma13=iMA(short_basket6,ma_tf,ma_period,0,MODE_SMA,PRICE_CLOSE,0); if (use_ma)ma14=iMA(short_basket7,ma_tf,ma_period,0,MODE_SMA,PRICE_CLOSE,0); if (GBPUSDm_now=0;i--) { OrderSelect(i, SELECT_BY_POS); { if (equity_trail&&pcnt>=start_trail&&starting_target0) blue++; } if(EURGBPm_pips==PLArray[i]) { PairsDisplay[i] = ""+long_basket2+""; PairsColor[i] = Green; if (EURGBPm_pips>0) blue++; } if(AUDJPYm_pips==PLArray[i]) { PairsDisplay[i] = ""+long_basket6+""; PairsColor[i] = Green; if (AUDJPYm_pips>0) blue++; } if(EURJPYm_pips==PLArray[i]) { PairsDisplay[i] = ""+long_basket7+""; PairsColor[i] = Green; if (EURJPYm_pips>0) blue++; } if(USDCHFm_pips==PLArray[i]) { PairsDisplay[i] = ""+long_basket4+""; PairsColor[i] = Green; if (USDCHFm_pips>0) blue++; } if(GBPJPYm_pips==PLArray[i]) { PairsDisplay[i] = ""+long_basket3+""; PairsColor[i] = Green; if (GBPJPYm_pips>0) blue++; } if(NZDUSDm_pips==PLArray[i]) { PairsDisplay[i] = ""+long_basket5+""; PairsColor[i] = Green; if (NZDUSDm_pips>0) blue++; } if(NZDJPYm_pips==PLArray[i]) { PairsDisplay[i] = ""+short_basket4+""; PairsColor[i] = Red; if (NZDJPYm_pips>0) red++; } if(AUDUSDm_pips==PLArray[i]) { PairsDisplay[i] = ""+short_basket3+""; PairsColor[i] = Red; if (AUDUSDm_pips>0) red++; } if(USDJPYm_pips==PLArray[i]) { PairsDisplay[i] = ""+short_basket2+""; PairsColor[i] = Red; if (USDJPYm_pips>0) red++; } if(EURUSDm_pips==PLArray[i]) { PairsDisplay[i] = ""+short_basket1+""; PairsColor[i] = Red; if (EURUSDm_pips>0) red++; } if(EURCHFm_pips==PLArray[i]) { PairsDisplay[i] = ""+short_basket7+""; PairsColor[i] = Red; if (EURCHFm_pips>0) red++; } if(GBPCHFm_pips==PLArray[i]) { PairsDisplay[i] = ""+short_basket5+""; PairsColor[i] = Red; if (GBPCHFm_pips>0) red++; } if(CHFJPYm_pips==PLArray[i]) { PairsDisplay[i] = ""+short_basket6+""; PairsColor[i] = Red; if (CHFJPYm_pips>0) red++; } // Print(PairsDisplay[i],"...",i,"..",PairsColor[i]); } if (ObjectFind("1") == -1 ){ ObjectCreate("1", OBJ_LABEL, companion, 0, 0); ObjectSet("1", OBJPROP_COLOR, Red); ObjectSet("1", OBJPROP_XDISTANCE, 10); ObjectSet("1", OBJPROP_YDISTANCE, 40);} if (PLArray[0]>0){ObjectSetText("1",PairsDisplay[0]+" = "+DoubleToStr(PLArray[0],0), 10,"Times New Roman",PairsColor[0]);} if (PLArray[0]<0){ObjectSetText("1",PairsDisplay[0]+" = "+DoubleToStr(PLArray[0],0), 10,"Times New Roman",PairsColor[0]);} if (ObjectFind("2") == -1 ){ ObjectCreate("2", OBJ_LABEL, companion, 0, 0); ObjectSet("2", OBJPROP_COLOR, Red); ObjectSet("2", OBJPROP_XDISTANCE, 10); ObjectSet("2", OBJPROP_YDISTANCE, 60);} if (PLArray[1]>0){ObjectSetText("2",PairsDisplay[1]+" = "+DoubleToStr(PLArray[1],0), 10,"Times New Roman",PairsColor[1]);} if (PLArray[1]<0){ObjectSetText("2",PairsDisplay[1]+" = "+DoubleToStr(PLArray[1],0), 10,"Times New Roman",PairsColor[1]);} if (ObjectFind("3") == -1 ){ ObjectCreate("3", OBJ_LABEL, companion, 0, 0); ObjectSet("3", OBJPROP_COLOR, Red); ObjectSet("3", OBJPROP_XDISTANCE, 10); ObjectSet("3", OBJPROP_YDISTANCE, 80);} if (PLArray[2]>0){ObjectSetText("3",PairsDisplay[2]+" = "+DoubleToStr(PLArray[2],0), 10,"Times New Roman",PairsColor[2]);} if (PLArray[2]<0){ObjectSetText("3",PairsDisplay[2]+" = "+DoubleToStr(PLArray[2],0), 10,"Times New Roman",PairsColor[2]);} if (ObjectFind("4") == -1 ){ ObjectCreate("4", OBJ_LABEL, companion, 0, 0); ObjectSet("4", OBJPROP_COLOR, Red); ObjectSet("4", OBJPROP_XDISTANCE, 10); ObjectSet("4", OBJPROP_YDISTANCE, 100);} if (PLArray[3]>0){ObjectSetText("4",PairsDisplay[3]+" = "+DoubleToStr(PLArray[3],0), 10,"Times New Roman",PairsColor[3]);} if (PLArray[3]<0){ObjectSetText("4",PairsDisplay[3]+" = "+DoubleToStr(PLArray[3],0), 10,"Times New Roman",PairsColor[3]);} if (ObjectFind("5") == -1 ){ ObjectCreate("5", OBJ_LABEL, companion, 0, 0); ObjectSet("5", OBJPROP_COLOR, Red); ObjectSet("5", OBJPROP_XDISTANCE, 10); ObjectSet("5", OBJPROP_YDISTANCE, 120);} if (PLArray[4]>0){ObjectSetText("5",PairsDisplay[4]+" = "+DoubleToStr(PLArray[4],0), 10,"Times New Roman",PairsColor[4]);} if (PLArray[4]<0){ObjectSetText("5",PairsDisplay[4]+" = "+DoubleToStr(PLArray[4],0), 10,"Times New Roman",PairsColor[4]);} if (ObjectFind("6") == -1 ){ ObjectCreate("6", OBJ_LABEL, companion, 0, 0); ObjectSet("6", OBJPROP_COLOR, Red); ObjectSet("6", OBJPROP_XDISTANCE, 10); ObjectSet("6", OBJPROP_YDISTANCE, 140);} if (PLArray[5]>0){ObjectSetText("6",PairsDisplay[5]+" = "+DoubleToStr(PLArray[5],0), 10,"Times New Roman",PairsColor[5]);} if (PLArray[5]<0){ObjectSetText("6",PairsDisplay[5]+" = "+DoubleToStr(PLArray[5],0), 10,"Times New Roman",PairsColor[5]);} if (ObjectFind("7") == -1 ){ ObjectCreate("7", OBJ_LABEL, companion, 0, 0); ObjectSet("7", OBJPROP_COLOR, Red); ObjectSet("7", OBJPROP_XDISTANCE, 10); ObjectSet("7", OBJPROP_YDISTANCE, 160);} if (PLArray[6]>0){ObjectSetText("7",PairsDisplay[6]+" = "+DoubleToStr(PLArray[6],0), 10,"Times New Roman",PairsColor[6]);} if (PLArray[6]<0){ObjectSetText("7",PairsDisplay[6]+" = "+DoubleToStr(PLArray[6],0), 10,"Times New Roman",PairsColor[6]);} if (ObjectFind("8") == -1 ){ ObjectCreate("8", OBJ_LABEL, companion, 0, 0); ObjectSet("8", OBJPROP_COLOR, Red); ObjectSet("8", OBJPROP_XDISTANCE, 10); ObjectSet("8", OBJPROP_YDISTANCE, 200);} if (PLArray[7]>0){ObjectSetText("8",PairsDisplay[7]+" = "+DoubleToStr(PLArray[7],0), 10,"Times New Roman",PairsColor[7]);} if (PLArray[7]<0){ObjectSetText("8",PairsDisplay[7]+" = "+DoubleToStr(PLArray[7],0), 10,"Times New Roman",PairsColor[7]);} if (ObjectFind("9") == -1 ){ ObjectCreate("9", OBJ_LABEL, companion, 0, 0); ObjectSet("9", OBJPROP_COLOR, Red); ObjectSet("9", OBJPROP_XDISTANCE, 10); ObjectSet("9", OBJPROP_YDISTANCE, 220);} if (PLArray[8]>0){ObjectSetText("9",PairsDisplay[8]+" = "+DoubleToStr(PLArray[8],0), 10,"Times New Roman",PairsColor[8]);} if (PLArray[8]<0){ObjectSetText("9",PairsDisplay[8]+" = "+DoubleToStr(PLArray[8],0), 10,"Times New Roman",PairsColor[8]);} if (ObjectFind("10") == -1 ){ ObjectCreate("10", OBJ_LABEL, companion, 0, 0); ObjectSet("10", OBJPROP_COLOR, Red); ObjectSet("10", OBJPROP_XDISTANCE, 10); ObjectSet("10", OBJPROP_YDISTANCE, 240);} if (PLArray[9]>0){ObjectSetText("10",PairsDisplay[9]+" = "+DoubleToStr(PLArray[9],0), 10,"Times New Roman",PairsColor[9]);} if (PLArray[9]<0){ObjectSetText("10",PairsDisplay[9]+" = "+DoubleToStr(PLArray[9],0), 10,"Times New Roman",PairsColor[9]);} if (ObjectFind("11") == -1 ){ ObjectCreate("11", OBJ_LABEL, companion, 0, 0); ObjectSet("11", OBJPROP_COLOR, Red); ObjectSet("11", OBJPROP_XDISTANCE, 10); ObjectSet("11", OBJPROP_YDISTANCE, 260);} if (PLArray[10]>0){ObjectSetText("11",PairsDisplay[10]+" = "+DoubleToStr(PLArray[10],0), 10,"Times New Roman",PairsColor[10]);} if (PLArray[10]<0){ObjectSetText("11",PairsDisplay[10]+" = "+DoubleToStr(PLArray[10],0), 10,"Times New Roman",PairsColor[10]);} if (ObjectFind("12") == -1 ){ ObjectCreate("12", OBJ_LABEL, companion, 0, 0); ObjectSet("12", OBJPROP_COLOR, Red); ObjectSet("12", OBJPROP_XDISTANCE, 10); ObjectSet("12", OBJPROP_YDISTANCE, 280);} if (PLArray[11]>0){ObjectSetText("12",PairsDisplay[11]+" = "+DoubleToStr(PLArray[11],0), 10,"Times New Roman",PairsColor[11]);} if (PLArray[11]<0){ObjectSetText("12",PairsDisplay[11]+" = "+DoubleToStr(PLArray[11],0), 10,"Times New Roman",PairsColor[11]);} if (ObjectFind("13") == -1 ){ ObjectCreate("13", OBJ_LABEL, companion, 0, 0); ObjectSet("13", OBJPROP_COLOR, Red); ObjectSet("13", OBJPROP_XDISTANCE, 10); ObjectSet("13", OBJPROP_YDISTANCE, 300);} if (PLArray[12]>0){ObjectSetText("13",PairsDisplay[12]+" = "+DoubleToStr(PLArray[12],0), 10,"Times New Roman",PairsColor[12]);} if (PLArray[12]<0){ObjectSetText("13",PairsDisplay[12]+" = "+DoubleToStr(PLArray[12],0), 10,"Times New Roman",PairsColor[12]);} if (ObjectFind("14") == -1 ){ ObjectCreate("14", OBJ_LABEL, companion, 0, 0); ObjectSet("14", OBJPROP_COLOR, Red); ObjectSet("14", OBJPROP_XDISTANCE, 10); ObjectSet("14", OBJPROP_YDISTANCE, 320);} if (PLArray[13]>0){ObjectSetText("14",PairsDisplay[13]+" = "+DoubleToStr(PLArray[13],0), 10,"Times New Roman",PairsColor[13]);} if (PLArray[13]<0){ObjectSetText("14",PairsDisplay[13]+" = "+DoubleToStr(PLArray[13],0), 10,"Times New Roman",PairsColor[13]);} if (ObjectFind("sig") == -1 ){ ObjectCreate("sig", OBJ_LABEL, companion, 0, 0); ObjectSet("sig", OBJPROP_COLOR, Red); ObjectSet("sig", OBJPROP_XDISTANCE, 125); ObjectSet("sig", OBJPROP_YDISTANCE, 450);} ObjectSetText("sig","Signal= Ranging", 16,"Times New Roman",Gray); if (signal == "long") { ObjectSetText("sig","Signal= Buy", 16,"Times New Roman",Blue); if (alert&&long_alert)PlaySound("alert.wav"); long_alert=false; short_alert=true; } if (signal == "short") { ObjectSetText("sig","Signal= Sell", 16,"Times New Roman",Red); if (alert&&short_alert)PlaySound("alert.wav"); short_alert=false; long_alert=true; } if (signal == "Ranging"){ObjectSetText("sig","Signal= Ranging", 16,"Times New Roman",Gray); } int total = short_pips+long_pips; if (ObjectFind("tot") == -1 ){ ObjectCreate("tot", OBJ_LABEL, companion, 0, 0); ObjectSet("tot", OBJPROP_COLOR, Red); ObjectSet("tot", OBJPROP_XDISTANCE, 10); ObjectSet("tot", OBJPROP_YDISTANCE, 460);} ObjectSetText("tot","Total= "+total+"", 16,"Times New Roman",Yellow); string trail3 =DoubleToStr(start_trail,2); string trail2 =DoubleToStr(trail,2); string pcnt2 = DoubleToStr(pcnt,2); string pcnt3 = DoubleToStr(pcntd,2); string target3 = DoubleToStr(target_dollars,2); string target2 = DoubleToStr(starting_target,2); if (ObjectFind("pc") == -1 ){ ObjectCreate("pc", OBJ_LABEL, companion, 0, 0); ObjectSet("pc", OBJPROP_COLOR, Red); ObjectSet("pc", OBJPROP_XDISTANCE, 220); ObjectSet("pc", OBJPROP_YDISTANCE, 0);} if (pcnt>0)ObjectSetText("pc","Profit = $"+pcnt3+" %"+pcnt2+"", profit_font_size,"Times New Roman",SpringGreen); if (pcnt<0)ObjectSetText("pc","Profit = $"+pcnt3+" %"+pcnt2+"", profit_font_size,"Times New Roman",Red); if (pcnt==0)ObjectSetText("pc","Profit = $"+pcnt3+" %"+pcnt2+"", profit_font_size,"Times New Roman",Yellow); if (ObjectFind("status") == -1 ){ ObjectCreate("status", OBJ_LABEL, companion, 0, 0); ObjectSet("status", OBJPROP_COLOR, Red); ObjectSet("status", OBJPROP_XDISTANCE, 140); ObjectSet("status", OBJPROP_YDISTANCE, 250);} ObjectSetText("status","status = "+stat+"", profit_font_size,"Times New Roman",Green); if (stat!= "waiting")ObjectSet("status", OBJPROP_COLOR, Red); if (stat== "waiting")ObjectSet("status", OBJPROP_COLOR, Green); ////////////////////////////////////////////////////////////////////////// if (ObjectFind("open_longs") == -1 ) { ObjectCreate("open_longs", OBJ_LABEL, companion, 0, 0); ObjectSet("open_longs", OBJPROP_COLOR, Red); ObjectSet("open_longs", OBJPROP_XDISTANCE, 140); ObjectSet("open_longs", OBJPROP_YDISTANCE, 150); ObjectSetText("open_longs","open longs", 16,"Times New Roman",DeepSkyBlue);} ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// if (exit_on_reverse&&signal != "short"&&ObjectGet("open_longs", OBJPROP_XDISTANCE) != 140) { ObjectSetText("status","status = opening buys", profit_font_size,"Times New Roman",Red); longs_allowed=true; open_buys=true; ObjectSet ("open_longs", OBJPROP_XDISTANCE, 140); ObjectSet ("open_longs", OBJPROP_YDISTANCE, 150);} ////////////////////////////////////////////////////////////////////////// if (exit_on_reverse&&signal == "short")ObjectSetText("open_longs","open longs", 16,"Times New Roman",Gray); if (exit_on_reverse&&signal != "short")ObjectSetText("open_longs","open longs", 16,"Times New Roman",DeepSkyBlue); if (!exit_on_reverse)ObjectSetText("open_longs","open longs", 16,"Times New Roman",DeepSkyBlue); ////////////////////////////////////////////////////////////////////////// if (exit_on_reverse==false&&ObjectGet("open_longs", OBJPROP_XDISTANCE) != 140) { ObjectSetText("status","status = opening buys", profit_font_size,"Times New Roman",Red); longs_allowed=true; open_buys=true; ObjectSet ("open_longs", OBJPROP_XDISTANCE, 140); ObjectSet ("open_longs", OBJPROP_YDISTANCE, 150);} ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// if (ObjectFind("open_shorts") == -1 ) { ObjectCreate("open_shorts", OBJ_LABEL, companion, 0, 0); ObjectSet("open_shorts", OBJPROP_COLOR, Red); ObjectSet("open_shorts", OBJPROP_XDISTANCE, 140); ObjectSet("open_shorts", OBJPROP_YDISTANCE, 180); ObjectSetText("open_shorts","open shorts", 16,"Times New Roman",Orange);} ////////////////////////////////////////////////////////////////////////// if (exit_on_reverse&&signal != "long"&&ObjectGet("open_shorts", OBJPROP_XDISTANCE) != 140) { ObjectSetText("status","status = opening sells", profit_font_size,"Times New Roman",Red); shorts_allowed=true; open_sells=true; ObjectSet ("open_shorts", OBJPROP_XDISTANCE, 140); ObjectSet ("open_shorts", OBJPROP_YDISTANCE, 180);} ////////////////////////////////////////////////////////////////////////// if (exit_on_reverse&&signal == "long")ObjectSetText("open_shorts","open shorts", 16,"Times New Roman",Gray); if (exit_on_reverse&&signal != "long")ObjectSetText("open_shorts","open shorts", 16,"Times New Roman",Orange); if (!exit_on_reverse)ObjectSetText("open_shorts","open shorts", 16,"Times New Roman",Orange); ////////////////////////////////////////////////////////////////////////// if (!exit_on_reverse&&ObjectGet("open_shorts", OBJPROP_XDISTANCE) != 140) { ObjectSetText("status","status = opening sells", profit_font_size,"Times New Roman",Red); shorts_allowed=true; open_sells=true; ObjectSet ("open_shorts", OBJPROP_XDISTANCE, 140); ObjectSet ("open_shorts", OBJPROP_YDISTANCE, 180);} ////////////////////////////////////////////////////////////////////////// if (ObjectFind("close") == -1 ) { ObjectCreate("close", OBJ_LABEL, companion, 0, 0); ObjectSet("close", OBJPROP_COLOR, Red); ObjectSet("close", OBJPROP_XDISTANCE, 290); ObjectSet("close", OBJPROP_YDISTANCE, 115); ObjectSetText("close","close all", 16,"Times New Roman",Red);} if (ObjectGet("close", OBJPROP_XDISTANCE) != 290) { ObjectSetText("status","status = closing all trades", profit_font_size,"Times New Roman",Red); close_all=true; ObjectSet ("close", OBJPROP_XDISTANCE, 290); ObjectSet ("close", OBJPROP_YDISTANCE, 115);} if (ObjectFind("close2") == -1 ) { ObjectCreate("close2", OBJ_LABEL, companion, 0, 0); ObjectSet("close2", OBJPROP_COLOR, Red); ObjectSet("close2", OBJPROP_XDISTANCE, 430); ObjectSet("close2", OBJPROP_YDISTANCE, 115); ObjectSetText("close2","close half", 16,"Times New Roman",Red);} if (ObjectGet("close2", OBJPROP_XDISTANCE) != 430) { close_half(); ObjectSet ("close2", OBJPROP_XDISTANCE, 430); ObjectSet ("close2", OBJPROP_YDISTANCE, 115);} if (ObjectFind("brkev") == -1 ) { ObjectCreate("brkev", OBJ_LABEL, companion, 0, 0); ObjectSet("brkev", OBJPROP_COLOR, Red); ObjectSet("brkev", OBJPROP_XDISTANCE, 430); ObjectSet("brkev", OBJPROP_YDISTANCE, 150); ObjectSetText("brkev","break even", 16,"Times New Roman",Yellow);} if (ObjectGet("brkev", OBJPROP_XDISTANCE) != 430) { breakeven(); ObjectSet ("brkev", OBJPROP_XDISTANCE, 430); ObjectSet ("brkev", OBJPROP_YDISTANCE, 150);} if (ObjectFind("brkev2") == -1 ) { ObjectCreate("brkev2", OBJ_LABEL, companion, 0, 0); ObjectSet("brkev2", OBJPROP_COLOR, Red); ObjectSet("brkev2", OBJPROP_XDISTANCE, 430); ObjectSet("brkev2", OBJPROP_YDISTANCE, 180); ObjectSetText("brkev2","remove stop loss", 16,"Times New Roman",Yellow);} if (ObjectGet("brkev2", OBJPROP_XDISTANCE) != 430) { removesl(); ObjectSet ("brkev2", OBJPROP_XDISTANCE, 430); ObjectSet ("brkev2", OBJPROP_YDISTANCE, 180);} if (ObjectFind("closel") == -1 ) { ObjectCreate("closel", OBJ_LABEL, companion, 0, 0); ObjectSet("closel", OBJPROP_COLOR, Red); ObjectSet("closel", OBJPROP_XDISTANCE, 290); ObjectSet("closel", OBJPROP_YDISTANCE, 150); ObjectSetText("closel","close longs", 16,"Times New Roman",DeepSkyBlue);} if (ObjectGet("closel", OBJPROP_XDISTANCE) != 290) { ObjectSetText("status","status = closing buys", profit_font_size,"Times New Roman",Red); close_l=true; ObjectSet ("closel", OBJPROP_XDISTANCE, 290); ObjectSet ("closel", OBJPROP_YDISTANCE, 150);} if (ObjectFind("closes") == -1 ) { ObjectCreate("closes", OBJ_LABEL, companion, 0, 0); ObjectSet("closes", OBJPROP_COLOR, Red); ObjectSet("closes", OBJPROP_XDISTANCE, 290); ObjectSet("closes", OBJPROP_YDISTANCE, 180); ObjectSetText("closes","close shorts", 16,"Times New Roman",Orange);} if (ObjectGet("closes", OBJPROP_XDISTANCE) != 290) { ObjectSetText("status","status = closing sells", profit_font_size,"Times New Roman",Red); close_s=true; ObjectSet ("closes", OBJPROP_XDISTANCE, 290); ObjectSet ("closes", OBJPROP_YDISTANCE, 180);} if (ObjectFind("etrail") == -1 ) { ObjectCreate("etrail", OBJ_LABEL, companion, 0, 0); ObjectSet("etrail", OBJPROP_COLOR, Red); ObjectSet("etrail", OBJPROP_XDISTANCE, 140); ObjectSet("etrail", OBJPROP_YDISTANCE, 40); ObjectSetText("etrail","equity trail", 16,"Times New Roman",Gray);} if (equity_trail==false&&ObjectGet("etrail", OBJPROP_XDISTANCE) != 140) { equity_trail=true; ObjectSet ("etrail", OBJPROP_XDISTANCE, 140); ObjectSet ("etrail", OBJPROP_YDISTANCE, 40); } if (equity_trail&&ObjectGet("etrail", OBJPROP_XDISTANCE) != 140) { equity_trail=false; ObjectSet ("etrail", OBJPROP_XDISTANCE, 140); ObjectSet ("etrail", OBJPROP_YDISTANCE, 40); } if (equity_trail==false)ObjectSetText("etrail","equity trail= Disabled ", 16,"Times New Roman",Gray); if (equity_trail)ObjectSetText("etrail","equity trail= "+trail2+" start trailing at= "+trail3+"", 16,"Times New Roman",White); if (ObjectFind("lock") == -1 ) { ObjectCreate("lock", OBJ_LABEL, companion, 0, 0); ObjectSet("lock", OBJPROP_COLOR, Red); ObjectSet("lock", OBJPROP_XDISTANCE, 480); ObjectSet("lock", OBJPROP_YDISTANCE, 20); ObjectSetText("lock","lock profit now", 16,"Times New Roman",Orange);} if (ObjectGet("lock", OBJPROP_XDISTANCE) != 480) { //if (pcnt/2>target)target= pcnt/2; if (pcnt-trail>0&&starting_target=0;i--) { OrderSelect(i, SELECT_BY_POS); { if (OrderType() == OP_BUY ) {OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), slippage, Blue ); shorts_allowed=true; } if (OrderType() == OP_SELL ) {OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), slippage, Red ); longs_allowed=true; } } } return; } //+------------------------------------------------------------------+ //| TC //+------------------------------------------------------------------+ void close_half() { ObjectSetText("status","status = closing half lots", profit_font_size,"Times New Roman",Red); int totalorders = OrdersTotal(); for(int i=totalorders-1;i>=0;i--) { OrderSelect(i, SELECT_BY_POS); { if ( OrderType() == OP_BUY ) { OrderClose( OrderTicket(), OrderLots()/2, MarketInfo(OrderSymbol(), MODE_BID), slippage, Blue );} if ( OrderType() == OP_SELL ) { OrderClose( OrderTicket(), OrderLots()/2, MarketInfo(OrderSymbol(), MODE_ASK), slippage, Red );} } } return; } //+------------------------------------------------------------------+ //| TC //+------------------------------------------------------------------+ void close_longs() { shorts_allowed=true; ObjectSetText("status","status = closing buys", profit_font_size,"Times New Roman",Red); open_buys=false;open_sells=false; int totalorders = OrdersTotal(); for(int i=totalorders-1;i>=0;i--) { OrderSelect(i, SELECT_BY_POS); { if (OrderType() == OP_BUY ) OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), slippage, Blue ); } } return; } //+------------------------------------------------------------------+ //| TC //+------------------------------------------------------------------+ void close_shorts() { longs_allowed=true; ObjectSetText("status","status = closing sells", profit_font_size,"Times New Roman",Red); open_buys=false;open_sells=false; int totalorders = OrdersTotal(); for(int i=totalorders-1;i>=0;i--) { OrderSelect(i, SELECT_BY_POS); { if (OrderType() == OP_SELL ) OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), slippage, Red ); } } return; } //+------------------------------------------------------------------+ //| TC //+------------------------------------------------------------------+ void breakeven() { ObjectSetText("status","status = setting breakeven", profit_font_size,"Times New Roman",Red); int totalorders = OrdersTotal(); for(int i=totalorders-1;i>=0;i--) { OrderSelect(i, SELECT_BY_POS); { if ( OrderType() == OP_BUY ) { OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Green); } if ( OrderType() == OP_SELL ) { OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Green); } } } return; } //+------------------------------------------------------------------+ //| TC //+------------------------------------------------------------------+ void removesl() { ObjectSetText("status","status = removing stop loss", profit_font_size,"Times New Roman",Red); int totalorders = OrdersTotal(); for(int i=totalorders-1;i>=0;i--) { OrderSelect(i, SELECT_BY_POS); { if ( OrderType() == OP_BUY ) { OrderModify(OrderTicket(),OrderOpenPrice(),0,OrderTakeProfit(),0,Green); } if ( OrderType() == OP_SELL ) { OrderModify(OrderTicket(),OrderOpenPrice(),0,OrderTakeProfit(),0,Green); } } } return; }