Can some one help me with this indicator. I am not able to make it work.
Thanks
Kris
#property copyright "Es Trader"
#property link "ES Trader @gmail.Com"
#property indicator_separate_window
#property indicator_buffers 6
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_color3 DeepSkyBlue
#property indicator_color4 LightGreen
#property indicator_color5 Orange
#property indicator_color6 Yellow
extern bool ShowComments = False;
extern int Xoffset = 0;
extern int Yoffset = 20;
extern string BGMTO = "Broker GMT Offset";
extern string inst = "Set once during non-Daylight Savings Time";
extern int Broker_GMTOffset = -5;
extern string inst2 = "Set Daylight Savings Time twice per year";
extern bool OnDaylightSavingsTime = True;
extern bool UseSpread = True;
extern bool UsePipCurrencyValue = True;
int StartWeeksBack = 0;
extern bool ShowBuysLine = False;
extern bool ShowSellsLine = False;
extern bool ShowTotalLine = True;
extern bool ShowBuyAllLine = False;
extern bool ShowSellAllLine = False;
extern bool DrawObjects = True;
extern color BuyPairs_Color = DeepSkyBlue;
extern color SellPairs_Color = Red;
extern color Positive_Color = DeepSkyBlue;
extern color Negative_Color = Red;
extern bool ShowIndividualGainsLosses = True;
string Pair_Suffix = "",shortname;
int GMTStartHour,BrokerStartHour,StartBar,myXoffset,myYoffset,a=0;
datetime GMT_Time,StartBarOpenTime,Broker_WeekOpenTime,GMT_Forex_WeekOpenTime,Forex_WeekOpenTime_ThisBroker,StartBarTime,EndTime;
bool BuyAllAlertDone,SellAllAlertDone,ExitBuyAlertDone,ExitSellAlertDone;
string TotalProfitBuys,TotalProfitSells,TotalP_L,IfBuyAll_Value,IfSellAll_Value;
color TotalProfitBuysColor,TotalProfitSellsColor,TotalProfitBuyAllColor,TotalProfitSellAllColor;
double BuysSpreadCostTotal,SellsSpreadCostTotal,SpreadCostTotal,LotsForIndis,LastBid;
int BrokerTZ; //zznbrm
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];
double ExtMapBuffer6[];
string Pair[6];
double PairPip[6];
double PairSpread[6];
double PairPipValuePerLot[6];
double PairSpreadCost[6];
datetime PairStartTime[6];
double PairStartAsk[6];
double PairStartBid[6];
datetime PairEndTime[6];
double PairEndAsk[6];
double PairEndBid[6];
double Buys[6];
double Sells[6];
double BuysIfSold[6];
double SellsIfBought[6];
double SortingArray[6];
color PairColor[6];
string Position[6];
string PairValue[6];
int digits[6];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
SetLevelValue(0,0);
shortname="T101 IA indi";
IndicatorShortName(shortname);
SetIndexStyle(0,DRAW_LINE);
SetIndexLabel (0, "Buys");
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_LINE);
SetIndexLabel (1, "Sells");
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexStyle(2,DRAW_LINE);
SetIndexLabel (2, "Buys and Sells Total");
SetIndexBuffer(2,ExtMapBuffer3);
SetIndexStyle(3,DRAW_LINE);
SetIndexLabel (3, "Total If Buying All");
SetIndexBuffer(3,ExtMapBuffer4);
SetIndexStyle(4,DRAW_LINE);
SetIndexLabel (4, "Total If Selling All");
SetIndexBuffer(4,ExtMapBuffer5);
SetIndexStyle(5,DRAW_LINE);
SetIndexLabel (5, "20 LWMA on Buys and Sells Total");
SetIndexBuffer(5,ExtMapBuffer6);
BrokerTZ = getBrokerTZ(); //zznbrm
ChooseT101PairSet();
DefinePipForEachPair();
//----
return(0);
}
//----
int deinit() {
ObjectsDeleteAll(0);
Comment("");
return(0);
}
//+------------------------------------------------------------------+
//| Accumulation/Distribution |
//+------------------------------------------------------------------+
int start()
{
/*
for(j=0;j<6;j++) {
PairStartTime[j] = iTime(Pair[j],0,iBarShift(Pair[j],0,StartBarTime));
}
*/
if(ShowComments == False) {
myXoffset = Xoffset+0;
myYoffset = Yoffset+0;
} else if(ShowComments == True) {
myXoffset = Xoffset+850;
myYoffset = Yoffset+0;
}
//For comments, to make sure Broker_GMTOffset is correct
if(OnDaylightSavingsTime == True) {
GMT_Time = (TimeCurrent()+(((-Broker_GMTOffset)-1)*60*60));
} else {
GMT_Time = (TimeCurrent()+((-Broker_GMTOffset)*60*60));
}
int OneSecond = 1;
int OneMinute = 60*OneSecond;
int OneHour = 60*OneMinute;
if(OnDaylightSavingsTime == True) {
int DSTOffset = 1;
} else {
DSTOffset = 0;
}
//From http://www.forexmarkethours.com/ :
//Forex market welcomes traders 24 hours a day.
//Forex market opens on Sunday 5 pm EST (10:00 pm GMT), closes on Friday 5 pm EST (10:00 pm GMT).
Broker_WeekOpenTime = calcWeekStart( TimeCurrent(), BrokerTZ ); //zznbrm
GMT_Forex_WeekOpenTime = Broker_WeekOpenTime+((22-TimeHour(Broker_WeekOpenTime))*OneHour);// We add 22 hours to 00:00 GMT to make 22:00 GMT, which is 10 PM GMT, which is Forex week start time per ForexMarketHours.com.
Forex_WeekOpenTime_ThisBroker = GMT_Forex_WeekOpenTime + (Broker_GMTOffset*OneHour)+(DSTOffset*OneHour);// We add Broker GMT Offset to GMT Forex Week Open Time, plus 1 hour if broker adheres to Daylight Savings Time, to get the Forex Week Open Time for This Broker.
StartBar = iBarShift(NULL,0,Forex_WeekOpenTime_ThisBroker);
StartBarTime = iTime(NULL,0,StartBar);
if(StartBarTime < Forex_WeekOpenTime_ThisBroker) {
StartBar = iBarShift(NULL,0,Forex_WeekOpenTime_ThisBroker)-1;
StartBarTime = iTime(NULL,0,StartBar);
} else {
StartBar = iBarShift(NULL,0,Forex_WeekOpenTime_ThisBroker);
StartBarTime = iTime(NULL,0,StartBar);
}
if(Time[0] == StartBarTime && Bars > a) {
for(int m = Bars;m>=0;m--) {
ExtMapBuffer1[m] = 0;
ExtMapBuffer2[m] = 0;
ExtMapBuffer3[m] = 0;
ExtMapBuffer4[m] = 0;
ExtMapBuffer5[m] = 0;
ExtMapBuffer6[m] = 0;
ObjectsDeleteAll();
Comment("");
a=Bars;
}
}
if(ObjectFind("Start Time of Trades") == -1) {
ObjectCreate("Start Time of Trades",OBJ_VLINE,0,StartBarTime,0);
ObjectSet("Start Time of Trades",OBJPROP_COLOR,Green);
} else {
ObjectSet("Start Time of Trades",OBJPROP_TIME1,StartBarTime);
}
for(int j=0;j<6;j++) {
PairStartTime[j] = iTime(Pair[j],0,iBarShift(Pair[j],0,StartBarTime));
PairEndTime[j] = iTime(Pair[j],0,0);
}
EndTime = TimeCurrent();
for(int i=StartBar; i>=0; i--) {
DefineSpread();
for(j=0;j<6;j++) {
PairStartAsk[j] = iOpen(Pair[j],0,StartBar)+(PairSpread[j]*PairPip[j]);
PairStartBid[j] = iOpen(Pair[j],0,StartBar);
PairEndAsk[j] = iClose(Pair[j],0,i)+(PairSpread[j]*PairPip[j]);
PairEndBid[j] = iClose(Pair[j],0,i);
}
//For Buy pairs, subtract starting price (artificial Ask from start of week) from ending price (Bid now), then divide by 100 (if JPY pair), then multiply by 10000, to get pips gained or lost as whole numbers.
//For Sell pairs, subtract ending price (Ask now) from starting price (Bid from start of week), then divide by 100 (if JPY pair), then multiply by 10000, to get pips gained or lost as whole numbers.
for(j=0;j<3;j++) {
if( StringFind(Pair[j],"JPY",0)!=-1) {
Buys[j] = ((PairEndBid[j]-PairStartAsk[j])/100)*10000;
BuysIfSold[j] = ((PairStartBid[j]-PairEndAsk[j])/100)*10000;
} else {
Buys[j] = (PairEndBid[j]-PairStartAsk[j])*10000;
BuysIfSold[j] = (PairStartBid[j]-PairEndAsk[j])*10000;
}
}
for(j=3;j<6;j++) {
if( StringFind(Pair[j],"JPY",0)!=-1) {
Sells[j] = ((PairStartBid[j]-PairEndAsk[j])/100)*10000;
SellsIfBought[j] = ((PairEndBid[j]-PairStartAsk[j])/100)*10000;
} else {
Sells[j] = (PairStartBid[j]-PairEndAsk[j])*10000;
SellsIfBought[j] = (PairEndBid[j]-PairStartAsk[j])*10000;
}
}
if(MarketInfo(Symbol(),MODE_LOTSIZE) == 100000) LotsForIndis = 0.1;
else if(MarketInfo(Symbol(),MODE_LOTSIZE) == 10000) LotsForIndis = 1.0;
else if(MarketInfo(Symbol(),MODE_LOTSIZE) == 1000) LotsForIndis = 10.0;
if(UsePipCurrencyValue == True) {
DefinePipValuePerLotForEachPair();
for (j=0;j<6;j++) {
PairSpreadCost[j] = PairSpread[j]*PairPipValuePerLot[j]*LotsForIndis;
}
for(j=0;j<3;j++) {
Buys[j] = Buys[j]*PairPipValuePerLot[j]*LotsForIndis;
BuysIfSold[j] = BuysIfSold[j]*PairPipValuePerLot[j]*LotsForIndis;
}
for(j=3;j<6;j++) {
Sells[j] = Sells[j]*PairPipValuePerLot[j]*LotsForIndis;
SellsIfBought[j] = SellsIfBought[j]*PairPipValuePerLot[j]*LotsForIndis;
}
}
double sum_Buys=0;
double sum_BuysIfSold=0;
double sum_Sells=0;
double sum_SellsIfBought=0;
for(j=0;j<3;j++) {
sum_Buys = sum_Buys+Buys[j];
sum_BuysIfSold = sum_BuysIfSold+BuysIfSold[j];
}
for(j=3;j<6;j++) {
sum_Sells = sum_Sells+Sells[j];
sum_SellsIfBought = sum_SellsIfBought+SellsIfBought[j];
}
double sum_BuysSpread=0;
double sum_SellsSpread=0;
double sum_Spread=0;
for(j=0;j<3;j++) {
sum_BuysSpread = sum_BuysSpread+PairSpread[j];
}
for(j=3;j<6;j++) {
sum_SellsSpread = sum_SellsSpread+PairSpread[j];
}
for(j=0;j<6;j++) {
sum_Spread = sum_Spread+PairSpread[j];
}
if(ShowBuysLine == True) ExtMapBuffer1[i] = sum_Buys;
if(ShowSellsLine == True) ExtMapBuffer2[i] = sum_Sells;
if(ShowTotalLine == True) ExtMapBuffer3[i] = sum_Buys+sum_Sells;
if(ShowBuyAllLine == True) ExtMapBuffer4[i] = sum_Buys+sum_SellsIfBought;
if(ShowSellAllLine == True) ExtMapBuffer5[i] = sum_BuysIfSold+sum_Sells;
BuysSpreadCostTotal = PairSpreadCost[0]+PairSpreadCost[1]+PairSpreadCost[2]+PairSpreadCost[3];
SellsSpreadCostTotal = PairSpreadCost[4]+PairSpreadCost[5];
SpreadCostTotal = BuysSpreadCostTotal+SellsSpreadCostTotal;
//Make an array, that will keep all the most recent values (pips gained or lost) from the above calculations for each pair
ArrayInitialize(SortingArray,0.0);
//fill the first 3 places, 0-2, with Buy pairs' gains
for (j=0;j<3;j++) {
SortingArray[j] = Buys[j];
}
//fill the second 3 places, 3-5, with Sell pairs' gains
for (j=3;j<6;j++) {
SortingArray[j] = Sells[j];
}
//Sort the values in the array from most gain to most loss
ArraySort(SortingArray,WHOLE_ARRAY,0,MODE_DESCEND);
ReassociatePairsWithArray();
//Give color to those values (objects created below) depending on if a Buy Pair (BuyPairs_color) or Sell pair (SellPairs_color)
for(j=0;j<6;j++) {
if(Position[j] == Pair[0] || Position[j] == Pair[1] || Position[j] == Pair[2] || Position[j] == Pair[3]) {
PairColor[j] = BuyPairs_Color;
} else {
PairColor[j] = SellPairs_Color;
}
}
//Make strings of the above information to fill the Objects created below
if(UsePipCurrencyValue == False) {
int cvround = 0;
} else {
cvround = 2;
}
for (j=0;j<6;j++) {
PairValue[j] = DoubleToStr(SortingArray[j],cvround);
}
TotalProfitBuys = DoubleToStr(sum_Buys,2);
TotalProfitSells = DoubleToStr(sum_Sells,2);
TotalP_L = DoubleToStr(sum_Buys+sum_Sells,2);
IfBuyAll_Value = DoubleToStr(sum_Buys+sum_SellsIfBought,2);
IfSellAll_Value = DoubleToStr(sum_BuysIfSold+sum_Sells,2);
}
if(ShowTotalLine == True) {
if(StartBar > 20) StartBar -= 20;
//Do the Moving Average
for(i = StartBar; i >= 0; i--) {
ExtMapBuffer6[i] = iMAOnArray(ExtMapBuffer3,0,20,0,MODE_LWMA,i);
}
}
if(StrToDouble(TotalProfitBuys) > 0) TotalProfitBuysColor = Positive_Color;
else if(StrToDouble(TotalProfitBuys) < 0) TotalProfitBuysColor = Negative_Color;
else if(StrToDouble(TotalProfitBuys) == 0) TotalProfitBuysColor = White;
if(StrToDouble(TotalProfitSells) > 0) TotalProfitSellsColor = Positive_Color;
else if(StrToDouble(TotalProfitSells) < 0) TotalProfitSellsColor = Negative_Color;
else if(StrToDouble(TotalProfitSells) == 0) TotalProfitSellsColor = White;
if(StrToDouble(IfBuyAll_Value) > 0) TotalProfitBuyAllColor = Positive_Color;
else if(StrToDouble(IfBuyAll_Value) < 0) TotalProfitBuyAllColor = Negative_Color;
else if(StrToDouble(IfBuyAll_Value) == 0) TotalProfitBuyAllColor = White;
if(StrToDouble(IfSellAll_Value) > 0) TotalProfitSellAllColor = Positive_Color;
else if(StrToDouble(IfSellAll_Value) < 0) TotalProfitSellAllColor = Negative_Color;
else if(StrToDouble(IfSellAll_Value) == 0) TotalProfitSellAllColor = White;
if(ShowComments == True) {
ShowCommentsThen();
}
if(DrawObjects == True) {
DrawObjectsThen();
}
if(LastBid != ExtMapBuffer4[0]) LastBid = ExtMapBuffer4[0];
//----
return(0);
}
//+------------------------------------------------------------------+
void ChooseT101PairSet() {
Pair_Suffix=StringSubstr(Symbol(),6,StringLen(Symbol())-6);
Pair[0] = "EURJPY"+Pair_Suffix;
Pair[1] = "USDCHF"+Pair_Suffix;
Pair[2] = "GBPUSD"+Pair_Suffix;
Pair[3] = "EURUSD"+Pair_Suffix;
Pair[4] = "USDJPY"+Pair_Suffix;
Pair[5] = "GBPCHF"+Pair_Suffix;
return;
}
void DefinePipForEachPair() {
for(int j=0;j<6;j++) {
if(Point == 0.0001 || Point == 0.01) {
PairPip[j] = MarketInfo(Pair[j],MODE_POINT);
} else if(Point == 0.00001 || Point == 0.001) {
PairPip[j] = MarketInfo(Pair[j],MODE_POINT)*10;
}
}
return;
}
void DefineSpread() {
if(UseSpread == True) {
for(int j=0;j<6;j++) {
if(Point == 0.00001 || Point == 0.001) {
PairSpread[j] = NormalizeDouble(MarketInfo(Pair[j],MODE_SPREAD)/10,1);
} else if(Point == 0.0001 || Point == 0.01) {
PairSpread[j] = NormalizeDouble(MarketInfo(Pair[j],MODE_SPREAD),0);
}
}
} else {
for(j=0;j<6;j++) {
PairSpread[j] = 0;
}
}
return;
}
void DefinePipValuePerLotForEachPair() {
for(int j=0;j<6;j++) {
if(Point == 0.0001 || Point == 0.01) {
PairPipValuePerLot[j] = MarketInfo(Pair[j], MODE_TICKVALUE);
} else if(Point == 0.00001 || Point == 0.001) {
PairPipValuePerLot[j] = MarketInfo(Pair[j], MODE_TICKVALUE)*10;
}
}
return;
}
void ShowCommentsThen() {
if((PairEndTime[0]+(Period()*60)-60) > TimeCurrent()) PairEndTime[0] = TimeCurrent();
else PairEndTime[0] = (PairEndTime[0]+(Period()*60)-60);
for(int j=0;j<6;j++) {
digits[j] = MarketInfo(Pair[j],MODE_DIGITS);
}
Comment(
"---------------------------------------" + "\n" +
"For real GMT Time, check: http://wwp.greenwichmeantime.com/" + "\n" +
"User inputs are correct if real GMT Time is: " + TimeToStr(GMT_Time) + "\n" +
"Broker GMT Offset = " + Broker_GMTOffset + " (user input)" + "\n" +
"On Daylight Savings Time = " + OnDaylightSavingsTime + " (user input)" + "\n" +
"---------------------------------------" + "\n" +
"Broker Server Time Now = " + TimeToStr(TimeCurrent()) + "\n" +
"---------------------------------------" + "\n" +
"Forex Week Open Time In GMT Time = " + TimeToStr(GMT_Forex_WeekOpenTime) + "\n" +
"Forex Week Open Time On This Broker = " + TimeToStr(Forex_WeekOpenTime_ThisBroker) + "\n" +
"StartBar = " + StartBar + "\n" +
"---------------------------------------" + "\n" +
Pair[0]+": " + "Open Bar Open Time = " + TimeToStr(PairStartTime[0]) + ", Open Price (faux Ask) = " + DoubleToStr(PairStartAsk[0],digits[0]) + ", Close Bar Close Time = " + TimeToStr(PairEndTime[0]) + ", Close Price (Bid) = " + DoubleToStr(PairEndBid[0],digits[0]) + ", Pair Gain/Loss = " + DoubleToStr(Buys[0],2) + ", Spread = " + DoubleToStr(PairSpread[0],0) + "\n" +
Pair[1]+": " + "Open Bar Open Time = " + TimeToStr(PairStartTime[1]) + ", Open Price (faux Ask) = " + DoubleToStr(PairStartAsk[1],digits[1]) + ", Close Bar Close Time = " + TimeToStr(PairEndTime[0]) + ", Close Price (Bid) = " + DoubleToStr(PairEndBid[1],digits[1]) + ", Pair Gain/Loss = " + DoubleToStr(Buys[1],2) + ", Spread = " + DoubleToStr(PairSpread[1],0) + "\n" +
Pair[2]+": " + "Open Bar Open Time = " + TimeToStr(PairStartTime[2]) + ", Open Price (faux Ask) = " + DoubleToStr(PairStartAsk[2],digits[2]) + ", Close Bar Close Time = " + TimeToStr(PairEndTime[0]) + ", Close Price (Bid) = " + DoubleToStr(PairEndBid[2],digits[2]) + ", Pair Gain/Loss = " + DoubleToStr(Buys[2],2) + ", Spread = " + DoubleToStr(PairSpread[2],0) + "\n" +
"------------------------------------" + "\n" +
Pair[4]+": " + "Open Bar Open Time = " + TimeToStr(PairStartTime[4]) + ", Open Price (Bid) = " + DoubleToStr(PairStartBid[4],digits[4]) + ", Close Bar Close Time = " + TimeToStr(PairEndTime[0]) + ", Close Price (Ask) = " + DoubleToStr(PairEndAsk[4],digits[4]) + ", Pair Gain/Loss = " + DoubleToStr(Sells[4],2) + ", Spread = " + DoubleToStr(PairSpread[4],0) + "\n" +
Pair[5]+": " + "Open Bar Open Time = " + TimeToStr(PairStartTime[5]) + ", Open Price (Bid) = " + DoubleToStr(PairStartBid[5],digits[5]) + ", Close Bar Close Time = " + TimeToStr(PairEndTime[0]) + ", Close Price (Ask) = " + DoubleToStr(PairEndAsk[5],digits[5]) + ", Pair Gain/Loss = " + DoubleToStr(Sells[5],2) + ", Spread = " + DoubleToStr(PairSpread[5],0) + "\n" +
Pair[6]+": " + "Open Bar Open Time = " + TimeToStr(PairStartTime[6]) + ", Open Price (Bid) = " + DoubleToStr(PairStartBid[6],digits[6]) + ", Close Bar Close Time = " + TimeToStr(PairEndTime[0]) + ", Close Price (Ask) = " + DoubleToStr(PairEndAsk[6],digits[6]) + ", Pair Gain/Loss = " + DoubleToStr(Sells[6],2) + ", Spread = " + DoubleToStr(PairSpread[6],0) + "\n" +
"------------------------------------" + "\n" +
"Buys Profit = " + DoubleToStr(ExtMapBuffer1[0],2) + "\n" +
"Sells Profit = " + DoubleToStr(ExtMapBuffer2[0],2) + "\n" +
"Buys and Sells Total Profit = " + DoubleToStr(ExtMapBuffer3[0],2) + "\n" +
"LastBid = " + DoubleToStr(LastBid,2) + "\n" +
"Total Profit If Buying All = " + DoubleToStr(ExtMapBuffer4[0],2) + "\n" +
"Total Profit If Selling All = " + DoubleToStr(ExtMapBuffer5[0],2)
);
return;
}
void ReassociatePairsWithArray() { //Re-associate the values in the array with the pairs the values belong to
if(SortingArray[0] == Buys[0]) {
Position[0] = Pair[0];
} else if(SortingArray[0] == Buys[1]) {
Position[0] = Pair[1];
} else if(SortingArray[0] == Buys[2]) {
Position[0] = Pair[2];
} else if(SortingArray[0] == Buys[3]) {
Position[0] = Pair[3];
} else if(SortingArray[0] == Sells[4]) {
Position[0] = Pair[4];
} else if(SortingArray[0] == Sells[5]) {
Position[0] = Pair[5];
}
if(SortingArray[1] == Buys[0]) {
Position[1] = Pair[0];
} else if(SortingArray[1] == Buys[1]) {
Position[1] = Pair[1];
} else if(SortingArray[1] == Buys[2]) {
Position[1] = Pair[2];
} else if(SortingArray[1] == Buys[3]) {
Position[1] = Pair[3];
} else if(SortingArray[1] == Sells[4]) {
Position[1] = Pair[4];
} else if(SortingArray[1] == Sells[5]) {
Position[1] = Pair[5];
}
if(SortingArray[2] == Buys[0]) {
Position[2] = Pair[0];
} else if(SortingArray[2] == Buys[1]) {
Position[2] = Pair[1];
} else if(SortingArray[2] == Buys[2]) {
Position[2] = Pair[2];
} else if(SortingArray[2] == Buys[3]) {
Position[2] = Pair[3];
} else if(SortingArray[2] == Sells[4]) {
Position[2] = Pair[4];
} else if(SortingArray[2] == Sells[5]) {
Position[2] = Pair[5];
}
if(SortingArray[3] == Buys[0]) {
Position[3] = Pair[0];
} else if(SortingArray[3] == Buys[1]) {
Position[3] = Pair[1];
} else if(SortingArray[3] == Buys[2]) {
Position[3] = Pair[2];
} else if(SortingArray[3] == Buys[3]) {
Position[3] = Pair[3];
} else if(SortingArray[3] == Sells[4]) {
Position[3] = Pair[4];
} else if(SortingArray[3] == Sells[5]) {
Position[3] = Pair[5];
}
if(SortingArray[4] == Buys[0]) {
Position[4] = Pair[0];
} else if(SortingArray[4] == Buys[1]) {
Position[4] = Pair[1];
} else if(SortingArray[4] == Buys[2]) {
Position[4] = Pair[2];
} else if(SortingArray[4] == Buys[3]) {
Position[4] = Pair[3];
} else if(SortingArray[4] == Sells[4]) {
Position[4] = Pair[4];
} else if(SortingArray[4] == Sells[5]) {
Position[4] = Pair[5];
}
if(SortingArray[5] == Buys[0]) {
Position[5] = Pair[0];
} else if(SortingArray[5] == Buys[1]) {
Position[5] = Pair[1];
} else if(SortingArray[5] == Buys[2]) {
Position[5] = Pair[2];
} else if(SortingArray[5] == Buys[3]) {
Position[5] = Pair[3];
} else if(SortingArray[5] == Sells[4]) {
Position[5] = Pair[4];
} else if(SortingArray[5] == Sells[5]) {
Position[5] = Pair[5];
}
if(SortingArray[6] == Buys[0]) {
Position[6] = Pair[0];
} else if(SortingArray[6] == Buys[1]) {
Position[6] = Pair[1];
} else if(SortingArray[6] == Buys[2]) {
Position[6] = Pair[2];
} else if(SortingArray[6] == Buys[3]) {
Position[6] = Pair[3];
} else if(SortingArray[6] == Sells[4]) {
Position[6] = Pair[4];
} else if(SortingArray[6] == Sells[5]) {
Position[6] = Pair[5];
}
if(SortingArray[7] == Buys[0]) {
Position[7] = Pair[0];
} else if(SortingArray[7] == Buys[1]) {
Position[7] = Pair[1];
} else if(SortingArray[7] == Buys[2]) {
Position[7] = Pair[2];
} else if(SortingArray[7] == Buys[3]) {
Position[7] = Pair[3];
} else if(SortingArray[7] == Sells[4]) {
Position[7] = Pair[4];
} else if(SortingArray[7] == Sells[5]) {
Position[7] = Pair[5];
}
return;
}
void DrawObjectsThen() {
//ObjectsDeleteAll();
ObjectCreate(shortname + "50", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "50"," StartTime:"+TimeToStr(PairStartTime[0]),7, "Arial Bold", White);
ObjectSet(shortname + "50", OBJPROP_CORNER, 0);
ObjectSet(shortname + "50", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "50", OBJPROP_YDISTANCE, 0+myYoffset);
ObjectCreate(shortname + "51", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "51"," EndTime:"+TimeToStr(PairEndTime[0]),7, "Arial Bold", White);
ObjectSet(shortname + "51", OBJPROP_CORNER, 0);
ObjectSet(shortname + "51", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "51", OBJPROP_YDISTANCE, 12+myYoffset);
ObjectCreate(shortname + "3", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "3",StringSubstr(Position[0],0),12, "Arial Bold", PairColor[0]);
ObjectSet(shortname + "3", OBJPROP_CORNER, 0);
ObjectSet(shortname + "3", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "3", OBJPROP_YDISTANCE, 25+myYoffset);
if(ShowIndividualGainsLosses == True) {
ObjectCreate(shortname + "4", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "4",StringSubstr(PairValue[0],0),12, "Arial Bold", PairColor[0]);
ObjectSet(shortname + "4", OBJPROP_CORNER, 0);
ObjectSet(shortname + "4", OBJPROP_XDISTANCE, 105+myXoffset);
ObjectSet(shortname + "4", OBJPROP_YDISTANCE, 25+myYoffset);
}
ObjectCreate(shortname + "5", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "5",StringSubstr(Position[1],0),12, "Arial Bold", PairColor[1]);
ObjectSet(shortname + "5", OBJPROP_CORNER, 0);
ObjectSet(shortname + "5", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "5", OBJPROP_YDISTANCE, 40+myYoffset);
if(ShowIndividualGainsLosses == True) {
ObjectCreate(shortname + "6", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "6",StringSubstr(PairValue[1],0),12, "Arial Bold", PairColor[1]);
ObjectSet(shortname + "6", OBJPROP_CORNER, 0);
ObjectSet(shortname + "6", OBJPROP_XDISTANCE, 105+myXoffset);
ObjectSet(shortname + "6", OBJPROP_YDISTANCE, 40+myYoffset);
}
ObjectCreate(shortname + "7", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "7",StringSubstr(Position[2],0),12, "Arial Bold", PairColor[2]);
ObjectSet(shortname + "7", OBJPROP_CORNER, 0);
ObjectSet(shortname + "7", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "7", OBJPROP_YDISTANCE, 55+myYoffset);
if(ShowIndividualGainsLosses == True) {
ObjectCreate(shortname + "8", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "8",StringSubstr(PairValue[2],0),12, "Arial Bold", PairColor[2]);
ObjectSet(shortname + "8", OBJPROP_CORNER, 0);
ObjectSet(shortname + "8", OBJPROP_XDISTANCE, 105+myXoffset);
ObjectSet(shortname + "8", OBJPROP_YDISTANCE, 55+myYoffset);
}
ObjectCreate(shortname + "9", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "9",StringSubstr(Position[3],0),12, "Arial Bold", PairColor[3]);
ObjectSet(shortname + "9", OBJPROP_CORNER, 0);
ObjectSet(shortname + "9", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "9", OBJPROP_YDISTANCE, 70+myYoffset);
if(ShowIndividualGainsLosses == True) {
ObjectCreate(shortname + "10", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "10",StringSubstr(PairValue[3],0),12, "Arial Bold", PairColor[3]);
ObjectSet(shortname + "10", OBJPROP_CORNER, 0);
ObjectSet(shortname + "10", OBJPROP_XDISTANCE, 105+myXoffset);
ObjectSet(shortname + "10", OBJPROP_YDISTANCE, 70+myYoffset);
}
if(ShowIndividualGainsLosses == False) {
ObjectCreate(shortname + "49", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "49","--------------",12, "Arial Bold", White);
ObjectSet(shortname + "49", OBJPROP_CORNER, 0);
ObjectSet(shortname + "49", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "49", OBJPROP_YDISTANCE, 75+myYoffset);
} else if(ShowIndividualGainsLosses == True) {
ObjectCreate(shortname + "49", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "49","------------------------------",12, "Arial Bold", White);
ObjectSet(shortname + "49", OBJPROP_CORNER, 0);
ObjectSet(shortname + "49", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "49", OBJPROP_YDISTANCE, 75+myYoffset);
}
ObjectCreate(shortname + "11", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "11",StringSubstr(Position[4],0),12, "Arial Bold", PairColor[4]);
ObjectSet(shortname + "11", OBJPROP_CORNER, 0);
ObjectSet(shortname + "11", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "11", OBJPROP_YDISTANCE, 85+myYoffset);
if(ShowIndividualGainsLosses == True) {
ObjectCreate(shortname + "12", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "12",StringSubstr(PairValue[4],0),12, "Arial Bold", PairColor[4]);
ObjectSet(shortname + "12", OBJPROP_CORNER, 0);
ObjectSet(shortname + "12", OBJPROP_XDISTANCE, 105+myXoffset);
ObjectSet(shortname + "12", OBJPROP_YDISTANCE, 85+myYoffset);
}
ObjectCreate(shortname + "13", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "13",StringSubstr(Position[5],0),12, "Arial Bold", PairColor[5]);
ObjectSet(shortname + "13", OBJPROP_CORNER, 0);
ObjectSet(shortname + "13", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "13", OBJPROP_YDISTANCE, 100+myYoffset);
if(ShowIndividualGainsLosses == True) {
ObjectCreate(shortname + "14", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "14",StringSubstr(PairValue[5],0),12, "Arial Bold", PairColor[5]);
ObjectSet(shortname + "14", OBJPROP_CORNER, 0);
ObjectSet(shortname + "14", OBJPROP_XDISTANCE, 105+myXoffset);
ObjectSet(shortname + "14", OBJPROP_YDISTANCE, 100+myYoffset);
}
ObjectCreate(shortname + "15", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "15",StringSubstr(Position[6],0),12, "Arial Bold", PairColor[6]);
ObjectSet(shortname + "15", OBJPROP_CORNER, 0);
ObjectSet(shortname + "15", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "15", OBJPROP_YDISTANCE, 115+myYoffset);
if(ShowIndividualGainsLosses == True) {
ObjectCreate(shortname + "16", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "16",StringSubstr(PairValue[6],0),12, "Arial Bold", PairColor[6]);
ObjectSet(shortname + "16", OBJPROP_CORNER, 0);
ObjectSet(shortname + "16", OBJPROP_XDISTANCE, 105+myXoffset);
ObjectSet(shortname + "16", OBJPROP_YDISTANCE, 115+myYoffset);
}
ObjectCreate(shortname + "17", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "17",StringSubstr(Position[7],0),12, "Arial Bold", PairColor[7]);
ObjectSet(shortname + "17", OBJPROP_CORNER, 0);
ObjectSet(shortname + "17", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "17", OBJPROP_YDISTANCE, 130+myYoffset);
if(ShowIndividualGainsLosses == True) {
ObjectCreate(shortname + "18", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "18",StringSubstr(PairValue[7],0),12, "Arial Bold", PairColor[7]);
ObjectSet(shortname + "18", OBJPROP_CORNER, 0);
ObjectSet(shortname + "18", OBJPROP_XDISTANCE, 105+myXoffset);
ObjectSet(shortname + "18", OBJPROP_YDISTANCE, 130+myYoffset);
}
ObjectCreate(shortname + "31", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "31",StringSubstr("Buys Profit",0),12, "Arial Bold", White);
ObjectSet(shortname + "31", OBJPROP_CORNER, 0);
ObjectSet(shortname + "31", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "31", OBJPROP_YDISTANCE, 150+myYoffset);
ObjectCreate(shortname + "32", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "32",StringSubstr(TotalProfitBuys,0),12, "Arial Bold", TotalProfitBuysColor);
ObjectSet(shortname + "32", OBJPROP_CORNER, 0);
ObjectSet(shortname + "32", OBJPROP_XDISTANCE, 105+myXoffset);
ObjectSet(shortname + "32", OBJPROP_YDISTANCE, 150+myYoffset);
ObjectCreate(shortname + "33", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "33",StringSubstr("Sells Profit",0),12, "Arial Bold", White);
ObjectSet(shortname + "33", OBJPROP_CORNER, 0);
ObjectSet(shortname + "33", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "33", OBJPROP_YDISTANCE, 165+myYoffset);
ObjectCreate(shortname + "34", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "34",StringSubstr(TotalProfitSells,0),12, "Arial Bold", TotalProfitSellsColor);
ObjectSet(shortname + "34", OBJPROP_CORNER, 0);
ObjectSet(shortname + "34", OBJPROP_XDISTANCE, 105+myXoffset);
ObjectSet(shortname + "34", OBJPROP_YDISTANCE, 165+myYoffset);
ObjectCreate(shortname + "35", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "35",StringSubstr("Total P/L",0),12, "Arial Bold", White);
ObjectSet(shortname + "35", OBJPROP_CORNER, 0);
ObjectSet(shortname + "35", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "35", OBJPROP_YDISTANCE, 180+myYoffset);
ObjectCreate(shortname + "36", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "36",StringSubstr(TotalP_L,0),12, "Arial Bold", White);
ObjectSet(shortname + "36", OBJPROP_CORNER, 0);
ObjectSet(shortname + "36", OBJPROP_XDISTANCE, 105+myXoffset);
ObjectSet(shortname + "36", OBJPROP_YDISTANCE, 180+myYoffset);
ObjectCreate(shortname + "39", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "39",StringSubstr("Buys Spread",0),12, "Arial Bold", White);
ObjectSet(shortname + "39", OBJPROP_CORNER, 0);
ObjectSet(shortname + "39", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "39", OBJPROP_YDISTANCE, 195+myYoffset);
ObjectCreate(shortname + "40", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "40",DoubleToStr(BuysSpreadCostTotal,2),12, "Arial Bold", White);
ObjectSet(shortname + "40", OBJPROP_CORNER, 0);
ObjectSet(shortname + "40", OBJPROP_XDISTANCE, 105+myXoffset);
ObjectSet(shortname + "40", OBJPROP_YDISTANCE, 195+myYoffset);
ObjectCreate(shortname + "41", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "41",StringSubstr("Sells Spread",0),12, "Arial Bold", White);
ObjectSet(shortname + "41", OBJPROP_CORNER, 0);
ObjectSet(shortname + "41", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "41", OBJPROP_YDISTANCE, 210+myYoffset);
ObjectCreate(shortname + "42", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "42",DoubleToStr(SellsSpreadCostTotal,2),12, "Arial Bold", White);
ObjectSet(shortname + "42", OBJPROP_CORNER, 0);
ObjectSet(shortname + "42", OBJPROP_XDISTANCE, 105+myXoffset);
ObjectSet(shortname + "42", OBJPROP_YDISTANCE, 210+myYoffset);
ObjectCreate(shortname + "43", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "43",StringSubstr("Total Spread",0),12, "Arial Bold", White);
ObjectSet(shortname + "43", OBJPROP_CORNER, 0);
ObjectSet(shortname + "43", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "43", OBJPROP_YDISTANCE, 225+myYoffset);
ObjectCreate(shortname + "44", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "44",DoubleToStr(SpreadCostTotal,2),12, "Arial Bold", White);
ObjectSet(shortname + "44", OBJPROP_CORNER, 0);
ObjectSet(shortname + "44", OBJPROP_XDISTANCE, 105+myXoffset);
ObjectSet(shortname + "44", OBJPROP_YDISTANCE, 225+myYoffset);
ObjectCreate(shortname + "45", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "45",StringSubstr("Buy All P/L",0),12, "Arial Bold", White);
ObjectSet(shortname + "45", OBJPROP_CORNER, 0);
ObjectSet(shortname + "45", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "45", OBJPROP_YDISTANCE, 240+myYoffset);
ObjectCreate(shortname + "46", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "46",IfBuyAll_Value,12, "Arial Bold", TotalProfitBuyAllColor);
ObjectSet(shortname + "46", OBJPROP_CORNER, 0);
ObjectSet(shortname + "46", OBJPROP_XDISTANCE, 105+myXoffset);
ObjectSet(shortname + "46", OBJPROP_YDISTANCE, 240+myYoffset);
ObjectCreate(shortname + "47", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "47",StringSubstr("Sell All P/L ",0),12, "Arial Bold", White);
ObjectSet(shortname + "47", OBJPROP_CORNER, 0);
ObjectSet(shortname + "47", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "47", OBJPROP_YDISTANCE, 255+myYoffset);
ObjectCreate(shortname + "48", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "48",IfSellAll_Value,12, "Arial Bold", TotalProfitSellAllColor);
ObjectSet(shortname + "48", OBJPROP_CORNER, 0);
ObjectSet(shortname + "48", OBJPROP_XDISTANCE, 105+myXoffset);
ObjectSet(shortname + "48", OBJPROP_YDISTANCE, 255+myYoffset);
return;
}
#include <zznbrm.datetime.mqh> //zznbrm
Thanks
Kris
#property copyright "Es Trader"
#property link "ES Trader @gmail.Com"
#property indicator_separate_window
#property indicator_buffers 6
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_color3 DeepSkyBlue
#property indicator_color4 LightGreen
#property indicator_color5 Orange
#property indicator_color6 Yellow
extern bool ShowComments = False;
extern int Xoffset = 0;
extern int Yoffset = 20;
extern string BGMTO = "Broker GMT Offset";
extern string inst = "Set once during non-Daylight Savings Time";
extern int Broker_GMTOffset = -5;
extern string inst2 = "Set Daylight Savings Time twice per year";
extern bool OnDaylightSavingsTime = True;
extern bool UseSpread = True;
extern bool UsePipCurrencyValue = True;
int StartWeeksBack = 0;
extern bool ShowBuysLine = False;
extern bool ShowSellsLine = False;
extern bool ShowTotalLine = True;
extern bool ShowBuyAllLine = False;
extern bool ShowSellAllLine = False;
extern bool DrawObjects = True;
extern color BuyPairs_Color = DeepSkyBlue;
extern color SellPairs_Color = Red;
extern color Positive_Color = DeepSkyBlue;
extern color Negative_Color = Red;
extern bool ShowIndividualGainsLosses = True;
string Pair_Suffix = "",shortname;
int GMTStartHour,BrokerStartHour,StartBar,myXoffset,myYoffset,a=0;
datetime GMT_Time,StartBarOpenTime,Broker_WeekOpenTime,GMT_Forex_WeekOpenTime,Forex_WeekOpenTime_ThisBroker,StartBarTime,EndTime;
bool BuyAllAlertDone,SellAllAlertDone,ExitBuyAlertDone,ExitSellAlertDone;
string TotalProfitBuys,TotalProfitSells,TotalP_L,IfBuyAll_Value,IfSellAll_Value;
color TotalProfitBuysColor,TotalProfitSellsColor,TotalProfitBuyAllColor,TotalProfitSellAllColor;
double BuysSpreadCostTotal,SellsSpreadCostTotal,SpreadCostTotal,LotsForIndis,LastBid;
int BrokerTZ; //zznbrm
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];
double ExtMapBuffer6[];
string Pair[6];
double PairPip[6];
double PairSpread[6];
double PairPipValuePerLot[6];
double PairSpreadCost[6];
datetime PairStartTime[6];
double PairStartAsk[6];
double PairStartBid[6];
datetime PairEndTime[6];
double PairEndAsk[6];
double PairEndBid[6];
double Buys[6];
double Sells[6];
double BuysIfSold[6];
double SellsIfBought[6];
double SortingArray[6];
color PairColor[6];
string Position[6];
string PairValue[6];
int digits[6];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
SetLevelValue(0,0);
shortname="T101 IA indi";
IndicatorShortName(shortname);
SetIndexStyle(0,DRAW_LINE);
SetIndexLabel (0, "Buys");
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_LINE);
SetIndexLabel (1, "Sells");
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexStyle(2,DRAW_LINE);
SetIndexLabel (2, "Buys and Sells Total");
SetIndexBuffer(2,ExtMapBuffer3);
SetIndexStyle(3,DRAW_LINE);
SetIndexLabel (3, "Total If Buying All");
SetIndexBuffer(3,ExtMapBuffer4);
SetIndexStyle(4,DRAW_LINE);
SetIndexLabel (4, "Total If Selling All");
SetIndexBuffer(4,ExtMapBuffer5);
SetIndexStyle(5,DRAW_LINE);
SetIndexLabel (5, "20 LWMA on Buys and Sells Total");
SetIndexBuffer(5,ExtMapBuffer6);
BrokerTZ = getBrokerTZ(); //zznbrm
ChooseT101PairSet();
DefinePipForEachPair();
//----
return(0);
}
//----
int deinit() {
ObjectsDeleteAll(0);
Comment("");
return(0);
}
//+------------------------------------------------------------------+
//| Accumulation/Distribution |
//+------------------------------------------------------------------+
int start()
{
/*
for(j=0;j<6;j++) {
PairStartTime[j] = iTime(Pair[j],0,iBarShift(Pair[j],0,StartBarTime));
}
*/
if(ShowComments == False) {
myXoffset = Xoffset+0;
myYoffset = Yoffset+0;
} else if(ShowComments == True) {
myXoffset = Xoffset+850;
myYoffset = Yoffset+0;
}
//For comments, to make sure Broker_GMTOffset is correct
if(OnDaylightSavingsTime == True) {
GMT_Time = (TimeCurrent()+(((-Broker_GMTOffset)-1)*60*60));
} else {
GMT_Time = (TimeCurrent()+((-Broker_GMTOffset)*60*60));
}
int OneSecond = 1;
int OneMinute = 60*OneSecond;
int OneHour = 60*OneMinute;
if(OnDaylightSavingsTime == True) {
int DSTOffset = 1;
} else {
DSTOffset = 0;
}
//From http://www.forexmarkethours.com/ :
//Forex market welcomes traders 24 hours a day.
//Forex market opens on Sunday 5 pm EST (10:00 pm GMT), closes on Friday 5 pm EST (10:00 pm GMT).
Broker_WeekOpenTime = calcWeekStart( TimeCurrent(), BrokerTZ ); //zznbrm
GMT_Forex_WeekOpenTime = Broker_WeekOpenTime+((22-TimeHour(Broker_WeekOpenTime))*OneHour);// We add 22 hours to 00:00 GMT to make 22:00 GMT, which is 10 PM GMT, which is Forex week start time per ForexMarketHours.com.
Forex_WeekOpenTime_ThisBroker = GMT_Forex_WeekOpenTime + (Broker_GMTOffset*OneHour)+(DSTOffset*OneHour);// We add Broker GMT Offset to GMT Forex Week Open Time, plus 1 hour if broker adheres to Daylight Savings Time, to get the Forex Week Open Time for This Broker.
StartBar = iBarShift(NULL,0,Forex_WeekOpenTime_ThisBroker);
StartBarTime = iTime(NULL,0,StartBar);
if(StartBarTime < Forex_WeekOpenTime_ThisBroker) {
StartBar = iBarShift(NULL,0,Forex_WeekOpenTime_ThisBroker)-1;
StartBarTime = iTime(NULL,0,StartBar);
} else {
StartBar = iBarShift(NULL,0,Forex_WeekOpenTime_ThisBroker);
StartBarTime = iTime(NULL,0,StartBar);
}
if(Time[0] == StartBarTime && Bars > a) {
for(int m = Bars;m>=0;m--) {
ExtMapBuffer1[m] = 0;
ExtMapBuffer2[m] = 0;
ExtMapBuffer3[m] = 0;
ExtMapBuffer4[m] = 0;
ExtMapBuffer5[m] = 0;
ExtMapBuffer6[m] = 0;
ObjectsDeleteAll();
Comment("");
a=Bars;
}
}
if(ObjectFind("Start Time of Trades") == -1) {
ObjectCreate("Start Time of Trades",OBJ_VLINE,0,StartBarTime,0);
ObjectSet("Start Time of Trades",OBJPROP_COLOR,Green);
} else {
ObjectSet("Start Time of Trades",OBJPROP_TIME1,StartBarTime);
}
for(int j=0;j<6;j++) {
PairStartTime[j] = iTime(Pair[j],0,iBarShift(Pair[j],0,StartBarTime));
PairEndTime[j] = iTime(Pair[j],0,0);
}
EndTime = TimeCurrent();
for(int i=StartBar; i>=0; i--) {
DefineSpread();
for(j=0;j<6;j++) {
PairStartAsk[j] = iOpen(Pair[j],0,StartBar)+(PairSpread[j]*PairPip[j]);
PairStartBid[j] = iOpen(Pair[j],0,StartBar);
PairEndAsk[j] = iClose(Pair[j],0,i)+(PairSpread[j]*PairPip[j]);
PairEndBid[j] = iClose(Pair[j],0,i);
}
//For Buy pairs, subtract starting price (artificial Ask from start of week) from ending price (Bid now), then divide by 100 (if JPY pair), then multiply by 10000, to get pips gained or lost as whole numbers.
//For Sell pairs, subtract ending price (Ask now) from starting price (Bid from start of week), then divide by 100 (if JPY pair), then multiply by 10000, to get pips gained or lost as whole numbers.
for(j=0;j<3;j++) {
if( StringFind(Pair[j],"JPY",0)!=-1) {
Buys[j] = ((PairEndBid[j]-PairStartAsk[j])/100)*10000;
BuysIfSold[j] = ((PairStartBid[j]-PairEndAsk[j])/100)*10000;
} else {
Buys[j] = (PairEndBid[j]-PairStartAsk[j])*10000;
BuysIfSold[j] = (PairStartBid[j]-PairEndAsk[j])*10000;
}
}
for(j=3;j<6;j++) {
if( StringFind(Pair[j],"JPY",0)!=-1) {
Sells[j] = ((PairStartBid[j]-PairEndAsk[j])/100)*10000;
SellsIfBought[j] = ((PairEndBid[j]-PairStartAsk[j])/100)*10000;
} else {
Sells[j] = (PairStartBid[j]-PairEndAsk[j])*10000;
SellsIfBought[j] = (PairEndBid[j]-PairStartAsk[j])*10000;
}
}
if(MarketInfo(Symbol(),MODE_LOTSIZE) == 100000) LotsForIndis = 0.1;
else if(MarketInfo(Symbol(),MODE_LOTSIZE) == 10000) LotsForIndis = 1.0;
else if(MarketInfo(Symbol(),MODE_LOTSIZE) == 1000) LotsForIndis = 10.0;
if(UsePipCurrencyValue == True) {
DefinePipValuePerLotForEachPair();
for (j=0;j<6;j++) {
PairSpreadCost[j] = PairSpread[j]*PairPipValuePerLot[j]*LotsForIndis;
}
for(j=0;j<3;j++) {
Buys[j] = Buys[j]*PairPipValuePerLot[j]*LotsForIndis;
BuysIfSold[j] = BuysIfSold[j]*PairPipValuePerLot[j]*LotsForIndis;
}
for(j=3;j<6;j++) {
Sells[j] = Sells[j]*PairPipValuePerLot[j]*LotsForIndis;
SellsIfBought[j] = SellsIfBought[j]*PairPipValuePerLot[j]*LotsForIndis;
}
}
double sum_Buys=0;
double sum_BuysIfSold=0;
double sum_Sells=0;
double sum_SellsIfBought=0;
for(j=0;j<3;j++) {
sum_Buys = sum_Buys+Buys[j];
sum_BuysIfSold = sum_BuysIfSold+BuysIfSold[j];
}
for(j=3;j<6;j++) {
sum_Sells = sum_Sells+Sells[j];
sum_SellsIfBought = sum_SellsIfBought+SellsIfBought[j];
}
double sum_BuysSpread=0;
double sum_SellsSpread=0;
double sum_Spread=0;
for(j=0;j<3;j++) {
sum_BuysSpread = sum_BuysSpread+PairSpread[j];
}
for(j=3;j<6;j++) {
sum_SellsSpread = sum_SellsSpread+PairSpread[j];
}
for(j=0;j<6;j++) {
sum_Spread = sum_Spread+PairSpread[j];
}
if(ShowBuysLine == True) ExtMapBuffer1[i] = sum_Buys;
if(ShowSellsLine == True) ExtMapBuffer2[i] = sum_Sells;
if(ShowTotalLine == True) ExtMapBuffer3[i] = sum_Buys+sum_Sells;
if(ShowBuyAllLine == True) ExtMapBuffer4[i] = sum_Buys+sum_SellsIfBought;
if(ShowSellAllLine == True) ExtMapBuffer5[i] = sum_BuysIfSold+sum_Sells;
BuysSpreadCostTotal = PairSpreadCost[0]+PairSpreadCost[1]+PairSpreadCost[2]+PairSpreadCost[3];
SellsSpreadCostTotal = PairSpreadCost[4]+PairSpreadCost[5];
SpreadCostTotal = BuysSpreadCostTotal+SellsSpreadCostTotal;
//Make an array, that will keep all the most recent values (pips gained or lost) from the above calculations for each pair
ArrayInitialize(SortingArray,0.0);
//fill the first 3 places, 0-2, with Buy pairs' gains
for (j=0;j<3;j++) {
SortingArray[j] = Buys[j];
}
//fill the second 3 places, 3-5, with Sell pairs' gains
for (j=3;j<6;j++) {
SortingArray[j] = Sells[j];
}
//Sort the values in the array from most gain to most loss
ArraySort(SortingArray,WHOLE_ARRAY,0,MODE_DESCEND);
ReassociatePairsWithArray();
//Give color to those values (objects created below) depending on if a Buy Pair (BuyPairs_color) or Sell pair (SellPairs_color)
for(j=0;j<6;j++) {
if(Position[j] == Pair[0] || Position[j] == Pair[1] || Position[j] == Pair[2] || Position[j] == Pair[3]) {
PairColor[j] = BuyPairs_Color;
} else {
PairColor[j] = SellPairs_Color;
}
}
//Make strings of the above information to fill the Objects created below
if(UsePipCurrencyValue == False) {
int cvround = 0;
} else {
cvround = 2;
}
for (j=0;j<6;j++) {
PairValue[j] = DoubleToStr(SortingArray[j],cvround);
}
TotalProfitBuys = DoubleToStr(sum_Buys,2);
TotalProfitSells = DoubleToStr(sum_Sells,2);
TotalP_L = DoubleToStr(sum_Buys+sum_Sells,2);
IfBuyAll_Value = DoubleToStr(sum_Buys+sum_SellsIfBought,2);
IfSellAll_Value = DoubleToStr(sum_BuysIfSold+sum_Sells,2);
}
if(ShowTotalLine == True) {
if(StartBar > 20) StartBar -= 20;
//Do the Moving Average
for(i = StartBar; i >= 0; i--) {
ExtMapBuffer6[i] = iMAOnArray(ExtMapBuffer3,0,20,0,MODE_LWMA,i);
}
}
if(StrToDouble(TotalProfitBuys) > 0) TotalProfitBuysColor = Positive_Color;
else if(StrToDouble(TotalProfitBuys) < 0) TotalProfitBuysColor = Negative_Color;
else if(StrToDouble(TotalProfitBuys) == 0) TotalProfitBuysColor = White;
if(StrToDouble(TotalProfitSells) > 0) TotalProfitSellsColor = Positive_Color;
else if(StrToDouble(TotalProfitSells) < 0) TotalProfitSellsColor = Negative_Color;
else if(StrToDouble(TotalProfitSells) == 0) TotalProfitSellsColor = White;
if(StrToDouble(IfBuyAll_Value) > 0) TotalProfitBuyAllColor = Positive_Color;
else if(StrToDouble(IfBuyAll_Value) < 0) TotalProfitBuyAllColor = Negative_Color;
else if(StrToDouble(IfBuyAll_Value) == 0) TotalProfitBuyAllColor = White;
if(StrToDouble(IfSellAll_Value) > 0) TotalProfitSellAllColor = Positive_Color;
else if(StrToDouble(IfSellAll_Value) < 0) TotalProfitSellAllColor = Negative_Color;
else if(StrToDouble(IfSellAll_Value) == 0) TotalProfitSellAllColor = White;
if(ShowComments == True) {
ShowCommentsThen();
}
if(DrawObjects == True) {
DrawObjectsThen();
}
if(LastBid != ExtMapBuffer4[0]) LastBid = ExtMapBuffer4[0];
//----
return(0);
}
//+------------------------------------------------------------------+
void ChooseT101PairSet() {
Pair_Suffix=StringSubstr(Symbol(),6,StringLen(Symbol())-6);
Pair[0] = "EURJPY"+Pair_Suffix;
Pair[1] = "USDCHF"+Pair_Suffix;
Pair[2] = "GBPUSD"+Pair_Suffix;
Pair[3] = "EURUSD"+Pair_Suffix;
Pair[4] = "USDJPY"+Pair_Suffix;
Pair[5] = "GBPCHF"+Pair_Suffix;
return;
}
void DefinePipForEachPair() {
for(int j=0;j<6;j++) {
if(Point == 0.0001 || Point == 0.01) {
PairPip[j] = MarketInfo(Pair[j],MODE_POINT);
} else if(Point == 0.00001 || Point == 0.001) {
PairPip[j] = MarketInfo(Pair[j],MODE_POINT)*10;
}
}
return;
}
void DefineSpread() {
if(UseSpread == True) {
for(int j=0;j<6;j++) {
if(Point == 0.00001 || Point == 0.001) {
PairSpread[j] = NormalizeDouble(MarketInfo(Pair[j],MODE_SPREAD)/10,1);
} else if(Point == 0.0001 || Point == 0.01) {
PairSpread[j] = NormalizeDouble(MarketInfo(Pair[j],MODE_SPREAD),0);
}
}
} else {
for(j=0;j<6;j++) {
PairSpread[j] = 0;
}
}
return;
}
void DefinePipValuePerLotForEachPair() {
for(int j=0;j<6;j++) {
if(Point == 0.0001 || Point == 0.01) {
PairPipValuePerLot[j] = MarketInfo(Pair[j], MODE_TICKVALUE);
} else if(Point == 0.00001 || Point == 0.001) {
PairPipValuePerLot[j] = MarketInfo(Pair[j], MODE_TICKVALUE)*10;
}
}
return;
}
void ShowCommentsThen() {
if((PairEndTime[0]+(Period()*60)-60) > TimeCurrent()) PairEndTime[0] = TimeCurrent();
else PairEndTime[0] = (PairEndTime[0]+(Period()*60)-60);
for(int j=0;j<6;j++) {
digits[j] = MarketInfo(Pair[j],MODE_DIGITS);
}
Comment(
"---------------------------------------" + "\n" +
"For real GMT Time, check: http://wwp.greenwichmeantime.com/" + "\n" +
"User inputs are correct if real GMT Time is: " + TimeToStr(GMT_Time) + "\n" +
"Broker GMT Offset = " + Broker_GMTOffset + " (user input)" + "\n" +
"On Daylight Savings Time = " + OnDaylightSavingsTime + " (user input)" + "\n" +
"---------------------------------------" + "\n" +
"Broker Server Time Now = " + TimeToStr(TimeCurrent()) + "\n" +
"---------------------------------------" + "\n" +
"Forex Week Open Time In GMT Time = " + TimeToStr(GMT_Forex_WeekOpenTime) + "\n" +
"Forex Week Open Time On This Broker = " + TimeToStr(Forex_WeekOpenTime_ThisBroker) + "\n" +
"StartBar = " + StartBar + "\n" +
"---------------------------------------" + "\n" +
Pair[0]+": " + "Open Bar Open Time = " + TimeToStr(PairStartTime[0]) + ", Open Price (faux Ask) = " + DoubleToStr(PairStartAsk[0],digits[0]) + ", Close Bar Close Time = " + TimeToStr(PairEndTime[0]) + ", Close Price (Bid) = " + DoubleToStr(PairEndBid[0],digits[0]) + ", Pair Gain/Loss = " + DoubleToStr(Buys[0],2) + ", Spread = " + DoubleToStr(PairSpread[0],0) + "\n" +
Pair[1]+": " + "Open Bar Open Time = " + TimeToStr(PairStartTime[1]) + ", Open Price (faux Ask) = " + DoubleToStr(PairStartAsk[1],digits[1]) + ", Close Bar Close Time = " + TimeToStr(PairEndTime[0]) + ", Close Price (Bid) = " + DoubleToStr(PairEndBid[1],digits[1]) + ", Pair Gain/Loss = " + DoubleToStr(Buys[1],2) + ", Spread = " + DoubleToStr(PairSpread[1],0) + "\n" +
Pair[2]+": " + "Open Bar Open Time = " + TimeToStr(PairStartTime[2]) + ", Open Price (faux Ask) = " + DoubleToStr(PairStartAsk[2],digits[2]) + ", Close Bar Close Time = " + TimeToStr(PairEndTime[0]) + ", Close Price (Bid) = " + DoubleToStr(PairEndBid[2],digits[2]) + ", Pair Gain/Loss = " + DoubleToStr(Buys[2],2) + ", Spread = " + DoubleToStr(PairSpread[2],0) + "\n" +
"------------------------------------" + "\n" +
Pair[4]+": " + "Open Bar Open Time = " + TimeToStr(PairStartTime[4]) + ", Open Price (Bid) = " + DoubleToStr(PairStartBid[4],digits[4]) + ", Close Bar Close Time = " + TimeToStr(PairEndTime[0]) + ", Close Price (Ask) = " + DoubleToStr(PairEndAsk[4],digits[4]) + ", Pair Gain/Loss = " + DoubleToStr(Sells[4],2) + ", Spread = " + DoubleToStr(PairSpread[4],0) + "\n" +
Pair[5]+": " + "Open Bar Open Time = " + TimeToStr(PairStartTime[5]) + ", Open Price (Bid) = " + DoubleToStr(PairStartBid[5],digits[5]) + ", Close Bar Close Time = " + TimeToStr(PairEndTime[0]) + ", Close Price (Ask) = " + DoubleToStr(PairEndAsk[5],digits[5]) + ", Pair Gain/Loss = " + DoubleToStr(Sells[5],2) + ", Spread = " + DoubleToStr(PairSpread[5],0) + "\n" +
Pair[6]+": " + "Open Bar Open Time = " + TimeToStr(PairStartTime[6]) + ", Open Price (Bid) = " + DoubleToStr(PairStartBid[6],digits[6]) + ", Close Bar Close Time = " + TimeToStr(PairEndTime[0]) + ", Close Price (Ask) = " + DoubleToStr(PairEndAsk[6],digits[6]) + ", Pair Gain/Loss = " + DoubleToStr(Sells[6],2) + ", Spread = " + DoubleToStr(PairSpread[6],0) + "\n" +
"------------------------------------" + "\n" +
"Buys Profit = " + DoubleToStr(ExtMapBuffer1[0],2) + "\n" +
"Sells Profit = " + DoubleToStr(ExtMapBuffer2[0],2) + "\n" +
"Buys and Sells Total Profit = " + DoubleToStr(ExtMapBuffer3[0],2) + "\n" +
"LastBid = " + DoubleToStr(LastBid,2) + "\n" +
"Total Profit If Buying All = " + DoubleToStr(ExtMapBuffer4[0],2) + "\n" +
"Total Profit If Selling All = " + DoubleToStr(ExtMapBuffer5[0],2)
);
return;
}
void ReassociatePairsWithArray() { //Re-associate the values in the array with the pairs the values belong to
if(SortingArray[0] == Buys[0]) {
Position[0] = Pair[0];
} else if(SortingArray[0] == Buys[1]) {
Position[0] = Pair[1];
} else if(SortingArray[0] == Buys[2]) {
Position[0] = Pair[2];
} else if(SortingArray[0] == Buys[3]) {
Position[0] = Pair[3];
} else if(SortingArray[0] == Sells[4]) {
Position[0] = Pair[4];
} else if(SortingArray[0] == Sells[5]) {
Position[0] = Pair[5];
}
if(SortingArray[1] == Buys[0]) {
Position[1] = Pair[0];
} else if(SortingArray[1] == Buys[1]) {
Position[1] = Pair[1];
} else if(SortingArray[1] == Buys[2]) {
Position[1] = Pair[2];
} else if(SortingArray[1] == Buys[3]) {
Position[1] = Pair[3];
} else if(SortingArray[1] == Sells[4]) {
Position[1] = Pair[4];
} else if(SortingArray[1] == Sells[5]) {
Position[1] = Pair[5];
}
if(SortingArray[2] == Buys[0]) {
Position[2] = Pair[0];
} else if(SortingArray[2] == Buys[1]) {
Position[2] = Pair[1];
} else if(SortingArray[2] == Buys[2]) {
Position[2] = Pair[2];
} else if(SortingArray[2] == Buys[3]) {
Position[2] = Pair[3];
} else if(SortingArray[2] == Sells[4]) {
Position[2] = Pair[4];
} else if(SortingArray[2] == Sells[5]) {
Position[2] = Pair[5];
}
if(SortingArray[3] == Buys[0]) {
Position[3] = Pair[0];
} else if(SortingArray[3] == Buys[1]) {
Position[3] = Pair[1];
} else if(SortingArray[3] == Buys[2]) {
Position[3] = Pair[2];
} else if(SortingArray[3] == Buys[3]) {
Position[3] = Pair[3];
} else if(SortingArray[3] == Sells[4]) {
Position[3] = Pair[4];
} else if(SortingArray[3] == Sells[5]) {
Position[3] = Pair[5];
}
if(SortingArray[4] == Buys[0]) {
Position[4] = Pair[0];
} else if(SortingArray[4] == Buys[1]) {
Position[4] = Pair[1];
} else if(SortingArray[4] == Buys[2]) {
Position[4] = Pair[2];
} else if(SortingArray[4] == Buys[3]) {
Position[4] = Pair[3];
} else if(SortingArray[4] == Sells[4]) {
Position[4] = Pair[4];
} else if(SortingArray[4] == Sells[5]) {
Position[4] = Pair[5];
}
if(SortingArray[5] == Buys[0]) {
Position[5] = Pair[0];
} else if(SortingArray[5] == Buys[1]) {
Position[5] = Pair[1];
} else if(SortingArray[5] == Buys[2]) {
Position[5] = Pair[2];
} else if(SortingArray[5] == Buys[3]) {
Position[5] = Pair[3];
} else if(SortingArray[5] == Sells[4]) {
Position[5] = Pair[4];
} else if(SortingArray[5] == Sells[5]) {
Position[5] = Pair[5];
}
if(SortingArray[6] == Buys[0]) {
Position[6] = Pair[0];
} else if(SortingArray[6] == Buys[1]) {
Position[6] = Pair[1];
} else if(SortingArray[6] == Buys[2]) {
Position[6] = Pair[2];
} else if(SortingArray[6] == Buys[3]) {
Position[6] = Pair[3];
} else if(SortingArray[6] == Sells[4]) {
Position[6] = Pair[4];
} else if(SortingArray[6] == Sells[5]) {
Position[6] = Pair[5];
}
if(SortingArray[7] == Buys[0]) {
Position[7] = Pair[0];
} else if(SortingArray[7] == Buys[1]) {
Position[7] = Pair[1];
} else if(SortingArray[7] == Buys[2]) {
Position[7] = Pair[2];
} else if(SortingArray[7] == Buys[3]) {
Position[7] = Pair[3];
} else if(SortingArray[7] == Sells[4]) {
Position[7] = Pair[4];
} else if(SortingArray[7] == Sells[5]) {
Position[7] = Pair[5];
}
return;
}
void DrawObjectsThen() {
//ObjectsDeleteAll();
ObjectCreate(shortname + "50", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "50"," StartTime:"+TimeToStr(PairStartTime[0]),7, "Arial Bold", White);
ObjectSet(shortname + "50", OBJPROP_CORNER, 0);
ObjectSet(shortname + "50", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "50", OBJPROP_YDISTANCE, 0+myYoffset);
ObjectCreate(shortname + "51", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "51"," EndTime:"+TimeToStr(PairEndTime[0]),7, "Arial Bold", White);
ObjectSet(shortname + "51", OBJPROP_CORNER, 0);
ObjectSet(shortname + "51", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "51", OBJPROP_YDISTANCE, 12+myYoffset);
ObjectCreate(shortname + "3", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "3",StringSubstr(Position[0],0),12, "Arial Bold", PairColor[0]);
ObjectSet(shortname + "3", OBJPROP_CORNER, 0);
ObjectSet(shortname + "3", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "3", OBJPROP_YDISTANCE, 25+myYoffset);
if(ShowIndividualGainsLosses == True) {
ObjectCreate(shortname + "4", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "4",StringSubstr(PairValue[0],0),12, "Arial Bold", PairColor[0]);
ObjectSet(shortname + "4", OBJPROP_CORNER, 0);
ObjectSet(shortname + "4", OBJPROP_XDISTANCE, 105+myXoffset);
ObjectSet(shortname + "4", OBJPROP_YDISTANCE, 25+myYoffset);
}
ObjectCreate(shortname + "5", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "5",StringSubstr(Position[1],0),12, "Arial Bold", PairColor[1]);
ObjectSet(shortname + "5", OBJPROP_CORNER, 0);
ObjectSet(shortname + "5", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "5", OBJPROP_YDISTANCE, 40+myYoffset);
if(ShowIndividualGainsLosses == True) {
ObjectCreate(shortname + "6", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "6",StringSubstr(PairValue[1],0),12, "Arial Bold", PairColor[1]);
ObjectSet(shortname + "6", OBJPROP_CORNER, 0);
ObjectSet(shortname + "6", OBJPROP_XDISTANCE, 105+myXoffset);
ObjectSet(shortname + "6", OBJPROP_YDISTANCE, 40+myYoffset);
}
ObjectCreate(shortname + "7", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "7",StringSubstr(Position[2],0),12, "Arial Bold", PairColor[2]);
ObjectSet(shortname + "7", OBJPROP_CORNER, 0);
ObjectSet(shortname + "7", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "7", OBJPROP_YDISTANCE, 55+myYoffset);
if(ShowIndividualGainsLosses == True) {
ObjectCreate(shortname + "8", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "8",StringSubstr(PairValue[2],0),12, "Arial Bold", PairColor[2]);
ObjectSet(shortname + "8", OBJPROP_CORNER, 0);
ObjectSet(shortname + "8", OBJPROP_XDISTANCE, 105+myXoffset);
ObjectSet(shortname + "8", OBJPROP_YDISTANCE, 55+myYoffset);
}
ObjectCreate(shortname + "9", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "9",StringSubstr(Position[3],0),12, "Arial Bold", PairColor[3]);
ObjectSet(shortname + "9", OBJPROP_CORNER, 0);
ObjectSet(shortname + "9", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "9", OBJPROP_YDISTANCE, 70+myYoffset);
if(ShowIndividualGainsLosses == True) {
ObjectCreate(shortname + "10", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "10",StringSubstr(PairValue[3],0),12, "Arial Bold", PairColor[3]);
ObjectSet(shortname + "10", OBJPROP_CORNER, 0);
ObjectSet(shortname + "10", OBJPROP_XDISTANCE, 105+myXoffset);
ObjectSet(shortname + "10", OBJPROP_YDISTANCE, 70+myYoffset);
}
if(ShowIndividualGainsLosses == False) {
ObjectCreate(shortname + "49", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "49","--------------",12, "Arial Bold", White);
ObjectSet(shortname + "49", OBJPROP_CORNER, 0);
ObjectSet(shortname + "49", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "49", OBJPROP_YDISTANCE, 75+myYoffset);
} else if(ShowIndividualGainsLosses == True) {
ObjectCreate(shortname + "49", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "49","------------------------------",12, "Arial Bold", White);
ObjectSet(shortname + "49", OBJPROP_CORNER, 0);
ObjectSet(shortname + "49", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "49", OBJPROP_YDISTANCE, 75+myYoffset);
}
ObjectCreate(shortname + "11", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "11",StringSubstr(Position[4],0),12, "Arial Bold", PairColor[4]);
ObjectSet(shortname + "11", OBJPROP_CORNER, 0);
ObjectSet(shortname + "11", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "11", OBJPROP_YDISTANCE, 85+myYoffset);
if(ShowIndividualGainsLosses == True) {
ObjectCreate(shortname + "12", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "12",StringSubstr(PairValue[4],0),12, "Arial Bold", PairColor[4]);
ObjectSet(shortname + "12", OBJPROP_CORNER, 0);
ObjectSet(shortname + "12", OBJPROP_XDISTANCE, 105+myXoffset);
ObjectSet(shortname + "12", OBJPROP_YDISTANCE, 85+myYoffset);
}
ObjectCreate(shortname + "13", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "13",StringSubstr(Position[5],0),12, "Arial Bold", PairColor[5]);
ObjectSet(shortname + "13", OBJPROP_CORNER, 0);
ObjectSet(shortname + "13", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "13", OBJPROP_YDISTANCE, 100+myYoffset);
if(ShowIndividualGainsLosses == True) {
ObjectCreate(shortname + "14", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "14",StringSubstr(PairValue[5],0),12, "Arial Bold", PairColor[5]);
ObjectSet(shortname + "14", OBJPROP_CORNER, 0);
ObjectSet(shortname + "14", OBJPROP_XDISTANCE, 105+myXoffset);
ObjectSet(shortname + "14", OBJPROP_YDISTANCE, 100+myYoffset);
}
ObjectCreate(shortname + "15", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "15",StringSubstr(Position[6],0),12, "Arial Bold", PairColor[6]);
ObjectSet(shortname + "15", OBJPROP_CORNER, 0);
ObjectSet(shortname + "15", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "15", OBJPROP_YDISTANCE, 115+myYoffset);
if(ShowIndividualGainsLosses == True) {
ObjectCreate(shortname + "16", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "16",StringSubstr(PairValue[6],0),12, "Arial Bold", PairColor[6]);
ObjectSet(shortname + "16", OBJPROP_CORNER, 0);
ObjectSet(shortname + "16", OBJPROP_XDISTANCE, 105+myXoffset);
ObjectSet(shortname + "16", OBJPROP_YDISTANCE, 115+myYoffset);
}
ObjectCreate(shortname + "17", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "17",StringSubstr(Position[7],0),12, "Arial Bold", PairColor[7]);
ObjectSet(shortname + "17", OBJPROP_CORNER, 0);
ObjectSet(shortname + "17", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "17", OBJPROP_YDISTANCE, 130+myYoffset);
if(ShowIndividualGainsLosses == True) {
ObjectCreate(shortname + "18", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "18",StringSubstr(PairValue[7],0),12, "Arial Bold", PairColor[7]);
ObjectSet(shortname + "18", OBJPROP_CORNER, 0);
ObjectSet(shortname + "18", OBJPROP_XDISTANCE, 105+myXoffset);
ObjectSet(shortname + "18", OBJPROP_YDISTANCE, 130+myYoffset);
}
ObjectCreate(shortname + "31", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "31",StringSubstr("Buys Profit",0),12, "Arial Bold", White);
ObjectSet(shortname + "31", OBJPROP_CORNER, 0);
ObjectSet(shortname + "31", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "31", OBJPROP_YDISTANCE, 150+myYoffset);
ObjectCreate(shortname + "32", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "32",StringSubstr(TotalProfitBuys,0),12, "Arial Bold", TotalProfitBuysColor);
ObjectSet(shortname + "32", OBJPROP_CORNER, 0);
ObjectSet(shortname + "32", OBJPROP_XDISTANCE, 105+myXoffset);
ObjectSet(shortname + "32", OBJPROP_YDISTANCE, 150+myYoffset);
ObjectCreate(shortname + "33", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "33",StringSubstr("Sells Profit",0),12, "Arial Bold", White);
ObjectSet(shortname + "33", OBJPROP_CORNER, 0);
ObjectSet(shortname + "33", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "33", OBJPROP_YDISTANCE, 165+myYoffset);
ObjectCreate(shortname + "34", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "34",StringSubstr(TotalProfitSells,0),12, "Arial Bold", TotalProfitSellsColor);
ObjectSet(shortname + "34", OBJPROP_CORNER, 0);
ObjectSet(shortname + "34", OBJPROP_XDISTANCE, 105+myXoffset);
ObjectSet(shortname + "34", OBJPROP_YDISTANCE, 165+myYoffset);
ObjectCreate(shortname + "35", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "35",StringSubstr("Total P/L",0),12, "Arial Bold", White);
ObjectSet(shortname + "35", OBJPROP_CORNER, 0);
ObjectSet(shortname + "35", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "35", OBJPROP_YDISTANCE, 180+myYoffset);
ObjectCreate(shortname + "36", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "36",StringSubstr(TotalP_L,0),12, "Arial Bold", White);
ObjectSet(shortname + "36", OBJPROP_CORNER, 0);
ObjectSet(shortname + "36", OBJPROP_XDISTANCE, 105+myXoffset);
ObjectSet(shortname + "36", OBJPROP_YDISTANCE, 180+myYoffset);
ObjectCreate(shortname + "39", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "39",StringSubstr("Buys Spread",0),12, "Arial Bold", White);
ObjectSet(shortname + "39", OBJPROP_CORNER, 0);
ObjectSet(shortname + "39", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "39", OBJPROP_YDISTANCE, 195+myYoffset);
ObjectCreate(shortname + "40", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "40",DoubleToStr(BuysSpreadCostTotal,2),12, "Arial Bold", White);
ObjectSet(shortname + "40", OBJPROP_CORNER, 0);
ObjectSet(shortname + "40", OBJPROP_XDISTANCE, 105+myXoffset);
ObjectSet(shortname + "40", OBJPROP_YDISTANCE, 195+myYoffset);
ObjectCreate(shortname + "41", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "41",StringSubstr("Sells Spread",0),12, "Arial Bold", White);
ObjectSet(shortname + "41", OBJPROP_CORNER, 0);
ObjectSet(shortname + "41", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "41", OBJPROP_YDISTANCE, 210+myYoffset);
ObjectCreate(shortname + "42", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "42",DoubleToStr(SellsSpreadCostTotal,2),12, "Arial Bold", White);
ObjectSet(shortname + "42", OBJPROP_CORNER, 0);
ObjectSet(shortname + "42", OBJPROP_XDISTANCE, 105+myXoffset);
ObjectSet(shortname + "42", OBJPROP_YDISTANCE, 210+myYoffset);
ObjectCreate(shortname + "43", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "43",StringSubstr("Total Spread",0),12, "Arial Bold", White);
ObjectSet(shortname + "43", OBJPROP_CORNER, 0);
ObjectSet(shortname + "43", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "43", OBJPROP_YDISTANCE, 225+myYoffset);
ObjectCreate(shortname + "44", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "44",DoubleToStr(SpreadCostTotal,2),12, "Arial Bold", White);
ObjectSet(shortname + "44", OBJPROP_CORNER, 0);
ObjectSet(shortname + "44", OBJPROP_XDISTANCE, 105+myXoffset);
ObjectSet(shortname + "44", OBJPROP_YDISTANCE, 225+myYoffset);
ObjectCreate(shortname + "45", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "45",StringSubstr("Buy All P/L",0),12, "Arial Bold", White);
ObjectSet(shortname + "45", OBJPROP_CORNER, 0);
ObjectSet(shortname + "45", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "45", OBJPROP_YDISTANCE, 240+myYoffset);
ObjectCreate(shortname + "46", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "46",IfBuyAll_Value,12, "Arial Bold", TotalProfitBuyAllColor);
ObjectSet(shortname + "46", OBJPROP_CORNER, 0);
ObjectSet(shortname + "46", OBJPROP_XDISTANCE, 105+myXoffset);
ObjectSet(shortname + "46", OBJPROP_YDISTANCE, 240+myYoffset);
ObjectCreate(shortname + "47", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "47",StringSubstr("Sell All P/L ",0),12, "Arial Bold", White);
ObjectSet(shortname + "47", OBJPROP_CORNER, 0);
ObjectSet(shortname + "47", OBJPROP_XDISTANCE, 10+myXoffset);
ObjectSet(shortname + "47", OBJPROP_YDISTANCE, 255+myYoffset);
ObjectCreate(shortname + "48", OBJ_LABEL, 0, 0, 0);
ObjectSetText(shortname + "48",IfSellAll_Value,12, "Arial Bold", TotalProfitSellAllColor);
ObjectSet(shortname + "48", OBJPROP_CORNER, 0);
ObjectSet(shortname + "48", OBJPROP_XDISTANCE, 105+myXoffset);
ObjectSet(shortname + "48", OBJPROP_YDISTANCE, 255+myYoffset);
return;
}
#include <zznbrm.datetime.mqh> //zznbrm