Price Data Components
Orders Execution
0
Views
0
Downloads
0
Favorites
T101 v1.7
//+---------------------------------------------------------------------+
//| T101 v1.7.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 can_trade= false;
extern bool can_exit= true;
bool exit_on_reverse= false;
extern double Lot= 0.01;
extern double Maximum_Risk = 0.5;
extern int look_back= 1;
extern int tf=10080;
extern bool update_start= true;
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;
double target=-10;
double pcnt;
int prob = 0;
bool longs_allowed=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 long_pips, short_pips;string signal;
int gbpusd,eurgbp,gbpjpy,usdchf,nzdusd,audjpy,eurjpy,eurusd,usdjpy,audusd,nzdjpy,gbpchf,chfjpy,eurchf,blue,red;
int init()
{
start();
return(0);
}
int deinit()
{
checkup();
/*
ObjectDelete("1");
ObjectDelete("2");
ObjectDelete("3");
ObjectDelete("4");
ObjectDelete("5");
ObjectDelete("6");
ObjectDelete("7");
ObjectDelete("8");
ObjectDelete("9");
ObjectDelete("10");
ObjectDelete("11");
ObjectDelete("12");
ObjectDelete("13");
ObjectDelete("14");
ObjectDelete("sig");
*/
return(0);
}
int start()
{
if(prob==0) checkup();
if(update_start) checkup();
pcnt =( (AccountEquity()-AccountBalance()) / AccountBalance())*100;
//if (prob==0) {checkup();}
Lot=LotsOptimized();
orders();
if (prob==1&&can_exit){check_exit();}
run_statistics_longs();
run_statistics_shorts();
draw_objects();
signal = "none";
if (blue >red) {signal = "long";}
if (red >blue) {signal = "short";}
if (prob==1&&can_trade&&signal=="long"){buy();}
if (prob==1&&can_trade&&signal=="short"){sell();}
prob=1;
return(0);
}
void checkup(){
if (price1==0)GBPUSDm= iClose(long_basket1, tf, look_back);else GBPUSDm=price1;
if (price2==0)EURGBPm= iClose(long_basket2, tf, look_back);else EURGBPm=price2;
if (price3==0)GBPJPYm= iClose(long_basket3, tf, look_back);else GBPJPYm=price3;
if (price4==0)USDCHFm= iClose(long_basket4, tf, look_back);else USDCHFm=price4;
if (price5==0)NZDUSDm= iClose(long_basket5, tf, look_back);else NZDUSDm=price5;
if (price6==0)AUDJPYm= iClose(long_basket6, tf, look_back);else AUDJPYm=price6;
if (price7==0)EURJPYm= iClose(long_basket7, tf, look_back);else EURJPYm=price7;
if (price8==0)EURUSDm= iClose(short_basket1, tf, look_back);else EURUSDm=price8;
if (price9==0)USDJPYm= iClose(short_basket2, tf, look_back);else USDJPYm=price9;
if (price10==0)AUDUSDm= iClose(short_basket3, tf, look_back);else AUDUSDm=price10;
if (price11==0)NZDJPYm= iClose(short_basket4, tf, look_back);else NZDJPYm=price11;
if (price12==0)GBPCHFm= iClose(short_basket5, tf, look_back);else GBPCHFm=price12;
if (price13==0)CHFJPYm= iClose(short_basket6, tf, look_back);else CHFJPYm=price13;
if (price14==0)EURCHFm= iClose(short_basket7, tf, look_back);else EURCHFm=price14;}
//+------------------------------------------------------------------+
//| TC lots
//+------------------------------------------------------------------+
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);
}
void orders()
{
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 ( 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++;}
if ( OrdersTotal() == 0 ) {target=-10;}
}
return;
}
void buy()
{
if (longs_allowed&&gbpusd==0)OrderSend(long_basket1,OP_BUY, Lot, MarketInfo(long_basket1,MODE_ASK), 2, NULL, NULL, NULL, 0, 0, CLR_NONE);
if (longs_allowed&&eurgbp==0)OrderSend(long_basket2,OP_BUY, Lot, MarketInfo(long_basket2,MODE_ASK), 2, NULL, NULL, NULL, 0, 0, CLR_NONE);
if (longs_allowed&&gbpjpy==0)OrderSend(long_basket3,OP_BUY, Lot, MarketInfo(long_basket3,MODE_ASK), 2, NULL, NULL, NULL, 0, 0, CLR_NONE);
if (longs_allowed&&usdchf==0)OrderSend(long_basket4,OP_BUY, Lot, MarketInfo(long_basket4,MODE_ASK), 2, NULL, NULL, NULL, 0, 0, CLR_NONE);
if (longs_allowed&&nzdusd==0)OrderSend(long_basket5,OP_BUY, Lot, MarketInfo(long_basket5,MODE_ASK), 2, NULL, NULL, NULL, 0, 0, CLR_NONE);
if (longs_allowed&&audjpy==0)OrderSend(long_basket6,OP_BUY, Lot, MarketInfo(long_basket6,MODE_ASK), 2, NULL, NULL, NULL, 0, 0, CLR_NONE);
if (longs_allowed&&eurjpy==0)OrderSend(long_basket7,OP_BUY, Lot, MarketInfo(long_basket7,MODE_ASK), 2, NULL, NULL, NULL, 0, 0, CLR_NONE);
if (longs_allowed&&eurusd==0)OrderSend(short_basket1,OP_BUY, Lot, MarketInfo(short_basket1,MODE_ASK), 2, NULL, NULL, NULL, 0, 0, CLR_NONE);
if (longs_allowed&&usdjpy==0)OrderSend(short_basket2,OP_BUY, Lot, MarketInfo(short_basket2,MODE_ASK), 2, NULL, NULL, NULL, 0, 0, CLR_NONE);
if (longs_allowed&&audusd==0)OrderSend(short_basket3,OP_BUY, Lot, MarketInfo(short_basket3,MODE_ASK), 2, NULL, NULL, NULL, 0, 0, CLR_NONE);
if (longs_allowed&&nzdjpy==0)OrderSend(short_basket4,OP_BUY, Lot, MarketInfo(short_basket4,MODE_ASK), 2, NULL, NULL, NULL, 0, 0, CLR_NONE);
if (longs_allowed&&gbpchf==0)OrderSend(short_basket5,OP_BUY, Lot, MarketInfo(short_basket5,MODE_ASK), 2, NULL, NULL, NULL, 0, 0, CLR_NONE);
if (longs_allowed&&chfjpy==0)OrderSend(short_basket6,OP_BUY, Lot, MarketInfo(short_basket6,MODE_ASK), 2, NULL, NULL, NULL, 0, 0, CLR_NONE);
if (longs_allowed&&eurchf==0)OrderSend(short_basket7,OP_BUY, Lot, MarketInfo(short_basket7,MODE_ASK), 2, NULL, NULL, NULL, 0, 0, CLR_NONE);
shorts_allowed=true;
return;
}
void sell()
{
if (shorts_allowed&&gbpusd==0)OrderSend(long_basket1,OP_SELL, Lot, MarketInfo(long_basket1,MODE_BID), 2, NULL, NULL, NULL, 0, 0, CLR_NONE);
if (shorts_allowed&&eurgbp==0)OrderSend(long_basket2,OP_SELL, Lot, MarketInfo(long_basket2,MODE_BID), 2, NULL, NULL, NULL, 0, 0, CLR_NONE);
if (shorts_allowed&&gbpjpy==0)OrderSend(long_basket3,OP_SELL, Lot, MarketInfo(long_basket3,MODE_BID), 2, NULL, NULL, NULL, 0, 0, CLR_NONE);
if (shorts_allowed&&usdchf==0)OrderSend(long_basket4,OP_SELL, Lot, MarketInfo(long_basket4,MODE_BID), 2, NULL, NULL, NULL, 0, 0, CLR_NONE);
if (shorts_allowed&&nzdusd==0)OrderSend(long_basket5,OP_SELL, Lot, MarketInfo(long_basket5,MODE_BID), 2, NULL, NULL, NULL, 0, 0, CLR_NONE);
if (shorts_allowed&&audjpy==0)OrderSend(long_basket6,OP_SELL, Lot, MarketInfo(long_basket6,MODE_BID), 2, NULL, NULL, NULL, 0, 0, CLR_NONE);
if (shorts_allowed&&eurjpy==0)OrderSend(long_basket7,OP_SELL, Lot, MarketInfo(long_basket7,MODE_BID), 2, NULL, NULL, NULL, 0, 0, CLR_NONE);
if (shorts_allowed&&eurusd==0)OrderSend(short_basket1,OP_SELL, Lot, MarketInfo(short_basket1,MODE_BID), 2, NULL, NULL, NULL, 0, 0, CLR_NONE);
if (shorts_allowed&&usdjpy==0)OrderSend(short_basket2,OP_SELL, Lot, MarketInfo(short_basket2,MODE_BID), 2, NULL, NULL, NULL, 0, 0, CLR_NONE);
if (shorts_allowed&&audusd==0)OrderSend(short_basket3,OP_SELL, Lot, MarketInfo(short_basket3,MODE_BID), 2, NULL, NULL, NULL, 0, 0, CLR_NONE);
if (shorts_allowed&&nzdjpy==0)OrderSend(short_basket4,OP_SELL, Lot, MarketInfo(short_basket4,MODE_BID), 2, NULL, NULL, NULL, 0, 0, CLR_NONE);
if (shorts_allowed&&gbpchf==0)OrderSend(short_basket5,OP_SELL, Lot, MarketInfo(short_basket5,MODE_BID), 2, NULL, NULL, NULL, 0, 0, CLR_NONE);
if (shorts_allowed&&chfjpy==0)OrderSend(short_basket6,OP_SELL, Lot, MarketInfo(short_basket6,MODE_BID), 2, NULL, NULL, NULL, 0, 0, CLR_NONE);
if (shorts_allowed&&eurchf==0)OrderSend(short_basket7,OP_SELL, Lot, MarketInfo(short_basket7,MODE_BID), 2, NULL, NULL, NULL, 0, 0, CLR_NONE);
longs_allowed=true;
return;
}
void check_exit()
{
int totalorders = OrdersTotal();
for(int i=totalorders-1;i>=0;i--)
{
OrderSelect(i, SELECT_BY_POS);
{
if (pcnt>=1&&target==-10 )target=0.5 ;
if (pcnt>=2 &&target==0.5)target=1 ;
if (pcnt>=3&&target==1 )target=2 ;
if (pcnt>=4 &&target==2)target=3 ;
if (pcnt>=5 &&target==3)target=4 ;
if (pcnt>=6 &&target==4)target=5 ;
if (pcnt>=7 &&target==5)target=6 ;
if (pcnt>=8 &&target==6)target=7 ;
if (pcnt>=9 &&target==7)target=8;
if (pcnt>=10 &&target==8)target=9 ;
if (pcnt>=11 &&target==9)target=10 ;
if (pcnt>=12&&target==10 )target=11 ;
if (pcnt>=13 &&target==11)target=12 ;
if (pcnt>=14&&target==12 )target=13 ;
if (pcnt>=15 &&target==13)target=14 ;
if (pcnt>=16 &&target==14)target=15 ;
if (pcnt>=17 &&target==15)target=16 ;
if (pcnt>=18 &&target==16)target=17 ;
if (pcnt>=19 &&target==17)target=18 ;
if (pcnt>=20&&target==18 )target=19 ;
if (pcnt>=21 &&target==19)target=20 ;
if (pcnt>=22 &&target==20)target=21 ;
if (pcnt>=23 &&target==21)target=22 ;
if (pcnt>=24 &&target==22)target=23 ;
if (pcnt>=25 &&target==23)target=24 ;
if (pcnt>=26 &&target==24)target=25 ;
if (pcnt>=27 &&target==25)target=26 ;
if (pcnt>=28 &&target==26)target=27 ;
if (pcnt>=29 &&target==27)target=28 ;
if (pcnt>=30 &&target==28)target=29 ;
if (pcnt>=31 &&target==29)target=30 ;
if (pcnt>=32&&target==30 )target=31 ;
if (pcnt>=33 &&target==31)target=32 ;
if (pcnt>=40 &&target==32)target=39 ;
if (pcnt<=target&&OrderType() == OP_BUY )
{OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );if (OrdersTotal()==0)target=-10;longs_allowed=false;}
if (pcnt<=target&&OrderType() == OP_SELL )
{OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red );if (OrdersTotal()==0)target=-10;shorts_allowed=false;}
if (exit_on_reverse&&signal== "short"&&OrderType() == OP_BUY )
{OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );if (OrdersTotal()==0)target=-10;longs_allowed=false;}
if (exit_on_reverse&&signal== "long"&&OrderType() == OP_SELL )
{OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red );if (OrdersTotal()==0)target=-10;shorts_allowed=false;}
}
}
return;
}
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;
return;
}
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;
return;
}
void draw_objects()
{
int companion =WindowFind("trendchaser_companion");
if (companion == -1)companion=0;
blue=0;red=0;
string PairsDisplay[14];
color PairsColor[14];
double PLArray[14];
PLArray[0]=GBPUSDm_pips;PLArray[1]=EURGBPm_pips;PLArray[2]=GBPCHFm_pips;PLArray[3]=CHFJPYm_pips;PLArray[4]=AUDJPYm_pips;PLArray[5]=EURJPYm_pips;
PLArray[6]=USDCHFm_pips;PLArray[7]=NZDJPYm_pips;PLArray[8]=AUDUSDm_pips;PLArray[9]=USDJPYm_pips;PLArray[10]=EURUSDm_pips;
PLArray[11]=EURCHFm_pips;PLArray[12]=GBPJPYm_pips;PLArray[13]=NZDUSDm_pips;
ArraySort(PLArray,WHOLE_ARRAY,0,MODE_DESCEND);
for(int i=0;i<=13;i++)
{
if(GBPUSDm_pips==PLArray[i])
{
PairsDisplay[i] = ""+long_basket1+"";
PairsColor[i] = Green;
if (GBPUSDm_pips>0) 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, 140);
ObjectSet("sig", OBJPROP_YDISTANCE, 100);}
if (signal == "long"){ObjectSetText("sig","Signal= Buy", 16,"Times New Roman",Blue);shorts_allowed=true;}
if (signal == "short"){ObjectSetText("sig","Signal= Sell", 16,"Times New Roman",Red);longs_allowed=true;}
if (signal == "none"){ObjectSetText("sig","Signal= Sell", 16,"Times New Roman",Gray);longs_allowed=true;shorts_allowed=true;}
/*
double 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, 360);}
ObjectSetText("tot","Total= "+total+"", 16,"Times New Roman",Yellow);
*/
string pcnt2 = DoubleToStr(pcnt,2);
string target2 = DoubleToStr(target,2);
if (ObjectFind("pc") == -1 ){
ObjectCreate("pc", OBJ_LABEL, companion, 0, 0);
ObjectSet("pc", OBJPROP_COLOR, Red);
ObjectSet("pc", OBJPROP_XDISTANCE, 140);
ObjectSet("pc", OBJPROP_YDISTANCE, 16);}
ObjectSetText("pc","Profit = "+pcnt2+" %", profit_font_size,"Times New Roman",Yellow);
if (ObjectFind("trgt") == -1 ){
ObjectCreate("trgt", OBJ_LABEL, companion, 0, 0);
ObjectSet("trgt", OBJPROP_COLOR, Red);
ObjectSet("trgt", OBJPROP_XDISTANCE, 140);
ObjectSet("trgt", OBJPROP_YDISTANCE, 70);}
ObjectSetText("trgt","Target = "+target2+" %", 16,"Times New Roman",White);
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 (ObjectGet("open_longs", OBJPROP_XDISTANCE) != 140)
{
longs_allowed=true;
buy();
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 (ObjectGet("open_shorts", OBJPROP_XDISTANCE) != 140)
{
shorts_allowed=true;
sell();
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, 140);
ObjectSet("close", OBJPROP_YDISTANCE, 210);
ObjectSetText("close","close", 16,"Times New Roman",Red);}
if (ObjectGet("close", OBJPROP_XDISTANCE) != 140)
{
shorts_allowed=true;
close();
ObjectSet ("close", OBJPROP_XDISTANCE, 140);
ObjectSet ("close", OBJPROP_YDISTANCE, 210);}
}
void close()
{
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), 5, Red );
if (OrderType() == OP_SELL )
OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red );
}
}
return;
}
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---