Algorithms

Warning! Executing cBots downloaded from this section may result in loss of funds. Use them at your own risk.
Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.
How to install
DescriptionSubmited byDateCategoryPreviewDownloadsCommentsRating
Description: Plots custom period separator.   Updates: 21/06/2016 - Version 1.0 Released.   Screenshot:   Notes: Works on tick charts as well.   Make a Donation: If you like my work and effort then please consider to make a kind donation thru PayPal or any Credit Card via this link.
by tmc.
02 Nov 2016
Downloads
458
Comments
5
Rating
0
Download
La idea inicial de este cbot es abrir ordenes opuestas con un SL definido, de manera que cuando el precio cierre una posición se abran de nuevo 2 posiciones nuevas en hedging con SL definido de nuevo y así succesivamente acumulando beneficio en las posiciones abiertas siempre y cuando el precio no gire de nuevo. Creo que es una muy buena opción para momentos en los que hay mucha volatilidad como por ejemplo en noticias. Como tengo unos conocimientos en programación muy limitados este cbot tiene un problema que no se resolver, si operas en otro mercado mientras esta activo y cerras alguna posición, abre de nuevo 2 posiciones. Espero que alguien pueda ayudarme a mejorar este problema.   using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; namespace cAlgo { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class sergi : Robot { [Parameter("Volume", DefaultValue = 1000)] public int Volume { get; set; } [Parameter("Stop Loss (pips)", DefaultValue = 20, MinValue = 1)] public int StopLossInPips { get; set; } protected override void OnStart() { Positions.Closed += closedposition; ExecuteMarketOrder(TradeType.Buy, Symbol, Volume, "Sergi", StopLossInPips, 0); ExecuteMarketOrder(TradeType.Sell, Symbol, Volume, "Sergi", StopLossInPips, 0); } private void closedposition(PositionClosedEventArgs arg) { var pos = arg.Position; if ((pos.NetProfit < 0)) Positions.Closed -= closedposition; OnStart(); } } }  
27 Oct 2016
Downloads
439
Comments
2
Rating
0
Download
In accordance with the description of the SPUD's theory on the http://www.forexfactory.com/showthread.php?t=37111 indicator shows the corresponding status.
Downloads
855
Comments
0
Rating
0
Download
Hi, This indicator displays the Position info on the Chart over the Position Line.  Kind of visual.  (Courtesy : Charles Layton) Thank you. ///S.Khan    
14 Oct 2016
Downloads
211
Comments
0
Rating
0
Download
Hi, a simple indicator that displays Pair Info on top of the Chart.  Kinda Helpful information for Traders. Information Displayed are : 1. Pips Current and Closed  2. Unrealized and Closed Net P/L 3. Pip Cost  4. Net Vol and Total Count 5. Buy and Sell Volume 6. Buy and Sell Count 7. Profit Factor   Thank you S.Khan  
14 Oct 2016
Downloads
199
Comments
2
Rating
0
Download
Hi, This Indicator basically displays : 1. Displays the PIPS (hourly, daily, weekly, monthly) and 2. Draw Lines through +/- ATR values on the CHART.   Have divided the ATR Value by x (x=1,2,3,4).   And converted it to Pips.  Added these Pips value to "OPEN PRICES" and drawn the lines on Chart. How to USE IT : 1.  Good for Trade :  If the Price has crossed  +D-1/2 ATR  or  -D-1/2 ATR, then it means that this PAIR is good for trading (either Buy or Sell. depending on your other triggers). 2.  Trigger :  After it has crossed Daily ATR lines, then wait for the prices to cross the "Hourly +ve or -ve" ATR line to start trading.  (Direction based on other trigger indicators).   3. Trending :  If Both Weekly ATR lines (+ve or -ve) are above Both the Monthly ATR Lines or vice versa. The Pair is trending. 4. Ranging :   if Daily lines are within Weekly ATR Lines,  and Weekly ATR Line are between the Monthly ATR lines. The Pair is ranging. 5. Short-Term Reversal :  if Price have broken all +ve (-ve)  Daily, Weekly, Monthly ATR lines in single session. *if it was early in ranging setup. 6. OPEN PRICES  :  if Daily Open Price is above Weekly Open Price, and Weekly Open Price is above Monthly Open Price  or vice versa ), then usually this Pair is also in trending mode but ranging setup (#4) will confirm or reject it. Disclaimer : This is not a Holy grail. Please use this for short-term inter-day trading.  And keep Take Profit as per 15-min ATR value in Pips. And keep Stop Loss outside 1-Hr ATR Line.  Leave your comments and feedback, so a cBOT can also be developed. Hope it helps other too who want to know how many Pips a Pair has moved from its opening price.   Please rate it and leave a comment. Thank you. ///S.Khan (*Still Learning to TRADE )  
14 Oct 2016
Downloads
774
Comments
0
Rating
5
Download
Hi, this indicator displays the Hourly, Daily, Weeky, Monthly Total Pips and ATR Value on Chart. Please rate it and leave a comment. Thank you. ///S.Khan    
14 Oct 2016
Downloads
628
Comments
0
Rating
0
Download
Hi, This cBOT will display 8-Major Pair Strength (in Pips) in different time frames, sorted.  Basically, it helps in knowing 1. how the Pairs are behaving in group and 2. which are the two opposite Major Pairs and 3. is it wise to trade or not.   4. It is best to trade the two extreme Pairs on Daily or 4Hr Time Frame (when London or US session opens). APLLY cBOT on : 1-min TIME FRAME WAITING :  DUE TO cTRADER internal issue; First TIME OPEN PRICE Loading takes time. so be patient. around 4 to 5 mins. then once loaded, it updates the prices within mili-seconds on each minute. Please give me your feedback on what other features can be displayed.  (inside the code, there is a code of individual 28 pairs that can be used to display the individual pairs also. have disabled it). Thank you ! /// Saleem Khan  
14 Oct 2016
Downloads
843
Comments
14
Rating
5
Download
Hi All, This cBOT displays 8-Major Pairs strength in different Time Frames.  I have chosen 1-Hr, 4Hr, Daily, Weekly, Monthly. Plus, it also shows the average and the Previous Time Frame values also. In the Picture, have highlighted with red box : #1.  This is the average value in Pips, of 4-previous values i/c current one. This column is sorted as per the Sorting in the Current Col.  IF Highlighted then it means that the "total pips" value in "Current" column has crossed this avg. value. #2.  Compare the Total Pips in 4-Hr Time Frame, (previous) with the ATR Value. If highlighted, it means that the value has crossed the ATR value of that same Time frame. #3.  This is "AVERAGE" Column #4. This is the "Current" Column #5, 6, 7 : These are the Values of the previous Time Frames. #8: If anyone of the 8-Major Pair, Total Pips (Current Time Frame) was greater then Average Pips in all Time Frames, then it will record the date and time over here. #9:  Sum of all the 28Pairs Pips and sum of 8-Major ATR Values displayed in the Last row. #10: Average of the 28 Pairs.   How to USE : 1. Which Pairs to trade : Normally, the Major-Pair whose "TOTAL Pips" has crossed "600" value in "DAILY" Current Time Frame, is the Pair which has the most movement. Better to trade the sub-pairs of that Major Pair when it cross this value. 2. Reversal : if the current "Total Pip" has crossed the current "ATR" Value, in any Time Frame, then it is most likely set to reverse. The cBot, will highlight it. Greater the time frame, the greater the chance of reversal. if the "week time-frame" closes with Total Pips greater then ATR Value in Weekly Time Frame, then that Pair will reverse the following next week.  *Check the JPY Pair, in the Weekly Time Frame in Prev-1 column and its value now in Current Weekly Time Frame. 3: Not to trade Pairs : whose Major-Pair are next to each other in the "current" Daily and 4-hour Time-Frame.  Atleast, a distance of two pairs is good. If GBP-Pair and JPY-Pair are next to each other in the sorted list; then better not to trade GBPJPY as it will move sideways. NOTE : THE CODE PASTED HERE (AFTER THE IMAGE)  IS THE RIGHT CODE.  FOR SOME REASON, THIS WEBSITE WAS NOT LOADING THIS CODE FILE.  THE FILE UPLOADED, IS JUST A TEMP FILE; IGNORE THAT FILE.   Please leave a comment if you like it and share any idea you would like to add to this cBOT. Thank you ///S.Khan   //////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// //// //// Name : INTER-MARKET CBOT //// //// Dated : 30-Mar-16 //// //// ver : 3.0 //// //// Updated : 30-Mar-16 //// //// //// //////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////// using System.Globalization; using System.IO; using System.Threading; using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; namespace cAlgo { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)] public class MajorPairStrengthv4 : Robot { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// USER INPUT /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// [Parameter("<--------------> FRIDAY <-------------->")] public string temp50 { get; set; } [Parameter("43. Close on Friday (yes or no)", DefaultValue = false)] public bool p_Flag_CloseFriday { get; set; } [Parameter("44. Close On Friday (x hours)", DefaultValue = 2, MinValue = 1, MaxValue = 10)] public int p_FridayClose_Hrs { get; set; } [Parameter("45. Write Data to CSV File ", DefaultValue = false)] public bool p_Flag_Create_CSV_File { get; set; } [Parameter("46. Folder Name on the Desktop ", DefaultValue = "SK Intermarket v4")] public string p_str_Folder_Name { get; set; } [Parameter("47. Live (No), BackTesting (Yes)", DefaultValue = false)] public bool p_Flag_BackTesting { get; set; } /////////////////////////////////// // END OF USER INPUT ///// /////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// GLOBAL VARIABLES /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // #-------------- TIME FRAMES --------------# // 5-min TimeFrame TF_5min = TimeFrame.Minute5; // 15 min TimeFrame TF_15min = TimeFrame.Minute15; // 1 Hr TimeFrame TF_1Hr = TimeFrame.Hour; // 4 Hr TimeFrame TF_4Hr = TimeFrame.Hour4; // Daily TimeFrame TF_D = TimeFrame.Daily; // Weekly TimeFrame TF_Wk = TimeFrame.Weekly; // 1-Month TimeFrame TF_Mt = TimeFrame.Monthly; // "#-------------- ATR VALUES --------------#" // 5-MIN (covering 1 hour) int ATR_P_5min = 20; // 15-MIN (covering 2 hours) int ATR_P_15min = 20; // 1-HOUR (covering 3 hours) int ATR_P_1Hr = 20; // 4-HOUR (covering 12 hours) int ATR_P_4Hr = 20; // Daily-ATR (covering 5 days) int ATR_P_D = 20; // Weekly-ATR (covering 1 month) int ATR_P_Wk = 20; // Monthly (covering 4 months) int ATR_P_Mt = 20; MovingAverageType p_ATR_MA_Type = MovingAverageType.Simple; // ----------------------------------------------------------- // PREVIOUS PRICES : INDEX private int LP1 = 4; // CONTAINS THE INDEX VALUES TO ACCESS OPEN PRICES : Current, Last, 3Months, 6 months private int[] LP1_Array_Open; private int[] LP1_Array_Close; private string[] LP1_TF_Name; // DAY WEEK VALUE private int Day_of_the_Week_1 = 0; private int Day_of_the_Week_2 = 0; private int Month_of_the_Year = 0; private string[] Month_Name; private bool Flag_New_Day = true; private bool Flag_is_Monday_Next = false; //For Indexng of MarketSeries private int Count_Bar = 0; //private double Daily_Count_Bar = 0; // COLORS --------------------------------------------------------- private Colors Clr_Bk_1 = Colors.DimGray; private Colors Clr_Heading_1 = Colors.Yellow; private Colors Clr_PairListing = Colors.Aqua; private Colors Clr_Positive = Colors.LightGreen; private Colors Clr_Negative = Colors.MediumVioletRed; private Colors Clr_Above = Colors.CornflowerBlue; private Colors Clr_Below = Colors.WhiteSmoke; private Colors Clr_Border = Colors.LightGray; // ALL 28 PAIRS PRICES [28,3] DAILY WEEKLY MONTHLY ---------------- private double[] All_28Pair_Pip_Size; private string[] All_28Pair_Symbol_Code; // ------- ATR VALUES ----------------- private double[,,] All_28Pair_ATR_Value; private double[,] GTotal_28Pair_ATR_Value; private double[,,] All_MajorPair_ATR_Value; private double[,] GTotal_MajorPair_ATR_Value; // 8 MAJOR PAIRS : DAILY, WEEKLY, MONTHLY private string[] MajorPair_Headings; private string[,] MajorPair_Combo; private int[,] Base_Currency; // ------- CURRENT PRICES -------------------------------------- // ARRAYS FOR STORING PREVIOUS PRICES : OPEN, HIGH, LOW, CLOSE private double[,,] All_28Pair_Open_Price; private double[,,] All_28Pair_Close_Price; private double[,,] All_28Pair_HiLo_Price; private double[,,] All_28Pair_Total_Pips; private double[,,] All_MajorPair_Total_Pips; private double[,] GTotal_28Pair_Total_Pips; private double[,] GTotal_MajorPair_Total_Pips; private int[,] Sorted_MajorPair_Monthly_Total_Pips; private int[,] Sorted_MajorPair_Weekly_Total_Pips; private int[,] Sorted_MajorPair_Daily_Total_Pips; private int[,] Sorted_MajorPair_4Hour_Total_Pips; private int[,] Sorted_MajorPair_Hourly_Total_Pips; private int[,] Sorted_MajorPair_15min_Total_Pips; // ----------------------------------------------------------------- // ------- AVERAGE PIPS ---------------------------------------- private double[,] Avg_All_28Pair_Total_Pips; private double[,] Avg_All_MajorPair_Total_Pips; // KEEP TRACK OF 8-MAJOR PAIR, IF TOTAL PIPS HAVE // CROSSED AVG.PIPS, IN ALL 7 TIME FRAMES private int[] Flag_TotalPips_Greater_AvgPips; private string[] DateTime_TotalPips_Greater_AvgPips; // ATR INDICATOR INSTANCE ///////////////////// private AverageTrueRange ATR_Indicator_1; private AverageTrueRange ATR_Indicator_2; private AverageTrueRange ATR_Indicator_3; private AverageTrueRange ATR_Indicator_4; private AverageTrueRange ATR_Indicator_5; private AverageTrueRange ATR_Indicator_6; private AverageTrueRange ATR_Indicator_7; /////////////////////////////////////////////// // CSV FILE CREATION private static string str_DesktopFolder; private static string str_FolderPath; private static string str_FileName; private System.IO.FileStream File_Stream; private System.IO.StreamWriter File_Writer; //*Important : These File_Stream and File_Writer has to be closed On_Stop function. //see On_Stop function in the END //////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////// // END OF GLOBAL VARIABLES ///// /////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// ON START /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected override void OnStart() { //DISPLAY START DATE AND TIME string t_Date = string.Format("{0:ddd-d-MMMM-y, HH:MM}", Server.Time); Print(""); Print("cBOT Start Date & Time : " + t_Date); // DISPLAY cBOT NAME ON CHART Draw_OnChart_C1("DBNAME01", (1), (1), "INTER-MARKET V4.0 BY /// S.KHAN (skhan.projects@gmail.com) ", Clr_Heading_1); //Set the Count Bar Value for MarketSeries Set_Count_Bar_Value(); if (p_Flag_Create_CSV_File) { Create_CSV_File(); } //END IF // DECLARE ALL ARRAYS ONCE ONLY ON START Declare_All_Arrays(); // INITIALIZE ARRAY ON START Initialize_Array_OnStart_Only(); //WRITE FIXED VALUE ON CHART SCREEN Create_Fixed_Display_1(); Create_Fixed_Display_2(); Create_Display_RowColumn(); // START LINE, STOP LINE, COL # Display_Vertical_Lines(3, 75, 9); Display_Vertical_Lines(3, 75, 24); // LINE NO, START COL, STOP COL Display_Horizontal_Lines(30, 1, 24); Display_Horizontal_Lines(43, 1, 24); // LOAD SYMBOL CODE AND PIPS SIZE Load_28Pair_SymbolCode(); Load_28Pair_PipSize(); // LOAD ON START-ONLY : OPEN PRICES OF ALL TIME FRAME OnSTART_Load_28Pair_Open_Prices(); // CURRENT PRICES --------------------------------------- Load_28Pair_Open_Prices(); Load_28Pair_Close_Prices(); // CALCULATE 28-PAIRS - TOTAL PIPS Get_28Pair_TOTAL_Pips_from_Open(); // GET 8-MAJOR PAIR - TOTAL PIPS Get_MajorPair_Total_Pips(); // ATR VALUES ------------------------------------------- Load_28Pair_ATR_Values(); Get_MajorPair_ATR_Values(); //Write_CSVFIle_MajorPair_Monthly_Total_Pips(); } //End METHOD On_Start ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// ON B A R /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected override void OnBar() { //Print("OnBar'' MEHTOD START : D/T= " + Server.Time); //SET THE DAY OF WEEK VALUE MON=1, TUE=2, ........FRI=5 Day_of_the_Week_1 = (int)Server.Time.DayOfWeek; // GET THE MONTH OF THE YEAR Month_of_the_Year = (int)Server.Time.Month; //CHECK CHANGE OF DAY if (Day_of_the_Week_1 != Day_of_the_Week_2) Flag_New_Day = true; else Flag_New_Day = false; //IF NEW DAY THEN GET NEW VALUES if (Flag_New_Day == true) { Flag_New_Day = false; } //END IF // CURRENT PRICES ------------------------------------------------- Load_28Pair_Open_Prices(); Load_28Pair_Close_Prices(); Load_28Pair_ATR_Values(); // Get TOTAL PIPS Get_28Pair_TOTAL_Pips_from_Open(); Get_MajorPair_Total_Pips(); Get_MajorPair_ATR_Values(); // AVERAGE Get_Avg_28Pair_Total_Pips(); Get_Avg_MajorPair_Total_Pips(); // SORT Sort_MajorPair_15min_TotalPips_Array(); Sort_MajorPair_Hourly_TotalPips_Array(); Sort_MajorPair_4Hour_TotalPips_Array(); Sort_MajorPair_Daily_TotalPips_Array(); Sort_MajorPair_Weekly_TotalPips_Array(); Sort_MajorPair_Monthly_TotalPips_Array(); // ----------------------------------------------------------------- // DISPLAY -------------------------------------------------------- int t_Line = 5, t_Col = 1; //Display_MajorPair_15min_Total_Pips(t_Line, t_Col); Display_MajorPair_Hourly_Total_Pips(t_Line, t_Col); Display_MajorPair_4Hour_Total_Pips(t_Line + 14, t_Col); Display_MajorPair_Daily_Total_Pips(t_Line + 28, t_Col); Display_MajorPair_Weekly_Total_Pips(t_Line + 42, t_Col); Display_MajorPair_Monthly_Total_Pips(t_Line + 56, t_Col); // ----------------------------------------------------------------- // IF TOTAL PIP > AVERAGE PIP IN ALL TIME FRAME -------------------- Update_Array_AvgPips_Greater_then_TotalPips(); Display_Array_AvgPips_Greater_then_TotalPips(61, 26); // ----------------------------------------------------------------- //MAKE A COPY OF THE DAY TO BE COMPARED, ON THE NEXT BAR Day_of_the_Week_2 = Day_of_the_Week_1; //IF FRIDAY THEN RESET THE MONDAY FLAG if (Day_of_the_Week_1 == 5) Flag_is_Monday_Next = true; // IF DAY HAS CHANGED TO MONDAY FROM SUNDAY OR FRIDAY if (Flag_is_Monday_Next == true && Day_of_the_Week_1 == 1) { Flag_is_Monday_Next = false; } //END IF } //END METHOD On_Bar ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// ON T I C K /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected override void OnTick() { // Put your core logic here } //End METHOD On_TICK ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// TEST_FUNCTION /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void TEST_FUNCTION() { } //END MEHTOD TEST_FUNCTION ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Display_Array_AvgPips_Greater_then_TotalPips /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void Display_Array_AvgPips_Greater_then_TotalPips(int t_Row, int t_Col) { int t_Line_no = 0, t_Col_no = 0, t_Offset = 0; double t_1 = 0; string tstr_1, tstr_Symbol_Code, tstr_Date, temp_1; Colors t_Clr; // SET THE LINE # AND COLUMN # t_Line_no = t_Row; t_Col_no = t_Col; t_Offset = 2; // DISPLAY AVERAGE VALUES --------------------------------------------------------------------------------- // COLUMN HEADINGs Draw_OnChart_C1("AvgTPips01", (t_Line_no - 2), (t_Col_no), "TOTAL > AVG.PIP", Clr_Heading_1); Draw_OnChart_C1("AvgTPips02", (t_Line_no - 1), (t_Col_no), "MAJOR PAIR", Clr_Heading_1); Draw_OnChart_C1("AvgTPips03", (t_Line_no - 2), (t_Col_no + t_Offset), " ALL", Clr_Heading_1); Draw_OnChart_C1("AvgTPips04", (t_Line_no - 1), (t_Col_no + t_Offset), "TIMEFRAME", Clr_Heading_1); //LOOP TO DISPLAY AVERAGE VALUES for (int i = 0; i < 8; i++) { // CONVERT t_Last_Price to STRING FOR UNIQUE OBJECT NAME IN Draw_OnChart_C1 METHOD temp_1 = i.ToString(); // GET SYMBOL CODE tstr_Symbol_Code = i.ToString("0") + ". " + MajorPair_Headings[i]; // GET THE VALUES FROM ARRAY t_1 = Flag_TotalPips_Greater_AvgPips[i]; tstr_Date = DateTime_TotalPips_Greater_AvgPips[i]; if (t_1 >= 5) { tstr_1 = "YES"; } else { tstr_1 = "NO"; } //END IF ELSE // SET COLOR NAME ON POSITIVE OR NEGATIVE TOTAL PIP FROM OPEN if (tstr_1 == "YES") t_Clr = Clr_Above; else t_Clr = Clr_Below; // DRAW ON CHART(OBJ_NAME, LINE#, COL#, Text_To_Display, ColorName); Draw_OnChart_C1("AVGTPips05" + temp_1, t_Line_no, (t_Col_no), tstr_Symbol_Code, Clr_PairListing); Draw_OnChart_C1("AVGTPips06" + temp_1, t_Line_no, (t_Col_no + t_Offset), tstr_1, t_Clr); if (tstr_1 == "YES") { Draw_OnChart_C1("AVGTPips07" + temp_1, t_Line_no, (t_Col_no + t_Offset + 1), tstr_Date, t_Clr); } else { Draw_OnChart_C1("AVGTPips07" + temp_1, t_Line_no, (t_Col_no + t_Offset + 1), "(Prev.Date) = " + tstr_Date, t_Clr); } //END IF ELSE // INC. THE LINE # t_Line_no += 1; // LEAVE A BLANK LINE if (i == 3) t_Line_no += 1; } //END FOR i } //END MEHTOD Display_Array_AvgPips_Greater_then_TotalPips ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Update_Array_AvgPips_Greater_then_TotalPips /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void Update_Array_AvgPips_Greater_then_TotalPips() { double t_1 = 0, t_2 = 0; int t_Count = 0; string t_Text; // FOR 8-MAJOR PAIRS for (int i = 0; i < 8; i++) { // 7-TIME FRAME : 0=5min, 1=15min, 2=1Hour, 3=4Hr, 5=Daily, 6=Weekly, 7=Monthly for (int j = 2; j < 7; j++) { // TOTAL PIPS OF MAJOR PAIR : 1ST INDEX IS FOR CURRENT or // Previous Values, 2nd index is for MAJOR-PAIR, t_TF can be 5min, Daily, Monthly t_1 = Math.Abs(All_MajorPair_Total_Pips[0, i, j]); t_2 = Avg_All_MajorPair_Total_Pips[i, j]; if (t_1 >= t_2) t_Count += 1; } //END FOR j // IF TOTALPIPS IN THE PARTICULAR TIME FRAME HAS CROSSED ITS // AVG. PIPS IN THE SAME TIME FRAME if (t_Count >= 5) { // SET THE FLAG TO TRUE Flag_TotalPips_Greater_AvgPips[i] = 1; // STORE THE DATE TIME t_Text = string.Format("{0:ddd-d-MMM-y, HH:mm}", Server.Time); DateTime_TotalPips_Greater_AvgPips[i] = t_Text; } else { Flag_TotalPips_Greater_AvgPips[i] = 0; } //END IF ELSE //RESET THE COUNTER t_Count = 0; } //END FOR i } //END MEHTOD Update_Array_AvgPips_Greater_then_TotalPips ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Get_Avg_28Pair_Total_Pips /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void Get_Avg_28Pair_Total_Pips() { double t_1 = 0; //Print("INSIDE : AVERAGE - MAJOR PAIRS"); // LOOP FOR 8-MAJOR PAIRS for (int i = 0; i < 8; i++) { // LOOP FOR 7-TIME FRAME for (int j = 0; j < 7; j++) { // LOOP FOR PREVIOUS PRICES DATA for (int k = 0; k < LP1; k++) { // CONVERT TO POSITIVE VALUES AND THEN ADD if (All_28Pair_Total_Pips[k, i, j] >= 0) t_1 += All_28Pair_Total_Pips[k, i, j]; else t_1 += All_28Pair_Total_Pips[k, i, j] * -1; } //END FOR K // FOR AVERAGE DIVIDE BY THE NO OF PREVIOUS PRICES ADDED Avg_All_28Pair_Total_Pips[i, j] = Math.Round(t_1 / LP1, 0); // RESET THE TOTAL TO 0 t_1 = 0; } //END FOR J } //END FOR I } //END MEHTOD Get_Avg_28Pair_Total_Pips ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Get_Avg_MajorPair_Total_Pips /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void Get_Avg_MajorPair_Total_Pips() { double t_1 = 0; // LOOP FOR 8-MAJOR PAIRS for (int i = 0; i < 8; i++) { // LOOP FOR 7-TIME FRAME for (int j = 0; j < 7; j++) { // LOOP FOR PREVIOUS PRICES DATA for (int k = 0; k < LP1; k++) { // CONVERT TO POSITIVE VALUES AND THEN ADD if (All_MajorPair_Total_Pips[k, i, j] >= 0) t_1 += All_MajorPair_Total_Pips[k, i, j]; else t_1 += All_MajorPair_Total_Pips[k, i, j] * -1; } //END FOR K // FOR AVERAGE DIVIDE BY THE NO OF PREVIOUS PRICES ADDED Avg_All_MajorPair_Total_Pips[i, j] = Math.Round(t_1 / LP1, 0); // RESET THE TOTAL TO 0 t_1 = 0; } //END FOR J } //END FOR I } //END MEHTOD Get_Avg_MajorPair_Total_Pips ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Write_CSVFIle__MajorPair_Monthly_Total_Pips /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void Write_CSVFIle_MajorPair_Monthly_Total_Pips() { int t_TF; double t_Total_Pip = 0; string tstr_TPips, tstr_Symbol_Code, tstr_CompleteRow; //SET TIME FRAME 0=5MIN, 1=15MIN, 2=1HR, 3=4HR, 4=D, 5=W, 6=M. t_TF = 6; // LOOP FOR 8 MAJOR-PAIRS : DISPLAY SYMBOL CODE AND TOTAL PIPS ON CHART for (int i = 0; i < 8; i++) { // GET THE SYMBOL INDEX FROM THE SORTED TEMP ARRAY //t_1 = Sorted_MajorPair_Monthly_Total_Pips[b, i]; // GET SYMBOL CODE AS PER THE t_Index tstr_Symbol_Code = MajorPair_Headings[i]; tstr_CompleteRow = tstr_Symbol_Code + ","; // LOOP TO ACCESS PREVIOUS PRICES for (int b = 0; b < LP1; b++) { // GET WEEKLY TOTAL PIPS MOVED FROM OPEN AND CONVERT TO STRING t_Total_Pip = All_MajorPair_Total_Pips[b, i, t_TF]; tstr_TPips = t_Total_Pip.ToString("0"); // ADD TO STRING ALL PREVIOUS PRICES OF ONE MAJOR PAIR ONLY tstr_CompleteRow += tstr_TPips + ","; } //END FOR b // WRITE MAJOR PARI : POSITION, SYMBOL CODE, TOTAL PIPS //WRITE CURRENT DATA File_Writer.WriteLine(Concate_With_Comma(tstr_CompleteRow)); // RESET THE STRING TO BLANK tstr_CompleteRow = ""; } // END FOR i } //END MEHTOD Write_CSVFIle__MajorPair_Monthly_Total_Pips ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Return_Pair_Index_Position /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private int Return_Pair_Index_Position(string tstr_Pair) { int t_index = 0; bool t_Flag = true; Symbol t_Symbol; while (t_Flag == true) { t_Symbol = Get_28Pair_Symbol(t_index); if (tstr_Pair == t_Symbol.Code.ToString()) { t_Flag = false; } //END IF t_index += 1; // IF PAIR IS NOT MATCHED : BREAK THE WHILE LOOP if (t_index >= 30) t_Flag = false; } //END WHILE // GO ONE BACK AS THE WHILE LOOPS ADD ONE EXTRA ON EXIT t_index -= 1; return t_index; } //END MEHTOD Return_Pair_Index_Position ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Return_Name_of_the_Month /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private string Return_Name_of_the_Month(int t_Month) { string t_str1 = ""; // IF NEGATIVE NUMBER e.g. -1, it means Dec of the PREVIOUS YEAR if (t_Month < 0) t_Month += 13; t_str1 = Month_Name[t_Month]; return t_str1; } //END MEHTOD Return_Name_of_the_Month ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Sort_MajorPair_15min_TotalPips_Array /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void Sort_MajorPair_15min_TotalPips_Array() { int t_1 = 0; int t_TF; double t_2 = 0; // TEMP ARRAY FOR STORING INDEX VALUE AND ARRAY VALUE int[] t_Index; double[] t_Value; t_Index = new int[8]; t_Value = new double[8]; //SET TIME FRAME 0=5MIN, 1=15MIN, 2=1HR, 3=4HR, 4=D, 5=W, 6=M. t_TF = 1; // LOOP TO DISPLAY LAST 4 VALUES for (int b = 0; b < LP1; b++) { //LOOP FOR 8-MAJOR PAIRS : COPY VALUES for (int i = 0; i < 8; i++) { // COPY IN TEMP ARRAY : serial#, Pip value t_Index[i] = i; t_Value[i] = All_MajorPair_Total_Pips[b, i, t_TF]; } //END FOR // SORT THE TEMP ARRAY INTO DESCENDING ORDER bool change = true; while (change == true) { change = false; // COMPARE VALUES [LOOP WILL RUN ONE LESS] for (int i = 0; i < 7; i++) { if (t_Value[i] < t_Value[i + 1]) { change = true; //SWAP FIRST INDEX VALUES (COUNTER) OF THE TEMP ARRAY t_1 = t_Index[i + 1]; t_Index[i + 1] = t_Index[i]; t_Index[i] = t_1; //SWAP 2ND INDEX VALUES (TOTAL PIP) OF THE TEMP ARRAY t_2 = t_Value[i + 1]; t_Value[i + 1] = t_Value[i]; t_Value[i] = t_2; } //END IF } //END FOR } //END WHILE SORTING //LOOP FOR 8-MAJOR PAIRS : COPY FROM TEMP ARRAY TO SORTED ARRAY for (int i = 0; i < 8; i++) { Sorted_MajorPair_15min_Total_Pips[b, i] = t_Index[i]; } // END FOR } // END FOR B } //END METHOD Sort_MajorPair_15min_TotalPips_Array ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Sort_MajorPair_Hourly_TotalPips_Array /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void Sort_MajorPair_Hourly_TotalPips_Array() { int t_1 = 0; int t_TF; double t_2 = 0; // TEMP ARRAY FOR STORING INDEX VALUE AND ARRAY VALUE int[] t_Index; double[] t_Value; t_Index = new int[8]; t_Value = new double[8]; //SET TIME FRAME 0=5MIN, 1=15MIN, 2=1HR, 3=4HR, 4=D, 5=W, 6=M. t_TF = 2; // LOOP TO DISPLAY LAST 4 VALUES for (int b = 0; b < LP1; b++) { //LOOP FOR 8-MAJOR PAIRS : COPY VALUES for (int i = 0; i < 8; i++) { // COPY IN TEMP ARRAY : serial#, Pip value t_Index[i] = i; t_Value[i] = All_MajorPair_Total_Pips[b, i, t_TF]; } //END FOR // SORT THE TEMP ARRAY INTO DESCENDING ORDER bool change = true; while (change == true) { change = false; // COMPARE VALUES [LOOP WILL RUN ONE LESS] for (int i = 0; i < 7; i++) { if (t_Value[i] < t_Value[i + 1]) { change = true; //SWAP FIRST INDEX VALUES (COUNTER) OF THE TEMP ARRAY t_1 = t_Index[i + 1]; t_Index[i + 1] = t_Index[i]; t_Index[i] = t_1; //SWAP 2ND INDEX VALUES (TOTAL PIP) OF THE TEMP ARRAY t_2 = t_Value[i + 1]; t_Value[i + 1] = t_Value[i]; t_Value[i] = t_2; } //END IF } //END FOR } //END WHILE SORTING //LOOP FOR 8-MAJOR PAIRS : COPY FROM TEMP ARRAY TO SORTED ARRAY for (int i = 0; i < 8; i++) { Sorted_MajorPair_Hourly_Total_Pips[b, i] = t_Index[i]; } // END FOR } // END FOR B } //END METHOD Sort_MajorPair_Hourly_TotalPips_Array ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Sort_MajorPair_4Hour_TotalPips_Array /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void Sort_MajorPair_4Hour_TotalPips_Array() { int t_1 = 0; int t_TF; double t_2 = 0; // TEMP ARRAY FOR STORING INDEX VALUE AND ARRAY VALUE int[] t_Index; double[] t_Value; t_Index = new int[8]; t_Value = new double[8]; //SET TIME FRAME 0=5MIN, 1=15MIN, 2=1HR, 3=4HR, 4=D, 5=W, 6=M. t_TF = 3; // LOOP TO DISPLAY LAST 4 VALUES for (int b = 0; b < LP1; b++) { //LOOP FOR 8-MAJOR PAIRS : COPY VALUES for (int i = 0; i < 8; i++) { // COPY IN TEMP ARRAY : serial#, Pip value t_Index[i] = i; t_Value[i] = All_MajorPair_Total_Pips[b, i, t_TF]; } //END FOR // SORT THE TEMP ARRAY INTO DESCENDING ORDER bool change = true; while (change == true) { change = false; // COMPARE VALUES [LOOP WILL RUN ONE LESS] for (int i = 0; i < 7; i++) { if (t_Value[i] < t_Value[i + 1]) { change = true; //SWAP FIRST INDEX VALUES (COUNTER) OF THE TEMP ARRAY t_1 = t_Index[i + 1]; t_Index[i + 1] = t_Index[i]; t_Index[i] = t_1; //SWAP 2ND INDEX VALUES (TOTAL PIP) OF THE TEMP ARRAY t_2 = t_Value[i + 1]; t_Value[i + 1] = t_Value[i]; t_Value[i] = t_2; } //END IF } //END FOR } //END WHILE SORTING //LOOP FOR 8-MAJOR PAIRS : COPY FROM TEMP ARRAY TO SORTED ARRAY for (int i = 0; i < 8; i++) { Sorted_MajorPair_4Hour_Total_Pips[b, i] = t_Index[i]; } // END FOR } // END FOR B } //END METHOD Sort_MajorPair_4Hour_TotalPips_Array ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Sort_MajorPair_Daily_TotalPips_Array /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void Sort_MajorPair_Daily_TotalPips_Array() { int t_1 = 0; int t_TF; double t_2 = 0; // TEMP ARRAY FOR STORING INDEX VALUE AND ARRAY VALUE int[] t_Index; double[] t_Value; t_Index = new int[8]; t_Value = new double[8]; //SET TIME FRAME 0=5MIN, 1=15MIN, 2=1HR, 3=4HR, 4=D, 5=W, 6=M. t_TF = 4; // LOOP TO DISPLAY LAST 4 VALUES for (int b = 0; b < LP1; b++) { //LOOP FOR 8-MAJOR PAIRS : COPY VALUES for (int i = 0; i < 8; i++) { // COPY IN TEMP ARRAY : serial#, Pip value t_Index[i] = i; t_Value[i] = All_MajorPair_Total_Pips[b, i, t_TF]; } //END FOR // SORT THE TEMP ARRAY INTO DESCENDING ORDER bool change = true; while (change == true) { change = false; // COMPARE VALUES [LOOP WILL RUN ONE LESS] for (int i = 0; i < 7; i++) { if (t_Value[i] < t_Value[i + 1]) { change = true; //SWAP FIRST INDEX VALUES (COUNTER) OF THE TEMP ARRAY t_1 = t_Index[i + 1]; t_Index[i + 1] = t_Index[i]; t_Index[i] = t_1; //SWAP 2ND INDEX VALUES (TOTAL PIP) OF THE TEMP ARRAY t_2 = t_Value[i + 1]; t_Value[i + 1] = t_Value[i]; t_Value[i] = t_2; } //END IF } //END FOR } //END WHILE SORTING //LOOP FOR 8-MAJOR PAIRS : COPY FROM TEMP ARRAY TO SORTED ARRAY for (int i = 0; i < 8; i++) { Sorted_MajorPair_Daily_Total_Pips[b, i] = t_Index[i]; } // END FOR } // END FOR B } //END METHOD Sort_MajorPair_Daily_TotalPips_Array ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Sort_MajorPair_Weekly_TotalPips_Array /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void Sort_MajorPair_Weekly_TotalPips_Array() { int t_1 = 0; int t_TF; double t_2 = 0; // TEMP ARRAY FOR STORING INDEX VALUE AND ARRAY VALUE int[] t_Index; double[] t_Value; t_Index = new int[8]; t_Value = new double[8]; //SET TIME FRAME 0=5MIN, 1=15MIN, 2=1HR, 3=4HR, 4=D, 5=W, 6=M. t_TF = 5; // LOOP TO DISPLAY LAST 4 VALUES for (int b = 0; b < LP1; b++) { //LOOP FOR 8-MAJOR PAIRS : COPY VALUES for (int i = 0; i < 8; i++) { // COPY IN TEMP ARRAY : serial#, Pip value t_Index[i] = i; t_Value[i] = All_MajorPair_Total_Pips[b, i, t_TF]; } //END FOR // SORT THE TEMP ARRAY INTO DESCENDING ORDER bool change = true; while (change == true) { change = false; // COMPARE VALUES [LOOP WILL RUN ONE LESS] for (int i = 0; i < 7; i++) { if (t_Value[i] < t_Value[i + 1]) { change = true; //SWAP FIRST INDEX VALUES (COUNTER) OF THE TEMP ARRAY t_1 = t_Index[i + 1]; t_Index[i + 1] = t_Index[i]; t_Index[i] = t_1; //SWAP 2ND INDEX VALUES (TOTAL PIP) OF THE TEMP ARRAY t_2 = t_Value[i + 1]; t_Value[i + 1] = t_Value[i]; t_Value[i] = t_2; } //END IF } //END FOR } //END WHILE SORTING //LOOP FOR 8-MAJOR PAIRS : COPY FROM TEMP ARRAY TO SORTED ARRAY for (int i = 0; i < 8; i++) { Sorted_MajorPair_Weekly_Total_Pips[b, i] = t_Index[i]; } // END FOR } // END FOR B } //END METHOD Sort_MajorPair_Weekly_TotalPips_Array ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Sort_MajorPair_Monthly_TotalPips_Array /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void Sort_MajorPair_Monthly_TotalPips_Array() { int t_1 = 0; int t_TF; double t_2 = 0; // TEMP ARRAY FOR STORING INDEX VALUE AND ARRAY VALUE int[] t_Index; double[] t_Value; t_Index = new int[8]; t_Value = new double[8]; //SET TIME FRAME 0=5MIN, 1=15MIN, 2=1HR, 3=4HR, 4=D, 5=W, 6=M. t_TF = 6; // LOOP TO DISPLAY LAST 4 VALUES for (int b = 0; b < LP1; b++) { //LOOP FOR 8-MAJOR PAIRS : COPY VALUES for (int i = 0; i < 8; i++) { // COPY IN TEMP ARRAY : serial#, Pip value t_Index[i] = i; t_Value[i] = All_MajorPair_Total_Pips[b, i, t_TF]; } //END FOR // SORT THE TEMP ARRAY INTO DESCENDING ORDER bool change = true; while (change == true) { change = false; // COMPARE VALUES [LOOP WILL RUN ONE LESS] for (int i = 0; i < 7; i++) { if (t_Value[i] < t_Value[i + 1]) { change = true; //SWAP FIRST INDEX VALUES (COUNTER) OF THE TEMP ARRAY t_1 = t_Index[i + 1]; t_Index[i + 1] = t_Index[i]; t_Index[i] = t_1; //SWAP 2ND INDEX VALUES (TOTAL PIP) OF THE TEMP ARRAY t_2 = t_Value[i + 1]; t_Value[i + 1] = t_Value[i]; t_Value[i] = t_2; } //END IF } //END FOR } //END WHILE SORTING //LOOP FOR 8-MAJOR PAIRS : COPY FROM TEMP ARRAY TO SORTED ARRAY for (int i = 0; i < 8; i++) { Sorted_MajorPair_Monthly_Total_Pips[b, i] = t_Index[i]; } // END FOR } // END FOR B } //END METHOD Sort_MajorPair_Monthly_TotalPips_Array ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Display_MajorPair_15min_Total_Pips /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void Display_MajorPair_15min_Total_Pips(int t_Row, int t_Col) { int t_Line_no = 0, t_Col_no = 0, t_Offset = 0, t_1 = 0; double t_Total_Pip = 0, t_2 = 0; double t_ATR; int t_TF; string tstr_TPips, tstr_Symbol_Code, temp_1, tstr_TFrame, tstr_GrandTotal, tstr_ATR; Colors t_Clr; //SET TIME FRAME 0=5MIN, 1=15MIN, 2=1HR, 3=4HR, 4=D, 5=W, 6=M. t_TF = 1; // SET THE LINE # AND COLUMN # t_Line_no = t_Row; t_Col_no = t_Col; t_Offset = 2; // DISPLAY AVERAGE VALUES --------------------------------------------------------------------------------- // COLUMN HEADINGs Draw_OnChart_C1("AvgPips01", (t_Line_no - 2), (t_Col_no), "AVERAGE", Clr_Heading_1); Draw_OnChart_C1("AvgPips02", (t_Line_no - 1), (t_Col_no), "MAJOR PAIR", Clr_Heading_1); Draw_OnChart_C1("AvgPips03", (t_Line_no - 2), (t_Col_no + t_Offset), "15-min", Clr_Heading_1); Draw_OnChart_C1("AvgPips04", (t_Line_no - 1), (t_Col_no + t_Offset), "AVG-Pips", Clr_Heading_1); //LOOP TO DISPLAY AVERAGE VALUES for (int i = 0; i < 8; i++) { // CONVERT t_Last_Price to STRING FOR UNIQUE OBJECT NAME IN Draw_OnChart_C1 METHOD temp_1 = i.ToString(); // SORT AS PER THE CURRENT SORTED MAJOR PAIR VALUES t_1 = Sorted_MajorPair_15min_Total_Pips[0, i]; // GET SYMBOL CODE AS PER THE t_Index tstr_Symbol_Code = i.ToString("0") + ". " + MajorPair_Headings[t_1]; // GET WEEKLY TOTAL PIPS MOVED FROM OPEN AND CONVERT TO STRING t_Total_Pip = Avg_All_MajorPair_Total_Pips[t_1, t_TF]; tstr_TPips = t_Total_Pip.ToString("0"); // GET TOTAL PIP FOR COMPARISON WITH AVERAGE TO SET THE COLOR t_2 = Math.Abs(All_MajorPair_Total_Pips[0, t_1, t_TF]); // SET COLOR NAME ON POSITIVE OR NEGATIVE TOTAL PIP FROM OPEN if (t_2 >= t_Total_Pip) t_Clr = Clr_Above; else t_Clr = Clr_Below; // DRAW ON CHART(OBJ_NAME, LINE#, COL#, Text_To_Display, ColorName); Draw_OnChart_C1("AVGPips05" + temp_1, t_Line_no, (t_Col_no), tstr_Symbol_Code, Clr_PairListing); Draw_OnChart_C1("AVGPips06" + temp_1, t_Line_no, (t_Col_no + t_Offset), tstr_TPips, t_Clr); // INC. THE LINE # t_Line_no += 1; // LEAVE A BLANK LINE if (i == 3) t_Line_no += 1; } //END FOR I // DISPLAY : AVERAGE OF 28 PAIRS TOTAL PIPS : CURRENT MONTH if (GTotal_28Pair_Total_Pips[0, t_TF] >= 0) t_Clr = Clr_Positive; else t_Clr = Clr_Negative; tstr_GrandTotal = (GTotal_28Pair_Total_Pips[0, t_TF] / 28).ToString("0"); Draw_OnChart_C1("AvgPips07", t_Line_no, (t_Col_no), "Avg of 28-Pairs", t_Clr); Draw_OnChart_C1("AvgPips08", t_Line_no, (t_Col_no + t_Offset), tstr_GrandTotal, t_Clr); // DISPLAY TOTAL PIPS --------------------------------------------------------------------------------- // RESET ROW COL POSITION TO DISPLAY THE NEXT LOOP VALUES t_Line_no = t_Row; t_Col_no = t_Col_no + 4; // LOOP TO DISPLAY LAST x VALUES for (int l = 0; l < LP1; l++) { // CONVERT t_Last_Price to STRING FOR UNIQUE OBJECT NAME IN Draw_OnChart_C1 METHOD temp_1 = l.ToString(); // GET THE TIME FRAME NAME tstr_TFrame = LP1_TF_Name[l]; // COLUMN HEADINGs Draw_OnChart_C1("PrvMPips01" + temp_1, (t_Line_no - 2), (t_Col_no), tstr_TFrame, Clr_Heading_1); Draw_OnChart_C1("PrvMPips02" + temp_1, (t_Line_no - 1), (t_Col_no), "MAJOR PAIR", Clr_Heading_1); Draw_OnChart_C1("PrvPMPips03" + temp_1, (t_Line_no - 2), (t_Col_no + t_Offset), "15-min", Clr_Heading_1); Draw_OnChart_C1("PrvPMPips04" + temp_1, (t_Line_no - 1), (t_Col_no + t_Offset), "T-Pips", Clr_Heading_1); Draw_OnChart_C1("PrvPMPips05" + temp_1, (t_Line_no - 2), (t_Col_no + t_Offset + 1), "15-min", Clr_Heading_1); Draw_OnChart_C1("PrvPMPips06" + temp_1, (t_Line_no - 1), (t_Col_no + t_Offset + 1), "ATR", Clr_Heading_1); // LOOP FOR 8 MAJOR-PAIRS : DISPLAY SYMBOL CODE AND TOTAL PIPS ON CHART for (int i = 0; i < 8; i++) { // GET THE SYMBOL INDEX FROM THE SORTED TEMP ARRAY t_1 = Sorted_MajorPair_15min_Total_Pips[l, i]; // GET SYMBOL CODE AS PER THE t_Index tstr_Symbol_Code = i.ToString("0") + ". " + MajorPair_Headings[t_1]; // GET WEEKLY TOTAL PIPS MOVED FROM OPEN AND CONVERT TO STRING t_Total_Pip = All_MajorPair_Total_Pips[l, t_1, t_TF]; tstr_TPips = t_Total_Pip.ToString("0"); // GET ATR VALUE t_ATR = All_MajorPair_ATR_Value[l, t_1, t_TF]; tstr_ATR = t_ATR.ToString(); // SET COLOR NAME ON POSITIVE OR NEGATIVE TOTAL PIP FROM OPEN if (t_Total_Pip >= 0) t_Clr = Clr_Positive; else t_Clr = Clr_Negative; // SET COLOR NAME ON POSITIVE OR NEGATIVE TOTAL PIP FROM OPEN if (t_Total_Pip >= t_ATR) t_Clr = Clr_Above; // DRAW ON CHART(OBJ_NAME, LINE#, COL#, Text_To_Display, ColorName); Draw_OnChart_C1("PrvMPips07" + temp_1, t_Line_no, (t_Col_no), tstr_Symbol_Code, Clr_PairListing); Draw_OnChart_C1("PrvMPips08" + temp_1, t_Line_no, (t_Col_no + t_Offset), tstr_TPips, t_Clr); // SET COLOR NAME ON POSITIVE OR NEGATIVE TOTAL PIP FROM OPEN if (t_Total_Pip >= 0) t_Clr = Clr_Positive; else t_Clr = Clr_Negative; // DRAW ATR VALUES ON CHART Draw_OnChart_C1("PrvMPips10" + temp_1, t_Line_no, (t_Col_no + t_Offset + 1), tstr_ATR, t_Clr); // INC. THE LINE # t_Line_no += 1; // LEAVE A BLANK LINE if (i == 3) t_Line_no += 1; } //END FOR I // ---------------------------------------------------------------------------------------------------------- // ON THE LAST LINE DISPLAY THE GRAND TOTAL OF ALL 28PAIRS : DAILY // SET COLOR NAME ON POSITIVE OR NEGATIVE TOTAL PIP FROM OPEN if (GTotal_28Pair_Total_Pips[l, t_TF] >= 0) t_Clr = Clr_Positive; else t_Clr = Clr_Negative; // DISPLAY GRAND_TOTAL OF TOTAL_DAILY_PIPS tstr_GrandTotal = GTotal_28Pair_Total_Pips[l, t_TF].ToString("0"); tstr_ATR = GTotal_28Pair_ATR_Value[l, t_TF].ToString(""); Draw_OnChart_C1("PrvMPips11" + temp_1, t_Line_no, (t_Col_no), "Total 28-Pairs", t_Clr); Draw_OnChart_C1("PrvMPips12" + temp_1, t_Line_no, (t_Col_no + t_Offset), tstr_GrandTotal, t_Clr); Draw_OnChart_C1("PrvMPips13" + temp_1, t_Line_no, (t_Col_no + t_Offset + 1), tstr_ATR, t_Clr); // INCREASE THE LINE SPACE FOR NEXT SET OF TIMEFRAME VALUES t_Line_no = t_Row; t_Col_no = t_Col_no + 5; } // END FOR L } //END MEHTOD Display_MajorPair_15min_Total_Pips ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Display_MajorPair_Hourly_Total_Pips /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void Display_MajorPair_Hourly_Total_Pips(int t_Row, int t_Col) { int t_Line_no = 0, t_Col_no = 0, t_Offset = 0, t_1 = 0; double t_Total_Pip = 0, t_2 = 0; double t_ATR; int t_TF; string tstr_TPips, tstr_Symbol_Code, temp_1, tstr_TFrame, tstr_GrandTotal, tstr_ATR; Colors t_Clr; //SET TIME FRAME 0=5MIN, 1=15MIN, 2=1HR, 3=4HR, 4=D, 5=W, 6=M. t_TF = 2; // SET THE LINE # AND COLUMN # t_Line_no = t_Row; t_Col_no = t_Col; t_Offset = 2; // DISPLAY AVERAGE VALUES --------------------------------------------------------------------------------- // COLUMN HEADINGs Draw_OnChart_C1("AvgPips01", (t_Line_no - 2), (t_Col_no), "AVERAGE", Clr_Heading_1); Draw_OnChart_C1("AvgPips02", (t_Line_no - 1), (t_Col_no), "MAJOR PAIR", Clr_Heading_1); Draw_OnChart_C1("AvgPips03", (t_Line_no - 2), (t_Col_no + t_Offset), "1-Hour", Clr_Heading_1); Draw_OnChart_C1("AvgPips04", (t_Line_no - 1), (t_Col_no + t_Offset), "AVG-Pips", Clr_Heading_1); //LOOP TO DISPLAY AVERAGE VALUES for (int i = 0; i < 8; i++) { // CONVERT t_Last_Price to STRING FOR UNIQUE OBJECT NAME IN Draw_OnChart_C1 METHOD temp_1 = i.ToString(); // SORT AS PER THE CURRENT SORTED MAJOR PAIR VALUES t_1 = Sorted_MajorPair_Hourly_Total_Pips[0, i]; // GET SYMBOL CODE AS PER THE t_Index tstr_Symbol_Code = i.ToString("0") + ". " + MajorPair_Headings[t_1]; // GET WEEKLY TOTAL PIPS MOVED FROM OPEN AND CONVERT TO STRING t_Total_Pip = Avg_All_MajorPair_Total_Pips[t_1, t_TF]; tstr_TPips = t_Total_Pip.ToString("0"); // GET TOTAL PIP FOR COMPARISON WITH AVERAGE TO SET THE COLOR t_2 = Math.Abs(All_MajorPair_Total_Pips[0, t_1, t_TF]); // SET COLOR NAME ON POSITIVE OR NEGATIVE TOTAL PIP FROM OPEN if (t_2 >= t_Total_Pip) t_Clr = Clr_Above; else t_Clr = Clr_Below; // DRAW ON CHART(OBJ_NAME, LINE#, COL#, Text_To_Display, ColorName); Draw_OnChart_C1("AVGPips05" + temp_1, t_Line_no, (t_Col_no), tstr_Symbol_Code, Clr_PairListing); Draw_OnChart_C1("AVGPips06" + temp_1, t_Line_no, (t_Col_no + t_Offset), tstr_TPips, t_Clr); // INC. THE LINE # t_Line_no += 1; // LEAVE A BLANK LINE if (i == 3) t_Line_no += 1; } //END FOR I // DISPLAY : AVERAGE OF 28 PAIRS TOTAL PIPS : CURRENT MONTH if (GTotal_28Pair_Total_Pips[0, t_TF] >= 0) t_Clr = Clr_Positive; else t_Clr = Clr_Negative; tstr_GrandTotal = (GTotal_28Pair_Total_Pips[0, t_TF] / 28).ToString("0"); Draw_OnChart_C1("AvgPips07", t_Line_no, (t_Col_no), "Avg of 28-Pairs", t_Clr); Draw_OnChart_C1("AvgPips08", t_Line_no, (t_Col_no + t_Offset), tstr_GrandTotal, t_Clr); // DISPLAY TOTAL PIPS --------------------------------------------------------------------------------- // RESET ROW COL POSITION TO DISPLAY THE NEXT LOOP VALUES t_Line_no = t_Row; t_Col_no = t_Col_no + 4; // LOOP TO DISPLAY LAST x VALUES for (int l = 0; l < LP1; l++) { // CONVERT t_Last_Price to STRING FOR UNIQUE OBJECT NAME IN Draw_OnChart_C1 METHOD temp_1 = l.ToString(); // GET THE TIME FRAME NAME tstr_TFrame = LP1_TF_Name[l]; // COLUMN HEADINGs Draw_OnChart_C1("PrvMPips01" + temp_1, (t_Line_no - 2), (t_Col_no), tstr_TFrame, Clr_Heading_1); Draw_OnChart_C1("PrvMPips02" + temp_1, (t_Line_no - 1), (t_Col_no), "MAJOR PAIR", Clr_Heading_1); Draw_OnChart_C1("PrvPMPips03" + temp_1, (t_Line_no - 2), (t_Col_no + t_Offset), "1-Hour", Clr_Heading_1); Draw_OnChart_C1("PrvPMPips04" + temp_1, (t_Line_no - 1), (t_Col_no + t_Offset), "T-Pips", Clr_Heading_1); Draw_OnChart_C1("PrvPMPips05" + temp_1, (t_Line_no - 2), (t_Col_no + t_Offset + 1), "1-Hour", Clr_Heading_1); Draw_OnChart_C1("PrvPMPips06" + temp_1, (t_Line_no - 1), (t_Col_no + t_Offset + 1), "ATR", Clr_Heading_1); // LOOP FOR 8 MAJOR-PAIRS : DISPLAY SYMBOL CODE AND TOTAL PIPS ON CHART for (int i = 0; i < 8; i++) { // GET THE SYMBOL INDEX FROM THE SORTED TEMP ARRAY t_1 = Sorted_MajorPair_Hourly_Total_Pips[l, i]; // GET SYMBOL CODE AS PER THE t_Index tstr_Symbol_Code = i.ToString("0") + ". " + MajorPair_Headings[t_1]; // GET WEEKLY TOTAL PIPS MOVED FROM OPEN AND CONVERT TO STRING t_Total_Pip = All_MajorPair_Total_Pips[l, t_1, t_TF]; tstr_TPips = t_Total_Pip.ToString("0"); // GET ATR VALUE t_ATR = All_MajorPair_ATR_Value[l, t_1, t_TF]; tstr_ATR = t_ATR.ToString(); // SET COLOR NAME ON POSITIVE OR NEGATIVE TOTAL PIP FROM OPEN if (t_Total_Pip >= 0) t_Clr = Clr_Positive; else t_Clr = Clr_Negative; // SET COLOR NAME ON POSITIVE OR NEGATIVE TOTAL PIP FROM OPEN if (t_Total_Pip >= t_ATR) t_Clr = Clr_Above; // DRAW ON CHART(OBJ_NAME, LINE#, COL#, Text_To_Display, ColorName); Draw_OnChart_C1("PrvMPips07" + temp_1, t_Line_no, (t_Col_no), tstr_Symbol_Code, Clr_PairListing); Draw_OnChart_C1("PrvMPips08" + temp_1, t_Line_no, (t_Col_no + t_Offset), tstr_TPips, t_Clr); // SET COLOR NAME ON POSITIVE OR NEGATIVE TOTAL PIP FROM OPEN if (t_Total_Pip >= 0) t_Clr = Clr_Positive; else t_Clr = Clr_Negative; // DRAW ATR VALUES ON CHART Draw_OnChart_C1("PrvMPips10" + temp_1, t_Line_no, (t_Col_no + t_Offset + 1), tstr_ATR, t_Clr); // INC. THE LINE # t_Line_no += 1; // LEAVE A BLANK LINE if (i == 3) t_Line_no += 1; } //END FOR I // ---------------------------------------------------------------------------------------------------------- // ON THE LAST LINE DISPLAY THE GRAND TOTAL OF ALL 28PAIRS : DAILY // SET COLOR NAME ON POSITIVE OR NEGATIVE TOTAL PIP FROM OPEN if (GTotal_28Pair_Total_Pips[l, t_TF] >= 0) t_Clr = Clr_Positive; else t_Clr = Clr_Negative; // DISPLAY GRAND_TOTAL OF TOTAL_DAILY_PIPS tstr_GrandTotal = GTotal_28Pair_Total_Pips[l, t_TF].ToString("0"); tstr_ATR = GTotal_28Pair_ATR_Value[l, t_TF].ToString(""); Draw_OnChart_C1("PrvMPips11" + temp_1, t_Line_no, (t_Col_no), "Total 28-Pairs", t_Clr); Draw_OnChart_C1("PrvMPips12" + temp_1, t_Line_no, (t_Col_no + t_Offset), tstr_GrandTotal, t_Clr); Draw_OnChart_C1("PrvMPips13" + temp_1, t_Line_no, (t_Col_no + t_Offset + 1), tstr_ATR, t_Clr); // INCREASE THE LINE SPACE FOR NEXT SET OF TIMEFRAME VALUES t_Line_no = t_Row; t_Col_no = t_Col_no + 5; } // END FOR L } //END MEHTOD Display_MajorPair_Hourly_Total_Pips ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Display_MajorPair_4Hour_Total_Pips /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void Display_MajorPair_4Hour_Total_Pips(int t_Row, int t_Col) { int t_Line_no = 0, t_Col_no = 0, t_Offset = 0, t_1 = 0; double t_Total_Pip = 0, t_2 = 0; double t_ATR; int t_TF; string tstr_TPips, tstr_Symbol_Code, temp_1, tstr_TFrame, tstr_GrandTotal, tstr_ATR; Colors t_Clr; //SET TIME FRAME 0=5MIN, 1=15MIN, 2=1HR, 3=4HR, 4=D, 5=W, 6=M. t_TF = 3; // SET THE LINE # AND COLUMN # t_Line_no = t_Row; t_Col_no = t_Col; t_Offset = 2; // DISPLAY AVERAGE VALUES --------------------------------------------------------------------------------- // COLUMN HEADINGs Draw_OnChart_C1("AvgPips01", (t_Line_no - 2), (t_Col_no), "AVERAGE", Clr_Heading_1); Draw_OnChart_C1("AvgPips02", (t_Line_no - 1), (t_Col_no), "MAJOR PAIR", Clr_Heading_1); Draw_OnChart_C1("AvgPips03", (t_Line_no - 2), (t_Col_no + t_Offset), "4-Hour", Clr_Heading_1); Draw_OnChart_C1("AvgPips04", (t_Line_no - 1), (t_Col_no + t_Offset), "AVG-Pips", Clr_Heading_1); //LOOP TO DISPLAY AVERAGE VALUES for (int i = 0; i < 8; i++) { // CONVERT t_Last_Price to STRING FOR UNIQUE OBJECT NAME IN Draw_OnChart_C1 METHOD temp_1 = i.ToString(); // SORT AS PER THE CURRENT SORTED MAJOR PAIR VALUES t_1 = Sorted_MajorPair_4Hour_Total_Pips[0, i]; // GET SYMBOL CODE AS PER THE t_Index tstr_Symbol_Code = i.ToString("0") + ". " + MajorPair_Headings[t_1]; // GET WEEKLY TOTAL PIPS MOVED FROM OPEN AND CONVERT TO STRING t_Total_Pip = Avg_All_MajorPair_Total_Pips[t_1, t_TF]; tstr_TPips = t_Total_Pip.ToString("0"); // GET TOTAL PIP FOR COMPARISON WITH AVERAGE TO SET THE COLOR t_2 = Math.Abs(All_MajorPair_Total_Pips[0, t_1, t_TF]); // SET COLOR NAME ON POSITIVE OR NEGATIVE TOTAL PIP FROM OPEN if (t_2 >= t_Total_Pip) t_Clr = Clr_Above; else t_Clr = Clr_Below; // DRAW ON CHART(OBJ_NAME, LINE#, COL#, Text_To_Display, ColorName); Draw_OnChart_C1("AVGPips05" + temp_1, t_Line_no, (t_Col_no), tstr_Symbol_Code, Clr_PairListing); Draw_OnChart_C1("AVGPips06" + temp_1, t_Line_no, (t_Col_no + t_Offset), tstr_TPips, t_Clr); // INC. THE LINE # t_Line_no += 1; // LEAVE A BLANK LINE if (i == 3) t_Line_no += 1; } //END FOR I // DISPLAY : AVERAGE OF 28 PAIRS TOTAL PIPS : CURRENT MONTH if (GTotal_28Pair_Total_Pips[0, t_TF] >= 0) t_Clr = Clr_Positive; else t_Clr = Clr_Negative; tstr_GrandTotal = (GTotal_28Pair_Total_Pips[0, t_TF] / 28).ToString("0"); Draw_OnChart_C1("AvgPips07", t_Line_no, (t_Col_no), "Avg of 28-Pairs", t_Clr); Draw_OnChart_C1("AvgPips08", t_Line_no, (t_Col_no + t_Offset), tstr_GrandTotal, t_Clr); // DISPLAY TOTAL PIPS --------------------------------------------------------------------------------- // RESET ROW COL POSITION TO DISPLAY THE NEXT LOOP VALUES t_Line_no = t_Row; t_Col_no = t_Col_no + 4; // LOOP TO DISPLAY LAST x VALUES for (int l = 0; l < LP1; l++) { // CONVERT t_Last_Price to STRING FOR UNIQUE OBJECT NAME IN Draw_OnChart_C1 METHOD temp_1 = l.ToString(); // GET THE TIME FRAME NAME tstr_TFrame = LP1_TF_Name[l]; // COLUMN HEADINGs Draw_OnChart_C1("PrvMPips01" + temp_1, (t_Line_no - 2), (t_Col_no), tstr_TFrame, Clr_Heading_1); Draw_OnChart_C1("PrvMPips02" + temp_1, (t_Line_no - 1), (t_Col_no), "MAJOR PAIR", Clr_Heading_1); Draw_OnChart_C1("PrvPMPips03" + temp_1, (t_Line_no - 2), (t_Col_no + t_Offset), "4-Hour", Clr_Heading_1); Draw_OnChart_C1("PrvPMPips04" + temp_1, (t_Line_no - 1), (t_Col_no + t_Offset), "T-Pips", Clr_Heading_1); Draw_OnChart_C1("PrvPMPips05" + temp_1, (t_Line_no - 2), (t_Col_no + t_Offset + 1), "4-Hour", Clr_Heading_1); Draw_OnChart_C1("PrvPMPips06" + temp_1, (t_Line_no - 1), (t_Col_no + t_Offset + 1), "ATR", Clr_Heading_1); // LOOP FOR 8 MAJOR-PAIRS : DISPLAY SYMBOL CODE AND TOTAL PIPS ON CHART for (int i = 0; i < 8; i++) { // GET THE SYMBOL INDEX FROM THE SORTED TEMP ARRAY t_1 = Sorted_MajorPair_4Hour_Total_Pips[l, i]; // GET SYMBOL CODE AS PER THE t_Index tstr_Symbol_Code = i.ToString("0") + ". " + MajorPair_Headings[t_1]; // GET WEEKLY TOTAL PIPS MOVED FROM OPEN AND CONVERT TO STRING t_Total_Pip = All_MajorPair_Total_Pips[l, t_1, t_TF]; tstr_TPips = t_Total_Pip.ToString("0"); // GET ATR VALUE t_ATR = All_MajorPair_ATR_Value[l, t_1, t_TF]; tstr_ATR = t_ATR.ToString(); // SET COLOR NAME ON POSITIVE OR NEGATIVE TOTAL PIP FROM OPEN if (t_Total_Pip >= 0) t_Clr = Clr_Positive; else t_Clr = Clr_Negative; // SET COLOR NAME ON POSITIVE OR NEGATIVE TOTAL PIP FROM OPEN if (t_Total_Pip >= t_ATR) t_Clr = Clr_Above; // DRAW ON CHART(OBJ_NAME, LINE#, COL#, Text_To_Display, ColorName); Draw_OnChart_C1("PrvMPips07" + temp_1, t_Line_no, (t_Col_no), tstr_Symbol_Code, Clr_PairListing); Draw_OnChart_C1("PrvMPips08" + temp_1, t_Line_no, (t_Col_no + t_Offset), tstr_TPips, t_Clr); // SET COLOR NAME ON POSITIVE OR NEGATIVE TOTAL PIP FROM OPEN if (t_Total_Pip >= 0) t_Clr = Clr_Positive; else t_Clr = Clr_Negative; // DRAW ATR VALUES ON CHART Draw_OnChart_C1("PrvMPips10" + temp_1, t_Line_no, (t_Col_no + t_Offset + 1), tstr_ATR, t_Clr); // INC. THE LINE # t_Line_no += 1; // LEAVE A BLANK LINE if (i == 3) t_Line_no += 1; } //END FOR I // ---------------------------------------------------------------------------------------------------------- // ON THE LAST LINE DISPLAY THE GRAND TOTAL OF ALL 28PAIRS : DAILY // SET COLOR NAME ON POSITIVE OR NEGATIVE TOTAL PIP FROM OPEN if (GTotal_28Pair_Total_Pips[l, t_TF] >= 0) t_Clr = Clr_Positive; else t_Clr = Clr_Negative; // DISPLAY GRAND_TOTAL OF TOTAL_DAILY_PIPS tstr_GrandTotal = GTotal_28Pair_Total_Pips[l, t_TF].ToString("0"); tstr_ATR = GTotal_28Pair_ATR_Value[l, t_TF].ToString(""); Draw_OnChart_C1("PrvMPips11" + temp_1, t_Line_no, (t_Col_no), "Total 28-Pairs", t_Clr); Draw_OnChart_C1("PrvMPips12" + temp_1, t_Line_no, (t_Col_no + t_Offset), tstr_GrandTotal, t_Clr); Draw_OnChart_C1("PrvMPips13" + temp_1, t_Line_no, (t_Col_no + t_Offset + 1), tstr_ATR, t_Clr); // INCREASE THE LINE SPACE FOR NEXT SET OF TIMEFRAME VALUES t_Line_no = t_Row; t_Col_no = t_Col_no + 5; } // END FOR L } //END MEHTOD Display_MajorPair_4Hour_Total_Pips ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Display_MajorPair_Daily_Total_Pips /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void Display_MajorPair_Daily_Total_Pips(int t_Row, int t_Col) { int t_Line_no = 0, t_Col_no = 0, t_Offset = 0, t_1 = 0; double t_Total_Pip = 0, t_2 = 0; double t_ATR; int t_TF; string tstr_TPips, tstr_Symbol_Code, temp_1, tstr_TFrame, tstr_GrandTotal, tstr_ATR; Colors t_Clr; //SET TIME FRAME 0=5MIN, 1=15MIN, 2=1HR, 3=4HR, 4=D, 5=W, 6=M. t_TF = 4; // SET THE LINE # AND COLUMN # t_Line_no = t_Row; t_Col_no = t_Col; t_Offset = 2; // DISPLAY AVERAGE VALUES --------------------------------------------------------------------------------- // COLUMN HEADINGs Draw_OnChart_C1("AvgPips01", (t_Line_no - 2), (t_Col_no), "AVERAGE", Clr_Heading_1); Draw_OnChart_C1("AvgPips02", (t_Line_no - 1), (t_Col_no), "MAJOR PAIR", Clr_Heading_1); Draw_OnChart_C1("AvgPips03", (t_Line_no - 2), (t_Col_no + t_Offset), "Daily", Clr_Heading_1); Draw_OnChart_C1("AvgPips04", (t_Line_no - 1), (t_Col_no + t_Offset), "AVG-Pips", Clr_Heading_1); //LOOP TO DISPLAY AVERAGE VALUES for (int i = 0; i < 8; i++) { // CONVERT t_Last_Price to STRING FOR UNIQUE OBJECT NAME IN Draw_OnChart_C1 METHOD temp_1 = i.ToString(); // SORT AS PER THE CURRENT SORTED MAJOR PAIR VALUES t_1 = Sorted_MajorPair_Daily_Total_Pips[0, i]; // GET SYMBOL CODE AS PER THE t_Index tstr_Symbol_Code = i.ToString("0") + ". " + MajorPair_Headings[t_1]; // GET WEEKLY TOTAL PIPS MOVED FROM OPEN AND CONVERT TO STRING t_Total_Pip = Avg_All_MajorPair_Total_Pips[t_1, t_TF]; tstr_TPips = t_Total_Pip.ToString("0"); // GET TOTAL PIP FOR COMPARISON WITH AVERAGE TO SET THE COLOR t_2 = Math.Abs(All_MajorPair_Total_Pips[0, t_1, t_TF]); // SET COLOR NAME ON POSITIVE OR NEGATIVE TOTAL PIP FROM OPEN if (t_2 >= t_Total_Pip) t_Clr = Clr_Above; else t_Clr = Clr_Below; // DRAW ON CHART(OBJ_NAME, LINE#, COL#, Text_To_Display, ColorName); Draw_OnChart_C1("AVGPips05" + temp_1, t_Line_no, (t_Col_no), tstr_Symbol_Code, Clr_PairListing); Draw_OnChart_C1("AVGPips06" + temp_1, t_Line_no, (t_Col_no + t_Offset), tstr_TPips, t_Clr); // INC. THE LINE # t_Line_no += 1; // LEAVE A BLANK LINE if (i == 3) t_Line_no += 1; } //END FOR I // DISPLAY : AVERAGE OF 28 PAIRS TOTAL PIPS : CURRENT MONTH if (GTotal_28Pair_Total_Pips[0, t_TF] >= 0) t_Clr = Clr_Positive; else t_Clr = Clr_Negative; tstr_GrandTotal = (GTotal_28Pair_Total_Pips[0, t_TF] / 28).ToString("0"); Draw_OnChart_C1("AvgPips07", t_Line_no, (t_Col_no), "Avg of 28-Pairs", t_Clr); Draw_OnChart_C1("AvgPips08", t_Line_no, (t_Col_no + t_Offset), tstr_GrandTotal, t_Clr); // DISPLAY TOTAL PIPS --------------------------------------------------------------------------------- // RESET ROW COL POSITION TO DISPLAY THE NEXT LOOP VALUES t_Line_no = t_Row; t_Col_no = t_Col_no + 4; // LOOP TO DISPLAY LAST x VALUES for (int l = 0; l < LP1; l++) { // CONVERT t_Last_Price to STRING FOR UNIQUE OBJECT NAME IN Draw_OnChart_C1 METHOD temp_1 = l.ToString(); // GET THE TIME FRAME NAME tstr_TFrame = LP1_TF_Name[l]; // COLUMN HEADINGs Draw_OnChart_C1("PrvMPips01" + temp_1, (t_Line_no - 2), (t_Col_no), tstr_TFrame, Clr_Heading_1); Draw_OnChart_C1("PrvMPips02" + temp_1, (t_Line_no - 1), (t_Col_no), "MAJOR PAIR", Clr_Heading_1); Draw_OnChart_C1("PrvPMPips03" + temp_1, (t_Line_no - 2), (t_Col_no + t_Offset), "Daily", Clr_Heading_1); Draw_OnChart_C1("PrvPMPips04" + temp_1, (t_Line_no - 1), (t_Col_no + t_Offset), "T-Pips", Clr_Heading_1); Draw_OnChart_C1("PrvPMPips05" + temp_1, (t_Line_no - 2), (t_Col_no + t_Offset + 1), "Daily", Clr_Heading_1); Draw_OnChart_C1("PrvPMPips06" + temp_1, (t_Line_no - 1), (t_Col_no + t_Offset + 1), "ATR", Clr_Heading_1); // LOOP FOR 8 MAJOR-PAIRS : DISPLAY SYMBOL CODE AND TOTAL PIPS ON CHART for (int i = 0; i < 8; i++) { // GET THE SYMBOL INDEX FROM THE SORTED TEMP ARRAY t_1 = Sorted_MajorPair_Daily_Total_Pips[l, i]; // GET SYMBOL CODE AS PER THE t_Index tstr_Symbol_Code = i.ToString("0") + ". " + MajorPair_Headings[t_1]; // GET WEEKLY TOTAL PIPS MOVED FROM OPEN AND CONVERT TO STRING t_Total_Pip = All_MajorPair_Total_Pips[l, t_1, t_TF]; tstr_TPips = t_Total_Pip.ToString("0"); // GET ATR VALUE t_ATR = All_MajorPair_ATR_Value[l, t_1, t_TF]; tstr_ATR = t_ATR.ToString(); // SET COLOR NAME ON POSITIVE OR NEGATIVE TOTAL PIP FROM OPEN if (t_Total_Pip >= 0) t_Clr = Clr_Positive; else t_Clr = Clr_Negative; // SET COLOR NAME ON POSITIVE OR NEGATIVE TOTAL PIP FROM OPEN if (t_Total_Pip >= t_ATR) t_Clr = Clr_Above; // DRAW ON CHART(OBJ_NAME, LINE#, COL#, Text_To_Display, ColorName); Draw_OnChart_C1("PrvMPips07" + temp_1, t_Line_no, (t_Col_no), tstr_Symbol_Code, Clr_PairListing); Draw_OnChart_C1("PrvMPips08" + temp_1, t_Line_no, (t_Col_no + t_Offset), tstr_TPips, t_Clr); // SET COLOR NAME ON POSITIVE OR NEGATIVE TOTAL PIP FROM OPEN if (t_Total_Pip >= 0) t_Clr = Clr_Positive; else t_Clr = Clr_Negative; // DRAW ATR VALUES ON CHART Draw_OnChart_C1("PrvMPips10" + temp_1, t_Line_no, (t_Col_no + t_Offset + 1), tstr_ATR, t_Clr); // INC. THE LINE # t_Line_no += 1; // LEAVE A BLANK LINE if (i == 3) t_Line_no += 1; } //END FOR I // ---------------------------------------------------------------------------------------------------------- // ON THE LAST LINE DISPLAY THE GRAND TOTAL OF ALL 28PAIRS : DAILY // SET COLOR NAME ON POSITIVE OR NEGATIVE TOTAL PIP FROM OPEN if (GTotal_28Pair_Total_Pips[l, t_TF] >= 0) t_Clr = Clr_Positive; else t_Clr = Clr_Negative; // DISPLAY GRAND_TOTAL OF TOTAL_DAILY_PIPS tstr_GrandTotal = GTotal_28Pair_Total_Pips[l, t_TF].ToString("0"); tstr_ATR = GTotal_28Pair_ATR_Value[l, t_TF].ToString(""); Draw_OnChart_C1("PrvMPips11" + temp_1, t_Line_no, (t_Col_no), "Total 28-Pairs", t_Clr); Draw_OnChart_C1("PrvMPips12" + temp_1, t_Line_no, (t_Col_no + t_Offset), tstr_GrandTotal, t_Clr); Draw_OnChart_C1("PrvMPips13" + temp_1, t_Line_no, (t_Col_no + t_Offset + 1), tstr_ATR, t_Clr); // INCREASE THE LINE SPACE FOR NEXT SET OF TIMEFRAME VALUES t_Line_no = t_Row; t_Col_no = t_Col_no + 5; } // END FOR L } //END MEHTOD Display_MajorPair_Daily_Total_Pips ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Display_MajorPair_Weekly_Total_Pips /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void Display_MajorPair_Weekly_Total_Pips(int t_Row, int t_Col) { int t_Line_no = 0, t_Col_no = 0, t_Offset = 0, t_1 = 0; double t_Total_Pip = 0, t_2 = 0; double t_ATR; int t_TF; string tstr_TPips, tstr_Symbol_Code, temp_1, tstr_TFrame, tstr_GrandTotal, tstr_ATR; Colors t_Clr; //SET TIME FRAME 0=5MIN, 1=15MIN, 2=1HR, 3=4HR, 4=D, 5=W, 6=M. t_TF = 5; // SET THE LINE # AND COLUMN # t_Line_no = t_Row; t_Col_no = t_Col; t_Offset = 2; // DISPLAY AVERAGE VALUES --------------------------------------------------------------------------------- // COLUMN HEADINGs Draw_OnChart_C1("AvgPips01", (t_Line_no - 2), (t_Col_no), "AVERAGE", Clr_Heading_1); Draw_OnChart_C1("AvgPips02", (t_Line_no - 1), (t_Col_no), "MAJOR PAIR", Clr_Heading_1); Draw_OnChart_C1("AvgPips03", (t_Line_no - 2), (t_Col_no + t_Offset), "Weekly", Clr_Heading_1); Draw_OnChart_C1("AvgPips04", (t_Line_no - 1), (t_Col_no + t_Offset), "AVG-Pips", Clr_Heading_1); //LOOP TO DISPLAY AVERAGE VALUES for (int i = 0; i < 8; i++) { // CONVERT t_Last_Price to STRING FOR UNIQUE OBJECT NAME IN Draw_OnChart_C1 METHOD temp_1 = i.ToString(); // SORT AS PER THE CURRENT SORTED MAJOR PAIR VALUES t_1 = Sorted_MajorPair_Weekly_Total_Pips[0, i]; // GET SYMBOL CODE AS PER THE t_Index tstr_Symbol_Code = i.ToString("0") + ". " + MajorPair_Headings[t_1]; // GET WEEKLY TOTAL PIPS MOVED FROM OPEN AND CONVERT TO STRING t_Total_Pip = Avg_All_MajorPair_Total_Pips[t_1, t_TF]; tstr_TPips = t_Total_Pip.ToString("0"); // GET TOTAL PIP FOR COMPARISON WITH AVERAGE TO SET THE COLOR t_2 = Math.Abs(All_MajorPair_Total_Pips[0, t_1, t_TF]); // SET COLOR NAME ON POSITIVE OR NEGATIVE TOTAL PIP FROM OPEN if (t_2 >= t_Total_Pip) t_Clr = Clr_Above; else t_Clr = Clr_Below; // DRAW ON CHART(OBJ_NAME, LINE#, COL#, Text_To_Display, ColorName); Draw_OnChart_C1("AVGPips05" + temp_1, t_Line_no, (t_Col_no), tstr_Symbol_Code, Clr_PairListing); Draw_OnChart_C1("AVGPips06" + temp_1, t_Line_no, (t_Col_no + t_Offset), tstr_TPips, t_Clr); // INC. THE LINE # t_Line_no += 1; // LEAVE A BLANK LINE if (i == 3) t_Line_no += 1; } //END FOR I // DISPLAY : AVERAGE OF 28 PAIRS TOTAL PIPS : CURRENT MONTH if (GTotal_28Pair_Total_Pips[0, t_TF] >= 0) t_Clr = Clr_Positive; else t_Clr = Clr_Negative; tstr_GrandTotal = (GTotal_28Pair_Total_Pips[0, t_TF] / 28).ToString("0"); Draw_OnChart_C1("AvgPips07", t_Line_no, (t_Col_no), "Avg of 28-Pairs", t_Clr); Draw_OnChart_C1("AvgPips08", t_Line_no, (t_Col_no + t_Offset), tstr_GrandTotal, t_Clr); // DISPLAY TOTAL PIPS --------------------------------------------------------------------------------- // RESET ROW COL POSITION TO DISPLAY THE NEXT LOOP VALUES t_Line_no = t_Row; t_Col_no = t_Col_no + 4; // LOOP TO DISPLAY LAST x VALUES for (int l = 0; l < LP1; l++) { // CONVERT t_Last_Price to STRING FOR UNIQUE OBJECT NAME IN Draw_OnChart_C1 METHOD temp_1 = l.ToString(); // GET THE TIME FRAME NAME tstr_TFrame = LP1_TF_Name[l]; // COLUMN HEADINGs Draw_OnChart_C1("PrvMPips01" + temp_1, (t_Line_no - 2), (t_Col_no), tstr_TFrame, Clr_Heading_1); Draw_OnChart_C1("PrvMPips02" + temp_1, (t_Line_no - 1), (t_Col_no), "MAJOR PAIR", Clr_Heading_1); Draw_OnChart_C1("PrvPMPips03" + temp_1, (t_Line_no - 2), (t_Col_no + t_Offset), "Week", Clr_Heading_1); Draw_OnChart_C1("PrvPMPips04" + temp_1, (t_Line_no - 1), (t_Col_no + t_Offset), "T-Pips", Clr_Heading_1); Draw_OnChart_C1("PrvPMPips05" + temp_1, (t_Line_no - 2), (t_Col_no + t_Offset + 1), "Week", Clr_Heading_1); Draw_OnChart_C1("PrvPMPips06" + temp_1, (t_Line_no - 1), (t_Col_no + t_Offset + 1), "ATR", Clr_Heading_1); // LOOP FOR 8 MAJOR-PAIRS : DISPLAY SYMBOL CODE AND TOTAL PIPS ON CHART for (int i = 0; i < 8; i++) { // GET THE SYMBOL INDEX FROM THE SORTED TEMP ARRAY t_1 = Sorted_MajorPair_Weekly_Total_Pips[l, i]; // GET SYMBOL CODE AS PER THE t_Index tstr_Symbol_Code = i.ToString("0") + ". " + MajorPair_Headings[t_1]; // GET WEEKLY TOTAL PIPS MOVED FROM OPEN AND CONVERT TO STRING t_Total_Pip = All_MajorPair_Total_Pips[l, t_1, t_TF]; tstr_TPips = t_Total_Pip.ToString("0"); // GET ATR VALUE t_ATR = All_MajorPair_ATR_Value[l, t_1, t_TF]; tstr_ATR = t_ATR.ToString(); // SET COLOR NAME ON POSITIVE OR NEGATIVE TOTAL PIP FROM OPEN if (t_Total_Pip >= 0) t_Clr = Clr_Positive; else t_Clr = Clr_Negative; // SET COLOR NAME ON POSITIVE OR NEGATIVE TOTAL PIP FROM OPEN if (t_Total_Pip >= t_ATR) t_Clr = Clr_Above; // DRAW ON CHART(OBJ_NAME, LINE#, COL#, Text_To_Display, ColorName); Draw_OnChart_C1("PrvMPips07" + temp_1, t_Line_no, (t_Col_no), tstr_Symbol_Code, Clr_PairListing); Draw_OnChart_C1("PrvMPips08" + temp_1, t_Line_no, (t_Col_no + t_Offset), tstr_TPips, t_Clr); // SET COLOR NAME ON POSITIVE OR NEGATIVE TOTAL PIP FROM OPEN if (t_Total_Pip >= 0) t_Clr = Clr_Positive; else t_Clr = Clr_Negative; // DRAW ATR VALUES ON CHART Draw_OnChart_C1("PrvMPips10" + temp_1, t_Line_no, (t_Col_no + t_Offset + 1), tstr_ATR, t_Clr); // INC. THE LINE # t_Line_no += 1; // LEAVE A BLANK LINE if (i == 3) t_Line_no += 1; } //END FOR I // ---------------------------------------------------------------------------------------------------------- // ON THE LAST LINE DISPLAY THE GRAND TOTAL OF ALL 28PAIRS : DAILY // SET COLOR NAME ON POSITIVE OR NEGATIVE TOTAL PIP FROM OPEN if (GTotal_28Pair_Total_Pips[l, t_TF] >= 0) t_Clr = Clr_Positive; else t_Clr = Clr_Negative; // DISPLAY GRAND_TOTAL OF TOTAL_DAILY_PIPS tstr_GrandTotal = GTotal_28Pair_Total_Pips[l, t_TF].ToString("0"); tstr_ATR = GTotal_28Pair_ATR_Value[l, t_TF].ToString(""); Draw_OnChart_C1("PrvMPips11" + temp_1, t_Line_no, (t_Col_no), "Total 28-Pairs", t_Clr); Draw_OnChart_C1("PrvMPips12" + temp_1, t_Line_no, (t_Col_no + t_Offset), tstr_GrandTotal, t_Clr); Draw_OnChart_C1("PrvMPips13" + temp_1, t_Line_no, (t_Col_no + t_Offset + 1), tstr_ATR, t_Clr); // INCREASE THE LINE SPACE FOR NEXT SET OF TIMEFRAME VALUES t_Line_no = t_Row; t_Col_no = t_Col_no + 5; } // END FOR L } //END MEHTOD Display_MajorPair_Weekly_Total_Pips ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Display_MajorPair_Monthly_Total_Pips /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void Display_MajorPair_Monthly_Total_Pips(int t_Row, int t_Col) { int t_Line_no = 0, t_Col_no = 0, t_Offset = 0, t_1 = 0; double t_Total_Pip = 0, t_2 = 0; double t_ATR; int t_TF; string tstr_TPips, tstr_Symbol_Code, temp_1, tstr_TFrame, tstr_GrandTotal, tstr_ATR; Colors t_Clr; //SET TIME FRAME 0=5MIN, 1=15MIN, 2=1HR, 3=4HR, 4=D, 5=W, 6=M. t_TF = 6; // SET THE LINE # AND COLUMN # t_Line_no = t_Row; t_Col_no = t_Col; t_Offset = 2; // DISPLAY AVERAGE VALUES --------------------------------------------------------------------------------- // COLUMN HEADINGs Draw_OnChart_C1("AvgPips01", (t_Line_no - 2), (t_Col_no), "AVERAGE", Clr_Heading_1); Draw_OnChart_C1("AvgPips02", (t_Line_no - 1), (t_Col_no), "MAJOR PAIR", Clr_Heading_1); Draw_OnChart_C1("AvgPips03", (t_Line_no - 2), (t_Col_no + t_Offset), "Month", Clr_Heading_1); Draw_OnChart_C1("AvgPips04", (t_Line_no - 1), (t_Col_no + t_Offset), "AVG-Pips", Clr_Heading_1); //LOOP TO DISPLAY AVERAGE VALUES for (int i = 0; i < 8; i++) { // CONVERT t_Last_Price to STRING FOR UNIQUE OBJECT NAME IN Draw_OnChart_C1 METHOD temp_1 = i.ToString(); // SORT AS PER THE CURRENT SORTED MAJOR PAIR VALUES t_1 = Sorted_MajorPair_Monthly_Total_Pips[0, i]; // GET SYMBOL CODE AS PER THE t_Index tstr_Symbol_Code = i.ToString("0") + ". " + MajorPair_Headings[t_1]; // GET WEEKLY TOTAL PIPS MOVED FROM OPEN AND CONVERT TO STRING t_Total_Pip = Avg_All_MajorPair_Total_Pips[t_1, t_TF]; tstr_TPips = t_Total_Pip.ToString("0"); // GET TOTAL PIP FOR COMPARISON WITH AVERAGE TO SET THE COLOR t_2 = Math.Abs(All_MajorPair_Total_Pips[0, t_1, t_TF]); // SET COLOR NAME ON POSITIVE OR NEGATIVE TOTAL PIP FROM OPEN if (t_2 >= t_Total_Pip) t_Clr = Clr_Above; else t_Clr = Clr_Below; // DRAW ON CHART(OBJ_NAME, LINE#, COL#, Text_To_Display, ColorName); Draw_OnChart_C1("AVGPips05" + temp_1, t_Line_no, (t_Col_no), tstr_Symbol_Code, Clr_PairListing); Draw_OnChart_C1("AVGPips06" + temp_1, t_Line_no, (t_Col_no + t_Offset), tstr_TPips, t_Clr); // INC. THE LINE # t_Line_no += 1; // LEAVE A BLANK LINE if (i == 3) t_Line_no += 1; } //END FOR I // DISPLAY : AVERAGE OF 28 PAIRS TOTAL PIPS : CURRENT MONTH if (GTotal_28Pair_Total_Pips[0, t_TF] >= 0) t_Clr = Clr_Positive; else t_Clr = Clr_Negative; tstr_GrandTotal = (GTotal_28Pair_Total_Pips[0, t_TF] / 28).ToString("0"); Draw_OnChart_C1("AvgPips07", t_Line_no, (t_Col_no), "Avg of 28-Pairs", t_Clr); Draw_OnChart_C1("AvgPips08", t_Line_no, (t_Col_no + t_Offset), tstr_GrandTotal, t_Clr); // DISPLAY TOTAL PIPS --------------------------------------------------------------------------------- // RESET ROW COL POSITION TO DISPLAY THE NEXT LOOP VALUES t_Line_no = t_Row; t_Col_no = t_Col_no + 4; // LOOP TO DISPLAY LAST x VALUES for (int l = 0; l < LP1; l++) { // CONVERT t_Last_Price to STRING FOR UNIQUE OBJECT NAME IN Draw_OnChart_C1 METHOD temp_1 = l.ToString(); // GET THE TIME FRAME NAME tstr_TFrame = LP1_TF_Name[l]; // COLUMN HEADINGs Draw_OnChart_C1("PrvMPips01" + temp_1, (t_Line_no - 2), (t_Col_no), tstr_TFrame, Clr_Heading_1); Draw_OnChart_C1("PrvMPips02" + temp_1, (t_Line_no - 1), (t_Col_no), "MAJOR PAIR", Clr_Heading_1); Draw_OnChart_C1("PrvPMPips03" + temp_1, (t_Line_no - 2), (t_Col_no + t_Offset), "Month", Clr_Heading_1); Draw_OnChart_C1("PrvPMPips04" + temp_1, (t_Line_no - 1), (t_Col_no + t_Offset), "T-Pips", Clr_Heading_1); Draw_OnChart_C1("PrvPMPips05" + temp_1, (t_Line_no - 2), (t_Col_no + t_Offset + 1), "Month", Clr_Heading_1); Draw_OnChart_C1("PrvPMPips06" + temp_1, (t_Line_no - 1), (t_Col_no + t_Offset + 1), "ATR", Clr_Heading_1); // LOOP FOR 8 MAJOR-PAIRS : DISPLAY SYMBOL CODE AND TOTAL PIPS ON CHART for (int i = 0; i < 8; i++) { // GET THE SYMBOL INDEX FROM THE SORTED TEMP ARRAY t_1 = Sorted_MajorPair_Monthly_Total_Pips[l, i]; // GET SYMBOL CODE AS PER THE t_Index tstr_Symbol_Code = i.ToString("0") + ". " + MajorPair_Headings[t_1]; // GET WEEKLY TOTAL PIPS MOVED FROM OPEN AND CONVERT TO STRING t_Total_Pip = All_MajorPair_Total_Pips[l, t_1, t_TF]; tstr_TPips = t_Total_Pip.ToString("0"); // GET ATR VALUE t_ATR = All_MajorPair_ATR_Value[l, t_1, t_TF]; tstr_ATR = t_ATR.ToString(); // SET COLOR NAME ON POSITIVE OR NEGATIVE TOTAL PIP FROM OPEN if (t_Total_Pip >= 0) t_Clr = Clr_Positive; else t_Clr = Clr_Negative; // SET COLOR NAME ON POSITIVE OR NEGATIVE TOTAL PIP FROM OPEN if (t_Total_Pip >= t_ATR) t_Clr = Clr_Above; // DRAW ON CHART(OBJ_NAME, LINE#, COL#, Text_To_Display, ColorName); Draw_OnChart_C1("PrvMPips07" + temp_1, t_Line_no, (t_Col_no), tstr_Symbol_Code, Clr_PairListing); Draw_OnChart_C1("PrvMPips08" + temp_1, t_Line_no, (t_Col_no + t_Offset), tstr_TPips, t_Clr); // SET COLOR NAME ON POSITIVE OR NEGATIVE TOTAL PIP FROM OPEN if (t_Total_Pip >= 0) t_Clr = Clr_Positive; else t_Clr = Clr_Negative; // DRAW ATR VALUES ON CHART Draw_OnChart_C1("PrvMPips10" + temp_1, t_Line_no, (t_Col_no + t_Offset + 1), tstr_ATR, t_Clr); // INC. THE LINE # t_Line_no += 1; // LEAVE A BLANK LINE if (i == 3) t_Line_no += 1; } //END FOR I // ---------------------------------------------------------------------------------------------------------- // ON THE LAST LINE DISPLAY THE GRAND TOTAL OF ALL 28PAIRS : DAILY // SET COLOR NAME ON POSITIVE OR NEGATIVE TOTAL PIP FROM OPEN if (GTotal_28Pair_Total_Pips[l, t_TF] >= 0) t_Clr = Clr_Positive; else t_Clr = Clr_Negative; // DISPLAY GRAND_TOTAL OF TOTAL_DAILY_PIPS tstr_GrandTotal = GTotal_28Pair_Total_Pips[l, t_TF].ToString("0"); tstr_ATR = GTotal_28Pair_ATR_Value[l, t_TF].ToString(""); Draw_OnChart_C1("PrvMPips11" + temp_1, t_Line_no, (t_Col_no), "Total 28-Pairs", t_Clr); Draw_OnChart_C1("PrvMPips12" + temp_1, t_Line_no, (t_Col_no + t_Offset), tstr_GrandTotal, t_Clr); Draw_OnChart_C1("PrvMPips13" + temp_1, t_Line_no, (t_Col_no + t_Offset + 1), tstr_ATR, t_Clr); // INCREASE THE LINE SPACE FOR NEXT SET OF TIMEFRAME VALUES t_Line_no = t_Row; t_Col_no = t_Col_no + 5; } // END FOR L } //END MEHTOD Display_MajorPair_Monthly_Total_Pips ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Get_MajorPair_Total_Pips /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void Get_MajorPair_Total_Pips() { string tstr_s1; int t_index; double t_Total = 0, t_GrandTotal = 0; // LOOP FOR PREVIOUS PRICES : LP IS A GLOBAL VARIABLE TO SET THE LOOP LIMIT for (int l = 0; l < LP1; l++) { // FOR : 5MIN, 15MIN, 1HOUR, 4HOUR, DAILY, WEEKLY, MONTHLY for (int k = 0; k < 7; k++) { // 8 - MAJOR PAIR for (int i = 0; i < 8; i++) { // 7 - SUB PAIR for (int j = 0; j < 7; j++) { tstr_s1 = MajorPair_Combo[i, j]; // MEHTOD CALL t_index = Return_Pair_Index_Position(tstr_s1); // GET 15-MINS TOTAL PIPS t_Total += (All_28Pair_Total_Pips[l, t_index, k] * Base_Currency[i, j]); All_MajorPair_Total_Pips[l, i, k] = t_Total; } //END FOR j //RESET t_Total = 0; // GRAND TOTAL OF ALL VALUES t_GrandTotal += All_MajorPair_Total_Pips[l, i, k]; GTotal_MajorPair_Total_Pips[l, k] = t_GrandTotal; } //END FOR i //RESET t_GrandTotal = 0; } //END FOR k } // END FOR l } //END MEHTOD Get_MajorPair_Total_Pips ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Get_MajorPair_ATR_Values /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void Get_MajorPair_ATR_Values() { string tstr_s1; int t_index; double t_Total = 0, t_GrandTotal = 0; // LOOP FOR PREVIOUS PRICES : LP IS A GLOBAL VARIABLE TO SET THE LOOP LIMIT for (int l = 0; l < LP1; l++) { // FOR : 5MIN, 15MIN, 1HOUR, 4HOUR, DAILY, WEEKLY, MONTHLY for (int k = 0; k < 7; k++) { // 8 - MAJOR PAIR for (int i = 0; i < 8; i++) { // 7 - SUB PAIR for (int j = 0; j < 7; j++) { tstr_s1 = MajorPair_Combo[i, j]; // MEHTOD CALL t_index = Return_Pair_Index_Position(tstr_s1); // GET 15-MINS TOTAL PIPS t_Total += (All_28Pair_ATR_Value[l, t_index, k]); All_MajorPair_ATR_Value[l, i, k] = t_Total; } //END FOR j //RESET t_Total = 0; // GRAND TOTAL OF ALL VALUES t_GrandTotal += All_MajorPair_ATR_Value[l, i, k]; GTotal_MajorPair_ATR_Value[l, k] = t_GrandTotal; } //END FOR i //RESET t_GrandTotal = 0; } //END FOR k } // END FOR l } //END MEHTOD Get_MajorPair_ATR_Values ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Load_28Pair_ATR_Values /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void Load_28Pair_ATR_Values() { double t_PipSize; double t_0 = 0, t_1 = 0, t_2 = 0, t_3 = 0, t_4 = 0, t_5 = 0, t_6 = 0; Symbol t_Symbol; string tstr_Symbol_Code; int t_ind; // LOOP FOR PREVIOUS PRICES : LP IS A GLOBAL VARIABLE TO SET THE LOOP LIMIT for (int l = 0; l < LP1; l++) { t_ind = LP1_Array_Open[l]; //LOOP FOR 28 PAIRS for (int i = 0; i < 28; i++) { // GET SYMBOL t_Symbol = Get_28Pair_Symbol(i); tstr_Symbol_Code = t_Symbol.Code.ToString(); t_PipSize = t_Symbol.PipSize; //GET A TEMP VARIABLE FOR MARKETDATA FOR THE SYMBOL AND TIME FRAME SPECIFIED BY USER // 5-MIN var temp_1 = MarketData.GetSeries(tstr_Symbol_Code, TF_5min); ATR_Indicator_1 = Indicators.AverageTrueRange(temp_1, ATR_P_5min, p_ATR_MA_Type); // 15-MIN var temp_2 = MarketData.GetSeries(tstr_Symbol_Code, TF_15min); ATR_Indicator_2 = Indicators.AverageTrueRange(temp_2, ATR_P_15min, p_ATR_MA_Type); // 1-HOUR var temp_3 = MarketData.GetSeries(tstr_Symbol_Code, TF_1Hr); ATR_Indicator_3 = Indicators.AverageTrueRange(temp_3, ATR_P_1Hr, p_ATR_MA_Type); // 4-HOUR var temp_4 = MarketData.GetSeries(tstr_Symbol_Code, TF_4Hr); ATR_Indicator_4 = Indicators.AverageTrueRange(temp_4, ATR_P_4Hr, p_ATR_MA_Type); // Daily var temp_5 = MarketData.GetSeries(tstr_Symbol_Code, TF_D); ATR_Indicator_5 = Indicators.AverageTrueRange(temp_5, ATR_P_D, p_ATR_MA_Type); // Weekly var temp_6 = MarketData.GetSeries(tstr_Symbol_Code, TF_Wk); ATR_Indicator_6 = Indicators.AverageTrueRange(temp_6, ATR_P_Wk, p_ATR_MA_Type); // Monthly var temp_7 = MarketData.GetSeries(tstr_Symbol_Code, TF_Mt); ATR_Indicator_7 = Indicators.AverageTrueRange(temp_7, ATR_P_Mt, p_ATR_MA_Type); //STORE ATR VALUE IN THE ARRAY. ARRAY STARTS FROM 0 INDEX // 5-MIN All_28Pair_ATR_Value[l, i, 0] = Math.Round(ATR_Indicator_1.Result.Last(t_ind) / t_PipSize, 0); t_0 += All_28Pair_ATR_Value[l, i, 0]; // 15-MIN All_28Pair_ATR_Value[l, i, 1] = Math.Round(ATR_Indicator_2.Result.Last(t_ind) / t_PipSize, 0); t_1 += All_28Pair_ATR_Value[l, i, 1]; // 1-HOUR All_28Pair_ATR_Value[l, i, 2] = Math.Round(ATR_Indicator_3.Result.Last(t_ind) / t_PipSize, 0); t_2 += All_28Pair_ATR_Value[l, i, 2]; // 4-HOUR All_28Pair_ATR_Value[l, i, 3] = Math.Round(ATR_Indicator_4.Result.Last(t_ind) / t_PipSize, 0); t_3 += All_28Pair_ATR_Value[l, i, 3]; // DAILY All_28Pair_ATR_Value[l, i, 4] = Math.Round(ATR_Indicator_5.Result.Last(t_ind) / t_PipSize, 0); t_4 += All_28Pair_ATR_Value[l, i, 4]; // WEEKLY All_28Pair_ATR_Value[l, i, 5] = Math.Round(ATR_Indicator_6.Result.Last(t_ind) / t_PipSize, 0); t_5 += All_28Pair_ATR_Value[l, i, 5]; // MONTHLY All_28Pair_ATR_Value[l, i, 6] = Math.Round(ATR_Indicator_7.Result.Last(t_ind) / t_PipSize, 0); t_6 += All_28Pair_ATR_Value[l, i, 6]; } //END FOR i //UPDATE THE GRANDTOTAL OF "TOTAL ATR VALUE" GTotal_28Pair_ATR_Value[l, 0] = t_0; GTotal_28Pair_ATR_Value[l, 1] = t_1; GTotal_28Pair_ATR_Value[l, 2] = t_2; GTotal_28Pair_ATR_Value[l, 3] = t_3; GTotal_28Pair_ATR_Value[l, 4] = t_4; GTotal_28Pair_ATR_Value[l, 5] = t_5; GTotal_28Pair_ATR_Value[l, 6] = t_6; //RESET t_0 = 0; t_1 = 0; t_2 = 0; t_3 = 0; t_4 = 0; t_5 = 0; t_6 = 0; } // END FOR l } //END MEHTOD Load_28Pair_ATR_Values ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Get_28Pair_TOTAL_Pips_from_Open /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void Get_28Pair_TOTAL_Pips_from_Open() { //Print("Inside : TOTAL_Pips_from_Open"); double t_PipSize; double t_0 = 0, t_1 = 0, t_2 = 0, t_3 = 0, t_4 = 0, t_5 = 0, t_6 = 0; double t_Close_P1, t_Close_P2, t_Close_P3, t_Close_P4, t_Close_P5, t_Close_P6, t_Close_P7; double t_Open_P1, t_Open_P2, t_Open_P3, t_Open_P4, t_Open_P5, t_Open_P6, t_Open_P7; // LOOP FOR PREVIOUS PRICES : LP IS A GLOBAL VARIABLE TO SET THE LOOP LIMIT for (int l = 0; l < LP1; l++) { //LOOP FOR 28 PAIRS for (int i = 0; i < 28; i++) { // LOAD PIP SIZE t_PipSize = All_28Pair_Pip_Size[i]; // ---------- LOAD CLOSE PRICE : ALL TIME FRAMES t_Close_P1 = All_28Pair_Close_Price[l, i, 0]; t_Close_P2 = All_28Pair_Close_Price[l, i, 1]; t_Close_P3 = All_28Pair_Close_Price[l, i, 2]; t_Close_P4 = All_28Pair_Close_Price[l, i, 3]; t_Close_P5 = All_28Pair_Close_Price[l, i, 4]; t_Close_P6 = All_28Pair_Close_Price[l, i, 5]; t_Close_P7 = All_28Pair_Close_Price[l, i, 6]; // ---------- LOAD OPEN PRICES : ALL TRIME FRAMES t_Open_P1 = All_28Pair_Open_Price[l, i, 0]; t_Open_P2 = All_28Pair_Open_Price[l, i, 1]; t_Open_P3 = All_28Pair_Open_Price[l, i, 2]; t_Open_P4 = All_28Pair_Open_Price[l, i, 3]; t_Open_P5 = All_28Pair_Open_Price[l, i, 4]; t_Open_P6 = All_28Pair_Open_Price[l, i, 5]; t_Open_P7 = All_28Pair_Open_Price[l, i, 6]; //STORE THE OPEN.LAST VALUE IN THE ARRAY. ARRAY STARTS FROM 0 INDEX // 5-MIN All_28Pair_Total_Pips[l, i, 0] = Math.Round(((t_Close_P1 - t_Open_P1) / t_PipSize), 0); t_0 += All_28Pair_Total_Pips[l, i, 0]; // 15-MIN All_28Pair_Total_Pips[l, i, 1] = Math.Round(((t_Close_P2 - t_Open_P2) / t_PipSize), 0); t_1 += All_28Pair_Total_Pips[l, i, 1]; // 1-HOUR All_28Pair_Total_Pips[l, i, 2] = Math.Round(((t_Close_P3 - t_Open_P3) / t_PipSize), 0); t_2 += All_28Pair_Total_Pips[l, i, 2]; // 4-HOUR All_28Pair_Total_Pips[l, i, 3] = Math.Round(((t_Close_P4 - t_Open_P4) / t_PipSize), 0); t_3 += All_28Pair_Total_Pips[l, i, 3]; // DAILY All_28Pair_Total_Pips[l, i, 4] = Math.Round(((t_Close_P5 - t_Open_P5) / t_PipSize), 0); t_4 += All_28Pair_Total_Pips[l, i, 4]; // WEEKLY All_28Pair_Total_Pips[l, i, 5] = Math.Round(((t_Close_P6 - t_Open_P6) / t_PipSize), 0); t_5 += All_28Pair_Total_Pips[l, i, 5]; // MONTHLY All_28Pair_Total_Pips[l, i, 6] = Math.Round(((t_Close_P7 - t_Open_P7) / t_PipSize), 0); t_6 += All_28Pair_Total_Pips[l, i, 6]; //UPDATE THE GRANDTOTAL OF "TOTAL PIPS" MOVED FROM OPEN PRICES : DAILY, WEEKLY, MONTHLY GTotal_28Pair_Total_Pips[l, 0] = t_0; GTotal_28Pair_Total_Pips[l, 1] = t_1; GTotal_28Pair_Total_Pips[l, 2] = t_2; GTotal_28Pair_Total_Pips[l, 3] = t_3; GTotal_28Pair_Total_Pips[l, 4] = t_4; GTotal_28Pair_Total_Pips[l, 5] = t_5; GTotal_28Pair_Total_Pips[l, 6] = t_6; } //END FOR i //RESET t_0 = 0; t_1 = 0; t_2 = 0; t_3 = 0; t_4 = 0; t_5 = 0; t_6 = 0; } // END FOR L } //END MEHTOD Get_28Pair_TOTAL_Pips_from_Open ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Load_28Pair_HiLo_Prices /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void Load_28Pair_HiLo_Prices() { //Print("Inside : -PREVIOUS- : Close AND HiLo Prices"); //double t_1; Symbol t_Symbol; string tstr_Symbol_Code; int t_ind; // LOOP FOR PREVIOUS PRICES : LP IS A GLOBAL VARIABLE TO SET THE LOOP LIMIT for (int l = 0; l < LP1; l++) { t_ind = LP1_Array_Close[l]; //LOOP FOR 28 PAIRS for (int i = 0; i < 28; i++) { // GET SYMBOL t_Symbol = Get_28Pair_Symbol(i); tstr_Symbol_Code = t_Symbol.Code.ToString(); //GET 5-MIN OPEN PRICES FOR THE SYMBOL var temp_1 = MarketData.GetSeries(tstr_Symbol_Code, TF_5min); //GET 15-MIN OPEN PRICES FOR THE SYMBOL var temp_2 = MarketData.GetSeries(tstr_Symbol_Code, TF_15min); //GET 1-HOUR OPEN PRICES FOR THE SYMBOL var temp_3 = MarketData.GetSeries(tstr_Symbol_Code, TF_1Hr); //GET 4-hOUR OPEN PRICES FOR THE SYMBOL var temp_4 = MarketData.GetSeries(tstr_Symbol_Code, TF_4Hr); //GET DAILY OPEN PRICES FOR THE SYMBOL var temp_5 = MarketData.GetSeries(tstr_Symbol_Code, TF_D); //GET Weekly OPEN PRICES FOR THE SYMBOL var temp_6 = MarketData.GetSeries(tstr_Symbol_Code, TF_Wk); //GET Monthly OPEN PRICES FOR THE SYMBOL var temp_7 = MarketData.GetSeries(tstr_Symbol_Code, TF_Mt); // ------------ HI-LO PRICES // 5-MIN All_28Pair_HiLo_Price[l, i, 0] = temp_1.High.Last(t_ind); All_28Pair_HiLo_Price[l, i, 1] = temp_1.Low.Last(t_ind); // 15-MIN All_28Pair_HiLo_Price[l, i, 2] = temp_2.High.Last(t_ind); All_28Pair_HiLo_Price[l, i, 3] = temp_2.Low.Last(t_ind); // 1-HOUR All_28Pair_HiLo_Price[l, i, 4] = temp_3.High.Last(t_ind); All_28Pair_HiLo_Price[l, i, 5] = temp_3.Low.Last(t_ind); // 4-HOUR All_28Pair_HiLo_Price[l, i, 6] = temp_4.High.Last(t_ind); All_28Pair_HiLo_Price[l, i, 7] = temp_4.Low.Last(t_ind); // DAILY All_28Pair_HiLo_Price[l, i, 8] = temp_5.High.Last(t_ind); All_28Pair_HiLo_Price[l, i, 9] = temp_5.Low.Last(t_ind); // WEEKLY All_28Pair_HiLo_Price[l, i, 10] = temp_6.High.Last(t_ind); All_28Pair_HiLo_Price[l, i, 11] = temp_6.Low.Last(t_ind); // MONTHLY All_28Pair_HiLo_Price[l, i, 12] = temp_7.High.Last(t_ind); All_28Pair_HiLo_Price[l, i, 13] = temp_7.Low.Last(t_ind); } //END FOR i } // END FOR l } //END METHOD Load_28Pair_HiLo_Prices ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Load_28Pair_Close_Prices /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void Load_28Pair_Close_Prices() { //Print("Inside : -PREVIOUS- : Close AND HiLo Prices"); //double t_1; Symbol t_Symbol; string tstr_Symbol_Code; int t_ind; // LOOP FOR PREVIOUS PRICES : LP IS A GLOBAL VARIABLE TO SET THE LOOP LIMIT for (int l = 0; l < LP1; l++) { t_ind = LP1_Array_Close[l]; //LOOP FOR 28 PAIRS for (int i = 0; i < 28; i++) { // GET SYMBOL t_Symbol = Get_28Pair_Symbol(i); tstr_Symbol_Code = t_Symbol.Code.ToString(); //GET 5-MIN OPEN PRICES FOR THE SYMBOL var temp_1 = MarketData.GetSeries(tstr_Symbol_Code, TF_5min); //GET 15-MIN OPEN PRICES FOR THE SYMBOL var temp_2 = MarketData.GetSeries(tstr_Symbol_Code, TF_15min); //GET 1-HOUR OPEN PRICES FOR THE SYMBOL var temp_3 = MarketData.GetSeries(tstr_Symbol_Code, TF_1Hr); //GET 4-hOUR OPEN PRICES FOR THE SYMBOL var temp_4 = MarketData.GetSeries(tstr_Symbol_Code, TF_4Hr); //GET DAILY OPEN PRICES FOR THE SYMBOL var temp_5 = MarketData.GetSeries(tstr_Symbol_Code, TF_D); //GET Weekly OPEN PRICES FOR THE SYMBOL var temp_6 = MarketData.GetSeries(tstr_Symbol_Code, TF_Wk); //GET Monthly OPEN PRICES FOR THE SYMBOL var temp_7 = MarketData.GetSeries(tstr_Symbol_Code, TF_Mt); // ----------- CLOSE PRICES // 5-MIN All_28Pair_Close_Price[l, i, 0] = temp_1.Close.Last(t_ind); // 15-MIN All_28Pair_Close_Price[l, i, 1] = temp_2.Close.Last(t_ind); // 1-HOUR All_28Pair_Close_Price[l, i, 2] = temp_3.Close.Last(t_ind); // 4-HOUR All_28Pair_Close_Price[l, i, 3] = temp_4.Close.Last(t_ind); // DAILY All_28Pair_Close_Price[l, i, 4] = temp_5.Close.Last(t_ind); // WEEKLY All_28Pair_Close_Price[l, i, 5] = temp_6.Close.Last(t_ind); // MONTHLY All_28Pair_Close_Price[l, i, 6] = temp_7.Close.Last(t_ind); } //END FOR i } // END FOR l } //END METHOD Load_28Pair_Close_Prices ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Load_28Pair_Open_Prices /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void Load_28Pair_Open_Prices() { //Print("Inside : CURRENT : Load 28Pair Open Prices"); Symbol t_Symbol; string tstr_Symbol_Code; int t_ind; // LOOP FOR PREVIOUS PRICES : LP IS A GLOBAL VARIABLE TO SET THE LOOP LIMIT for (int l = 0; l < LP1; l++) { t_ind = LP1_Array_Open[l]; for (int i = 0; i < 28; i++) { // GET SYMBOL t_Symbol = Get_28Pair_Symbol(i); tstr_Symbol_Code = t_Symbol.Code.ToString(); //GET 5-MIN OPEN PRICES FOR THE SYMBOL var temp_1 = MarketData.GetSeries(tstr_Symbol_Code, TF_5min); //GET 15-MIN OPEN PRICES FOR THE SYMBOL var temp_2 = MarketData.GetSeries(tstr_Symbol_Code, TF_15min); //GET 1-HOUR OPEN PRICES FOR THE SYMBOL var temp_3 = MarketData.GetSeries(tstr_Symbol_Code, TF_1Hr); //GET 4-hOUR OPEN PRICES FOR THE SYMBOL var temp_4 = MarketData.GetSeries(tstr_Symbol_Code, TF_4Hr); //GET DAILY OPEN PRICES FOR THE SYMBOL var temp_5 = MarketData.GetSeries(tstr_Symbol_Code, TF_D); //GET Weekly OPEN PRICES FOR THE SYMBOL var temp_6 = MarketData.GetSeries(tstr_Symbol_Code, TF_Wk); //GET Monthly OPEN PRICES FOR THE SYMBOL var temp_7 = MarketData.GetSeries(tstr_Symbol_Code, TF_Mt); /// ----------- OPEN PRICES // 5-MIN All_28Pair_Open_Price[l, i, 0] = temp_1.Open.Last(t_ind); // 15-MIN All_28Pair_Open_Price[l, i, 1] = temp_2.Open.Last(t_ind); // 1-HOUR All_28Pair_Open_Price[l, i, 2] = temp_3.Open.Last(t_ind); // 4-HOUR All_28Pair_Open_Price[l, i, 3] = temp_4.Open.Last(t_ind); // DAILY All_28Pair_Open_Price[l, i, 4] = temp_5.Open.Last(t_ind); // WEEKLY All_28Pair_Open_Price[l, i, 5] = temp_6.Open.Last(t_ind); // MONTHLY All_28Pair_Open_Price[l, i, 6] = temp_7.Open.Last(t_ind); } //END FOR i //Print("LP1 INDEX VALUE = " + t_ind); } // END FOR l } //END METHOD Load_28Pair_Open_Prices ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// OnSTART_Load_28Pair_Open_Prices /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void OnSTART_Load_28Pair_Open_Prices() { Print("Inside : FIRST TIME ONLY : GET 28-PAIR OPEN PRICES ON START"); Symbol t_Symbol; string tstr_Symbol_Code; double t_1; // GET 5 PAIRS OPEN PRICES for (int i = 0; i < 28; i++) { // GET SYMBOL t_Symbol = Get_28Pair_Symbol(i); tstr_Symbol_Code = t_Symbol.Code.ToString(); //GET 5-MIN OPEN PRICES FOR THE SYMBOL var temp_1 = MarketData.GetSeries(tstr_Symbol_Code, TF_5min); //GET 15-MIN OPEN PRICES FOR THE SYMBOL var temp_2 = MarketData.GetSeries(tstr_Symbol_Code, TF_15min); //GET 1-HOUR OPEN PRICES FOR THE SYMBOL var temp_3 = MarketData.GetSeries(tstr_Symbol_Code, TF_1Hr); //GET 4-hOUR OPEN PRICES FOR THE SYMBOL var temp_4 = MarketData.GetSeries(tstr_Symbol_Code, TF_4Hr); //GET DAILY OPEN PRICES FOR THE SYMBOL var temp_5 = MarketData.GetSeries(tstr_Symbol_Code, TF_D); //GET Weekly OPEN PRICES FOR THE SYMBOL var temp_6 = MarketData.GetSeries(tstr_Symbol_Code, TF_Wk); //GET Monthly OPEN PRICES FOR THE SYMBOL var temp_7 = MarketData.GetSeries(tstr_Symbol_Code, TF_Mt); /// ----------- OPEN PRICES // 5-MIN t_1 = temp_1.Open.LastValue; // 15-MIN t_1 = temp_2.Open.LastValue; // 1-HOUR t_1 = temp_3.Open.LastValue; // 4-HOUR t_1 = temp_4.Open.LastValue; // DAILY t_1 = temp_5.Open.LastValue; // WEEKLY t_1 = temp_6.Open.LastValue; // MONTHLY t_1 = temp_7.Open.LastValue; Print(i + ". " + tstr_Symbol_Code + " = " + t_1); } //END FOR i } //END METHOD OnSTART_Load_28Pair_Open_Prices ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Load_28Pair_PipSize /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void Load_28Pair_PipSize() { Print("Inside : Load 28Pair Pip-Size"); Symbol t_Symbol; // LOOP FOR 28 PAIRS for (int i = 0; i < 28; i++) { // GET SYMBOL t_Symbol = Get_28Pair_Symbol(i); All_28Pair_Pip_Size[i] = t_Symbol.PipSize; } //END FOR } //END METHOD Load_28Pair_PipSize ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Load_28Pair_SymbolCode /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void Load_28Pair_SymbolCode() { Print("Inside : Load 28Pair Symbol-Code"); string tstr_Symbol_Code; Symbol t_Symbol; // LOOP FOR 28 PAIRS for (int i = 0; i < 28; i++) { // GET SYMBOL t_Symbol = Get_28Pair_Symbol(i); tstr_Symbol_Code = t_Symbol.Code.ToString(); All_28Pair_Symbol_Code[i] = tstr_Symbol_Code; } //END FOR } //END METHOD Load_28Pair_SymbolCode ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// CLOSE ALL PENDING ORDERS /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //CLOSE-ALL PENDING-ORDERS OF THE LABEL DEFINED IN (t_Label) private void CloseAll_PendingOrders(string t_Label) { //Print Message and SERVER Date Time to Log files string tempText1 = string.Format("{0:ddd-d-MMM-y,h:mm tt}", Server.Time); //Print("Close-Selected ''Pending-Orders''. Server Date & Time = " + tempText1 + ",----> P-Order Label : " + t_Label); foreach (var pen in PendingOrders) { if (pen.Label == t_Label) { CancelPendingOrder(pen); } //END IF } //END FOR_EACH } //END METHOD CLOSE_ALL_Pending_Orders //////////////////////////////////////////////////////////////////////////////////////////// //CLOSE-ALL PENDING-ORDERS IRRESPECTIVE OF THE LABEL private void CloseAll_PendingOrders() { foreach (var pen in PendingOrders) { CancelPendingOrderAsync(pen); } //END FOR-EACH } //END METHOD CloseAll_PendingOrders ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// CLOSE ALL POSITIONS /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //CLOSE-ALL TRADES OF THE LABEL DEFINED IN (t_Label) private void CloseAll_Positions(string t_Label) { //Print Message and Date Time to Log files string tempText1 = string.Format("{0:ddd-d-MMM-y,h:mm tt}", Server.Time); //Print("Close-Selected ''Running-Positions''. Server Date & Time = " + tempText1 + ",----> Running Position Label : " + t_Label); foreach (var pos in Positions) { if (pos.Label == t_Label) { ClosePosition(pos); } //END IF } //END FOR_EACH } //END METHOD CLOSE_ALL_Open_Position //////////////////////////////////////////////////////////////////////////////////////////// //CLOSE-ALL POSITIVE OR NEGATIVE TRADES IRRESPECTIVE OF THE LABEL private void CloseAll_Positions(bool Flag_Profit_Loss) { foreach (var pen in Positions) { //CLOSE ALL PROFITABLE TRADE if (Flag_Profit_Loss) if (pen.NetProfit >= 0) ClosePositionAsync(pen); //CLOSE ALL LOSS TRADE if (!Flag_Profit_Loss) if (pen.NetProfit <= 0) ClosePositionAsync(pen); } //END FOR-EACH } //END METHOD CloseAll_Positions //////////////////////////////////////////////////////////////////////////////////////////// //CLOSE PROFITABLE OR NEGATIVE TRADE THAT ARE ABOVE/BELOW THE TARGET VALUE (t_Target) private void CloseAll_Positions(int t_Target) { foreach (var pen in Positions) { //IF POSITIVE VALUE : CLOSE ALL GREATER THEN TARGET PRICE if (t_Target >= 0) if (pen.NetProfit >= t_Target) ClosePositionAsync(pen); //IF NEGATIVE VALUE : CLOSE ALL LESS THEN THE TARGET PRICE if (t_Target < 0) if (pen.NetProfit <= t_Target) ClosePositionAsync(pen); } //END FOR-EACH } //END METHOD CloseAll_Positions //////////////////////////////////////////////////////////////////////////////////////////// //CLOSE TRADE WITH DEFINED LABEL (t_str1) AND THOSE THAT ARE ABOVE/BELOW THE TARGET VALUE (t_Target ) private void CloseAll_Positions(string t_str1, int t_Target) { foreach (var pen in Positions) { //IF POSITIVE VALUE if (t_Target >= 0) if ((pen.Label == t_str1) && (pen.NetProfit >= t_Target)) ClosePositionAsync(pen); //IF NEGATIVE VALUE if (t_Target < 0) if ((pen.Label == t_str1) && (pen.NetProfit <= t_Target)) ClosePositionAsync(pen); } //END FOR-EACH } //END METHOD CloseAll_Positions ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// WRITE CANDLE DATA TO CSV FILE /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void Write_To_CSV_File() { //>>>>>>>>>>>>>>>>>>>>>> //THIS FUNCTION WILL WRITE ALL THE DATA TO CSV FILE //>>>>>>>>>>>>>>>>>>>>>> //////////////////////////////////////// /// WRITE DATA TO CSV FILE /////// //////////////////////////////////////// if (p_Flag_Create_CSV_File) { //WRITE CURRENT DATA File_Writer.WriteLine(Concate_With_Comma()); } //END IF } //End METHOD Write_To_CSV_File ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// ADD COMMA TO THE STRING FUNCITON ////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private string Concate_With_Comma(params object[] parameters) { return string.Join(",", parameters.Select(p => p.ToString())); } //End METHOD CONCAT_WITH_COMMA ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// CREATE CSV FILE /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected void Create_CSV_File() { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; //Server Time Recod string str_temp1 = string.Format("{0:ddd-d-MMM-y}", Server.Time); //Desktop Folder PATH and NAME str_DesktopFolder = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); str_FolderPath = Path.Combine(str_DesktopFolder, p_str_Folder_Name); //Create Directory and make the file name Directory.CreateDirectory(str_FolderPath); str_FileName = Path.Combine(str_FolderPath, Symbol.Code + " " + TimeFrame + " " + str_temp1 + ".csv"); //Print("File Path : " + str_FilePath); //Create or OVER RIDE Existing FILE and then Close it which is a must. File_Stream = File.Create(str_FileName); File_Stream.Close(); //Open File to prevent .NET from locking it and preventing access by other processes File_Stream = File.Open(str_FileName, FileMode.Open, FileAccess.Write, FileShare.ReadWrite); //Seek End of File to write File_Stream.Seek(0, SeekOrigin.End); //File Writer Stream to be created. File_Writer = new System.IO.StreamWriter(File_Stream, System.Text.Encoding.UTF8, 1); //Auto Flush to improve IO performance File_Writer.AutoFlush = true; } //End METHOD Create_CSV_File ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// ON STOP /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected override void OnStop() { string temp_Text = string.Format("{0:ddd-d-MMM-y,h:mm tt}", Server.Time); Print("cBOT ''onStop'' Stop Date & time : " + temp_Text); //////////////////////////////////////// /// WRITE DATA TO CSV FILE /////// //////////////////////////////////////// if (p_Flag_Create_CSV_File) { File_Writer.WriteLine(Concate_With_Comma()); } //END IF //BLANK LINE Print(""); } //END METHOD On_STOP ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Get_28Pair_Symbol /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private Symbol Get_28Pair_Symbol(int t_Pair) { switch (t_Pair) { ////////////////////////////////////////////// /// JPY PAIRS x 7 ////////////////////////////////////////////// case 0: return MarketData.GetSymbol("GBPJPY"); break; case 1: return MarketData.GetSymbol("USDJPY"); break; case 2: return MarketData.GetSymbol("CADJPY"); break; case 3: return MarketData.GetSymbol("AUDJPY"); break; case 4: return MarketData.GetSymbol("NZDJPY"); break; case 5: return MarketData.GetSymbol("EURJPY"); break; case 6: return MarketData.GetSymbol("CHFJPY"); break; ////////////////////////////////////////////// /// EUR PAIRS x 6 ////////////////////////////////////////////// case 7: return MarketData.GetSymbol("EURNZD"); break; case 8: return MarketData.GetSymbol("EURCAD"); break; case 9: return MarketData.GetSymbol("EURAUD"); break; case 10: return MarketData.GetSymbol("EURUSD"); break; case 11: return MarketData.GetSymbol("EURGBP"); break; case 12: return MarketData.GetSymbol("EURCHF"); break; ////////////////////////////////////////////// /// GBP PAIRS x 5 ////////////////////////////////////////////// case 13: return MarketData.GetSymbol("GBPNZD"); break; case 14: return MarketData.GetSymbol("GBPAUD"); break; case 15: return MarketData.GetSymbol("GBPCAD"); break; case 16: return MarketData.GetSymbol("GBPCHF"); break; case 17: return MarketData.GetSymbol("GBPUSD"); break; ////////////////////////////////////////////// /// AUD PAIRS x 4 ////////////////////////////////////////////// case 18: return MarketData.GetSymbol("AUDUSD"); break; case 19: return MarketData.GetSymbol("AUDCHF"); break; case 20: return MarketData.GetSymbol("AUDNZD"); break; case 21: return MarketData.GetSymbol("AUDCAD"); break; ////////////////////////////////////////////// /// NZD PAIRS x 5 ////////////////////////////////////////////// case 22: return MarketData.GetSymbol("NZDCHF"); break; case 23: return MarketData.GetSymbol("NZDUSD"); break; case 24: return MarketData.GetSymbol("NZDCAD"); break; ////////////////////////////////////////////// /// USD PAIRS x 2 ////////////////////////////////////////////// case 25: return MarketData.GetSymbol("USDCAD"); break; case 26: return MarketData.GetSymbol("USDCHF"); break; ////////////////////////////////////////////// /// CAD PAIRS x 1 ////////////////////////////////////////////// case 27: return MarketData.GetSymbol("CADCHF"); break; } //SWITCH return Symbol; } //END METHOD Get_Pair_Symbol ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Set the Count Bar Value for Market Series Function ////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void Set_Count_Bar_Value() { Count_Bar = MarketSeries.Close.Count - 1; //Daily_Count_Bar = 1; //Print("Count_Bar Value = " + Count_Bar + ", Daily_Count_Bar = " + Daily_Count_Bar); //Print(""); } //End METHOD Set_Count_Bar_Value //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// SET TEXT, TAB AND NEXT LINE SETTING /////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void Draw_OnChart_C1(string t_PreFix, int Line_No, int Tab_Pos, string t_text, Colors Draw_Color) { //CREATE A UNIQUE OBJECT NAME FOR THE METHOD ChartObjects.DrawText string tstr_1 = ""; tstr_1 = t_PreFix + Line_No.ToString() + Tab_Pos.ToString(); ChartObjects.DrawText(tstr_1, my_NL(Line_No) + my_Tabs(Tab_Pos) + t_text, StaticPosition.TopLeft, Draw_Color); } //END METHOD //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// static string my_Tabs(int n) { return new String('\t', n); } //END METHOD my_Tabs //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// static string my_NL(int n) { return new String('\n', n); } //END METHOD my_NL //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void Create_Fixed_Display_1() { //int c1 = 0, c2 = 0; // c3 = 0, c4 = 0, c5 = 0, c6 = 0, c7 = 0, c8 = 0, c9 = 0; //int r1 = 0; // r2 = 0, r3 = 0, r4 = 0, r5 = 0, r6 = 0, r7 = 0, r8 = 0, r9 = 0; //Heading # 1 //r1 = 1; //c1 = 3; //ChartObjects.DrawText("a00", my_NL(r1 + 0) + my_Tabs(c1) + "Line 1", StaticPosition.TopLeft, Colors.Yellow); //Heading # 2 //c2 = c1 + 1; //ChartObjects.DrawText("b00", my_NL(r1 + 0) + my_Tabs(c2) + "Line 1", StaticPosition.TopLeft, Colors.Yellow); } //END METHOD Create_Fixed_Display_1 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void Create_Fixed_Display_2() { //int c1 = 0, c2 = 0, c3 = 0, c4 = 0, c5 = 0, c6 = 0, c7 = 0, c8 = 0, c9 = 0; //int r1 = 0, r2 = 0, r3 = 0, r4 = 0, r5 = 0, r6 = 0, r7 = 0, r8 = 0, r9 = 0; } //END METHOD Create_Fixed_Display_2 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void Create_Display_RowColumn() { //int r1, c1; string t_text = ""; // DISPLAY LINE # for (int i = 0; i <= 80; i++) { t_text = i.ToString(); Draw_OnChart_C1("Line", i, 0, t_text, Clr_Bk_1); } //END FOR // DISPLAY LINE # for (int i = 0; i <= 50; i++) { t_text = "C#"; t_text = t_text + "." + i.ToString(); Draw_OnChart_C1("Line", 0, (i), t_text, Clr_Bk_1); } //END FOR } //END METHOD Create_Display_RowColumn ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void Display_Vertical_Lines(int t_Start_Line, int t_Stop_Line, int t_Col) { //FIRST LOOP for (int i = t_Start_Line; i < t_Stop_Line; i++) { Draw_OnChart_C1("VL" + i.ToString(), i, t_Col, " ||", Clr_Border); } //END FOR } //END FUNCTION Display_Major_Flag_Values ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void Display_Horizontal_Lines(int t_Line, int t_Start_Col, int t_Stop_Col) { //FIRST LOOP for (int i = t_Start_Col; i < t_Stop_Col; i++) { Draw_OnChart_C1("VL" + i.ToString(), t_Line, i, "=======", Clr_Border); } //END FOR } //END FUNCTION Display_Major_Flag_Values ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Declare_All_Arrays /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void Declare_All_Arrays() { // ATR VALUES (IN PIPS) ---------------------------------- All_28Pair_ATR_Value = new double[LP1, 28, 7]; GTotal_28Pair_ATR_Value = new double[LP1, 7]; All_MajorPair_ATR_Value = new double[LP1, 8, 7]; GTotal_MajorPair_ATR_Value = new double[LP1, 7]; // 28-PAIRS ---------------------------------------------- All_28Pair_Pip_Size = new double[28]; All_28Pair_Symbol_Code = new string[28]; // 8-MAJOR PAIRS ----------------------------------------- // MAJOR PAIR RELATED VARIABLES MajorPair_Headings = new string[8]; MajorPair_Combo = new string[8, 7]; Base_Currency = new int[8, 7]; // CURRENT PRICES ---------------------------------------- // LP1 IS THE HISTORY OF PREVIOUS PRICES. // 28 PAirs, 7 TimeFrames (5min, 15min, .....) All_28Pair_Open_Price = new double[LP1, 28, 7]; All_28Pair_Close_Price = new double[LP1, 28, 7]; All_28Pair_HiLo_Price = new double[LP1, 28, 14]; // TOTAL PIPS -------------------------------------------- All_28Pair_Total_Pips = new double[LP1, 28, 7]; GTotal_28Pair_Total_Pips = new double[LP1, 7]; All_MajorPair_Total_Pips = new double[LP1, 8, 7]; GTotal_MajorPair_Total_Pips = new double[LP1, 7]; Sorted_MajorPair_Monthly_Total_Pips = new int[LP1, 8]; Sorted_MajorPair_Weekly_Total_Pips = new int[LP1, 8]; Sorted_MajorPair_Daily_Total_Pips = new int[LP1, 8]; Sorted_MajorPair_4Hour_Total_Pips = new int[LP1, 8]; Sorted_MajorPair_Hourly_Total_Pips = new int[LP1, 8]; Sorted_MajorPair_15min_Total_Pips = new int[LP1, 8]; // NAMES OF THE MONTH Month_Name = new string[12]; // CONTAINS THE INDEX VALUES TO ACCESS PRICES // CURRENT YEAR LP1_Array_Open = new int[LP1]; LP1_Array_Close = new int[LP1]; LP1_TF_Name = new string[LP1]; // AVERAGE PIPS -------------------------------------------- Avg_All_28Pair_Total_Pips = new double[28, 7]; Avg_All_MajorPair_Total_Pips = new double[8, 7]; // KEEP TRACK OF 8-MAJOR PAIR, IF TOTAL PIPS HAVE // CROSSED AVG.PIPS, IN ALL 7 TIME FRAMES Flag_TotalPips_Greater_AvgPips = new int[8]; DateTime_TotalPips_Greater_AvgPips = new string[8]; } //END METHOD Declare_All_Arrays ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Initialize_Array_OnStart_Only /////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void Initialize_Array_OnStart_Only() { //INITIALIZATION OF MAJOR PAIR NAMES MajorPair_Headings[0] = "EUR-PAIRS"; MajorPair_Headings[1] = "GBP-PAIRS"; MajorPair_Headings[2] = "USD-PAIRS"; MajorPair_Headings[3] = "JPY-PAIRS"; MajorPair_Headings[4] = "CHF-PAIRS"; MajorPair_Headings[5] = "CAD-PAIRS"; MajorPair_Headings[6] = "AUD-PAIRS"; MajorPair_Headings[7] = "NZD-PAIRS"; // 0-EURO PAIRS MajorPair_Combo[0, 0] = "EURUSD"; MajorPair_Combo[0, 1] = "EURJPY"; MajorPair_Combo[0, 2] = "EURGBP"; MajorPair_Combo[0, 3] = "EURAUD"; MajorPair_Combo[0, 4] = "EURNZD"; MajorPair_Combo[0, 5] = "EURCHF"; MajorPair_Combo[0, 6] = "EURCAD"; Base_Currency[0, 0] = 1; Base_Currency[0, 1] = 1; Base_Currency[0, 2] = 1; Base_Currency[0, 3] = 1; Base_Currency[0, 4] = 1; Base_Currency[0, 5] = 1; Base_Currency[0, 6] = 1; // 1-GBP PAIRS MajorPair_Combo[1, 0] = "GBPUSD"; MajorPair_Combo[1, 1] = "GBPJPY"; MajorPair_Combo[1, 2] = "EURGBP"; MajorPair_Combo[1, 3] = "GBPAUD"; MajorPair_Combo[1, 4] = "GBPNZD"; MajorPair_Combo[1, 5] = "GBPCHF"; MajorPair_Combo[1, 6] = "GBPCAD"; Base_Currency[1, 0] = 1; Base_Currency[1, 1] = 1; Base_Currency[1, 2] = -1; Base_Currency[1, 3] = 1; Base_Currency[1, 4] = 1; Base_Currency[1, 5] = 1; Base_Currency[1, 6] = 1; // 2-USD PAIRS MajorPair_Combo[2, 0] = "EURUSD"; MajorPair_Combo[2, 1] = "GBPUSD"; MajorPair_Combo[2, 2] = "AUDUSD"; MajorPair_Combo[2, 3] = "NZDUSD"; MajorPair_Combo[2, 4] = "USDJPY"; MajorPair_Combo[2, 5] = "USDCHF"; MajorPair_Combo[2, 6] = "USDCAD"; Base_Currency[2, 0] = -1; Base_Currency[2, 1] = -1; Base_Currency[2, 2] = -1; Base_Currency[2, 3] = -1; Base_Currency[2, 4] = 1; Base_Currency[2, 5] = 1; Base_Currency[2, 6] = 1; // 3-JPY PAIRS MajorPair_Combo[3, 0] = "EURJPY"; MajorPair_Combo[3, 1] = "USDJPY"; MajorPair_Combo[3, 2] = "GBPJPY"; MajorPair_Combo[3, 3] = "AUDJPY"; MajorPair_Combo[3, 4] = "NZDJPY"; MajorPair_Combo[3, 5] = "CHFJPY"; MajorPair_Combo[3, 6] = "CADJPY"; Base_Currency[3, 0] = -1; Base_Currency[3, 1] = -1; Base_Currency[3, 2] = -1; Base_Currency[3, 3] = -1; Base_Currency[3, 4] = -1; Base_Currency[3, 5] = -1; Base_Currency[3, 6] = -1; // 4-CHF PAIRS MajorPair_Combo[4, 0] = "EURCHF"; MajorPair_Combo[4, 1] = "USDCHF"; MajorPair_Combo[4, 2] = "GBPCHF"; MajorPair_Combo[4, 3] = "AUDCHF"; MajorPair_Combo[4, 4] = "NZDCHF"; MajorPair_Combo[4, 5] = "CADCHF"; MajorPair_Combo[4, 6] = "CHFJPY"; Base_Currency[4, 0] = -1; Base_Currency[4, 1] = -1; Base_Currency[4, 2] = -1; Base_Currency[4, 3] = -1; Base_Currency[4, 4] = -1; Base_Currency[4, 5] = -1; Base_Currency[4, 6] = 1; // 5-CAD PAIRS MajorPair_Combo[5, 0] = "EURCAD"; MajorPair_Combo[5, 1] = "USDCAD"; MajorPair_Combo[5, 2] = "GBPCAD"; MajorPair_Combo[5, 3] = "AUDCAD"; MajorPair_Combo[5, 4] = "NZDCAD"; MajorPair_Combo[5, 5] = "CADCHF"; MajorPair_Combo[5, 6] = "CADJPY"; Base_Currency[5, 0] = -1; Base_Currency[5, 1] = -1; Base_Currency[5, 2] = -1; Base_Currency[5, 3] = -1; Base_Currency[5, 4] = -1; Base_Currency[5, 5] = 1; Base_Currency[5, 6] = 1; // 6-AUD PAIRS MajorPair_Combo[6, 0] = "EURAUD"; MajorPair_Combo[6, 1] = "GBPAUD"; MajorPair_Combo[6, 2] = "AUDUSD"; MajorPair_Combo[6, 3] = "AUDJPY"; MajorPair_Combo[6, 4] = "AUDNZD"; MajorPair_Combo[6, 5] = "AUDCHF"; MajorPair_Combo[6, 6] = "AUDCAD"; Base_Currency[6, 0] = -1; Base_Currency[6, 1] = -1; Base_Currency[6, 2] = 1; Base_Currency[6, 3] = 1; Base_Currency[6, 4] = 1; Base_Currency[6, 5] = 1; Base_Currency[6, 6] = 1; // 7-NZD PAIRS MajorPair_Combo[7, 0] = "EURNZD"; MajorPair_Combo[7, 1] = "GBPNZD"; MajorPair_Combo[7, 2] = "AUDNZD"; MajorPair_Combo[7, 3] = "NZDUSD"; MajorPair_Combo[7, 4] = "NZDJPY"; MajorPair_Combo[7, 5] = "NZDCHF"; MajorPair_Combo[7, 6] = "NZDCAD"; Base_Currency[7, 0] = -1; Base_Currency[7, 1] = -1; Base_Currency[7, 2] = -1; Base_Currency[7, 3] = 1; Base_Currency[7, 4] = 1; Base_Currency[7, 5] = 1; Base_Currency[7, 6] = 1; // NAME OF THE MONTHS Month_Name[0] = "1.Jan"; Month_Name[1] = "2.Feb"; Month_Name[2] = "3.Mar"; Month_Name[3] = "4.Apr"; Month_Name[4] = "5.May"; Month_Name[5] = "6.June"; Month_Name[6] = "7.Jul"; Month_Name[7] = "8.Aug"; Month_Name[8] = "9.Sep"; Month_Name[9] = "10.Oct"; Month_Name[10] = "11.Nov"; Month_Name[11] = "12.Dec"; //--------------------------------------------------- // CURRENT MONTH : OPEN AND CLOSE PRICES LP1_Array_Open[0] = 0; LP1_Array_Close[0] = 0; // INITIALIZE THE INDEX FOR ACCESSING PRICES for (int i = 1; i < LP1; i++) { LP1_Array_Open[i] = i; } //END FOR for (int i = 1; i < LP1; i++) { LP1_Array_Close[i] = i; } //END FOR LP1_TF_Name[0] = "Current"; for (int i = 1; i < LP1; i++) { LP1_TF_Name[i] = "Prev-" + i.ToString(); } //END FOR //--------------------------------------------------- } //END METHOD Initialize_Array_OnStart_Only } //END OF MAIN PUBLIC CLASS } //END OF MAIN cALGO ROBOT  
14 Oct 2016
Downloads
664
Comments
3
Rating
5
Download
The cBot will open trades after breakout of previous bars. Strong money management, Primary SL & Reversal Trailing algorithm. Risk Per Trade based on the distance between Entry-price & Primary SL and also you can use manual lot-size by Risk per trade 0.   www.facebook.com/cls.fx    
06 Oct 2016
Downloads
27001
Comments
2
Rating
0
Download
Pip count for each Candle, very useful    // ------------------------------------------------------------ // Paste this code into your cAlgo editor. // ----------------------------------------------------------- using System; using System.Collections.Generic; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Collections; using System.Collections.ObjectModel; using System.ComponentModel; using System.IO; using System.Reflection; using System.Threading; using System.Diagnostics; using System.Runtime.InteropServices; using Microsoft.Win32; using cAlgo.API.Requests; // --------------------------------------------------------------------------- // Converted from MQ4 to cAlgo with http://2calgo.com // --------------------------------------------------------------------------- namespace cAlgo.Indicators { [Indicator(ScalePrecision = 5, AutoRescale = false, IsOverlay = true, AccessRights = AccessRights.None)] [Levels()] public class FXPT_CandleSizev2_Indicator : Indicator { Mq4Double Mq4Init() { if (Point == 1E-05) Poin = 0.0001; else { if (Point == 0.001) Poin = 0.01; else Poin = Point; } return 0; return 0; } Mq4Double deinitFunc() { DeleteObjectsFunc(); return 0; return 0; } void DeleteObjectsFunc() { Mq4Double cnt = 0; Mq4String name = ""; Mq4Double objs = 0; objs = ObjectsTotal(); for (cnt = ObjectsTotal() - 1; cnt >= 0; cnt--) { name = ObjectName(cnt); if (StringFind(name, "FXPTc_", 0) > -1) ObjectDelete(name); WindowRedraw(); } return; } Mq4Double Mq4Start() { Mq4Double i = 0; Mq4Double Rng = 0; Mq4String sObjName = ""; Mq4String text = ""; if (prevtime == Time[0]) { return 0; } DeleteObjectsFunc(); for (i = 0; i < NumberBars; i++) { Rng = MathAbs(Open[i] - Close[i]) / Poin; text = DoubleToStr(Rng, 0); if (Open[i] < Close[i]) { sObjName = "FXPTc_label1" + i; ObjectCreate(sObjName, OBJ_TEXT, 0, Time[i], High[i] + TextPosition * Poin); ObjectSet(sObjName, OBJPROP_ANGLE, TextAngle); ObjectSetText(sObjName, text, 10, "Corbel", SlateGray); } else { sObjName = "FXPTc_label1" + i; ObjectCreate(sObjName, OBJ_TEXT, 0, Time[i], Low[i] - TextPosition * Poin); ObjectSet(sObjName, OBJPROP_ANGLE, TextAngle); ObjectSetText(sObjName, text, 10, "Corbel", SlateGray); } } return 0; return 0; } [Parameter("TextPosition", DefaultValue = 10)] public int TextPosition_parameter { get; set; } bool _TextPositionGot; Mq4Double TextPosition_backfield; Mq4Double TextPosition { get { if (!_TextPositionGot) TextPosition_backfield = TextPosition_parameter; return TextPosition_backfield; } set { TextPosition_backfield = value; } } [Parameter("TextAngle", DefaultValue = 0)] public int TextAngle_parameter { get; set; } bool _TextAngleGot; Mq4Double TextAngle_backfield; Mq4Double TextAngle { get { if (!_TextAngleGot) TextAngle_backfield = TextAngle_parameter; return TextAngle_backfield; } set { TextAngle_backfield = value; } } [Parameter("NumberBars", DefaultValue = 100)] public int NumberBars_parameter { get; set; } bool _NumberBarsGot; Mq4Double NumberBars_backfield; Mq4Double NumberBars { get { if (!_NumberBarsGot) NumberBars_backfield = NumberBars_parameter; return NumberBars_backfield; } set { NumberBars_backfield = value; } } Mq4Double Poin; Mq4Double prevtime = 0; int indicator_buffers = 0; Mq4Double indicator_width1 = 1; Mq4Double indicator_width2 = 1; Mq4Double indicator_width3 = 1; Mq4Double indicator_width4 = 1; Mq4Double indicator_width5 = 1; Mq4Double indicator_width6 = 1; Mq4Double indicator_width7 = 1; Mq4Double indicator_width8 = 1; List AllBuffers = new List(); public List AllOutputDataSeries = new List(); protected override void Initialize() { CommonInitialize(); } private bool _initialized; public override void Calculate(int index) { try { _currentIndex = index; if (IsLastBar) { if (!_initialized) { Mq4Init(); _initialized = true; } Mq4Start(); _indicatorCounted = index; } } catch (Exception e) { throw; } } int _currentIndex; CachedStandardIndicators _cachedStandardIndicators; Mq4ChartObjects _mq4ChartObjects; Mq4ArrayToDataSeriesConverterFactory _mq4ArrayToDataSeriesConverterFactory; Mq4MarketDataSeries Open; Mq4MarketDataSeries High; Mq4MarketDataSeries Low; Mq4MarketDataSeries Close; Mq4MarketDataSeries Median; Mq4MarketDataSeries Volume; Mq4TimeSeries Time; private void CommonInitialize() { Open = new Mq4MarketDataSeries(MarketSeries.Open); High = new Mq4MarketDataSeries(MarketSeries.High); Low = new Mq4MarketDataSeries(MarketSeries.Low); Close = new Mq4MarketDataSeries(MarketSeries.Close); Volume = new Mq4MarketDataSeries(MarketSeries.TickVolume); Median = new Mq4MarketDataSeries(MarketSeries.Median); Time = new Mq4TimeSeries(MarketSeries.OpenTime); _cachedStandardIndicators = new CachedStandardIndicators(Indicators); _mq4ChartObjects = new Mq4ChartObjects(ChartObjects, MarketSeries.OpenTime); _mq4ArrayToDataSeriesConverterFactory = new Mq4ArrayToDataSeriesConverterFactory(() => CreateDataSeries()); } private int Bars { get { return MarketSeries.Close.Count; } } Mq4Double Point { get { if (Symbol == null) return 1E-05; return Symbol.TickSize; } } private int Period() { if (TimeFrame == TimeFrame.Minute) return 1; if (TimeFrame == TimeFrame.Minute2) return 2; if (TimeFrame == TimeFrame.Minute3) return 3; if (TimeFrame == TimeFrame.Minute4) return 4; if (TimeFrame == TimeFrame.Minute5) return 5; if (TimeFrame == TimeFrame.Minute10) return 10; if (TimeFrame == TimeFrame.Minute15) return 15; if (TimeFrame == TimeFrame.Minute30) return 30; if (TimeFrame == TimeFrame.Hour) return 60; if (TimeFrame == TimeFrame.Hour4) return 240; if (TimeFrame == TimeFrame.Hour12) return 720; if (TimeFrame == TimeFrame.Daily) return 1440; if (TimeFrame == TimeFrame.Weekly) return 10080; return 43200; } public TimeFrame PeriodToTimeFrame(int period) { switch (period) { case 0: return TimeFrame; case 1: return TimeFrame.Minute; case 2: return TimeFrame.Minute2; case 3: return TimeFrame.Minute3; case 4: return TimeFrame.Minute4; case 5: return TimeFrame.Minute5; case 10: return TimeFrame.Minute10; case 15: return TimeFrame.Minute15; case 30: return TimeFrame.Minute30; case 60: return TimeFrame.Hour; case 240: return TimeFrame.Hour4; case 720: return TimeFrame.Hour12; case 1440: return TimeFrame.Daily; case 10080: return TimeFrame.Weekly; case 43200: return TimeFrame.Monthly; default: throw new NotSupportedException(string.Format("TimeFrame {0} minutes isn't supported by cAlgo", period)); } } Mq4Double MathAbs(double x) { return Math.Abs(x); } Mq4String DoubleToStr(double value, int digits) { return value.ToString("F" + digits); } int ToMq4ErrorCode(ErrorCode errorCode) { switch (errorCode) { case ErrorCode.BadVolume: return ERR_INVALID_TRADE_VOLUME; case ErrorCode.NoMoney: return ERR_NOT_ENOUGH_MONEY; case ErrorCode.MarketClosed: return ERR_MARKET_CLOSED; case ErrorCode.Disconnected: return ERR_NO_CONNECTION; case ErrorCode.Timeout: return ERR_TRADE_TIMEOUT; default: return ERR_COMMON_ERROR; } } void WindowRedraw() { } int StringFind(Mq4String text, string matched_text, int start = 0) { return ((string)text).IndexOf(matched_text, start); } const string NotSupportedMaShift = "Converter supports only ma_shift = 0"; private int _lastError; const string GlobalVariablesPath = "Software\\2calgo\\Global Variables\\"; Symbol GetSymbol(string symbolCode) { if (symbolCode == "0" || string.IsNullOrEmpty(symbolCode)) { return Symbol; } return MarketData.GetSymbol(symbolCode); } MarketSeries GetSeries(string symbol, int period) { var timeFrame = PeriodToTimeFrame(period); var symbolObject = GetSymbol(symbol); if (symbolObject == Symbol && timeFrame == TimeFrame) return MarketSeries; return MarketData.GetSeries(symbolObject.Code, timeFrame); } private DataSeries ToAppliedPrice(string symbol, int timeframe, int constant) { var series = GetSeries(symbol, timeframe); switch (constant) { case PRICE_OPEN: return series.Open; case PRICE_HIGH: return series.High; case PRICE_LOW: return series.Low; case PRICE_CLOSE: return series.Close; case PRICE_MEDIAN: return series.Median; case PRICE_TYPICAL: return series.Typical; case PRICE_WEIGHTED: return series.WeightedClose; } throw new NotImplementedException("Converter doesn't support working with this type of AppliedPrice"); } const string xArrow = "✖"; public static string GetArrowByCode(int code) { switch (code) { case 0: return string.Empty; case 32: return " "; case 33: return "✏"; case 34: return "✂"; case 35: return "✁"; case 40: return "☎"; case 41: return "✆"; case 42: return "✉"; case 54: return "⌛"; case 55: return "⌨"; case 62: return "✇"; case 63: return "✍"; case 65: return "✌"; case 69: return "☜"; case 70: return "☞"; case 71: return "☝"; case 72: return "☟"; case 74: return "☺"; case 76: return "☹"; case 78: return "☠"; case 79: return "⚐"; case 81: return "✈"; case 82: return "☼"; case 84: return "❄"; case 86: return "✞"; case 88: return "✠"; case 89: return "✡"; case 90: return "☪"; case 91: return "☯"; case 92: return "ॐ"; case 93: return "☸"; case 94: return "♈"; case 95: return "♉"; case 96: return "♊"; case 97: return "♋"; case 98: return "♌"; case 99: return "♍"; case 100: return "♎"; case 101: return "♏"; case 102: return "♐"; case 103: return "♑"; case 104: return "♒"; case 105: return "♓"; case 106: return "&"; case 107: return "&"; case 108: return "●"; case 109: return "❍"; case 110: return "■"; case 111: case 112: return "□"; case 113: return "❑"; case 114: return "❒"; case 115: case 116: return "⧫"; case 117: case 119: return "◆"; case 118: return "❖"; case 120: return "⌧"; case 121: return "⍓"; case 122: return "⌘"; case 123: return "❀"; case 124: return "✿"; case 125: return "❝"; case 126: return "❞"; case 127: return "▯"; case 128: return "⓪"; case 129: return "①"; case 130: return "②"; case 131: return "③"; case 132: return "④"; case 133: return "⑤"; case 134: return "⑥"; case 135: return "⑦"; case 136: return "⑧"; case 137: return "⑨"; case 138: return "⑩"; case 139: return "⓿"; case 140: return "❶"; case 141: return "❷"; case 142: return "❸"; case 143: return "❹"; case 144: return "❺"; case 145: return "❻"; case 146: return "❼"; case 147: return "❽"; case 148: return "❾"; case 149: return "❿"; case 158: return "·"; case 159: return "•"; case 160: case 166: return "▪"; case 161: return "○"; case 162: case 164: return "⭕"; case 165: return "◎"; case 167: return "✖"; case 168: return "◻"; case 170: return "✦"; case 171: return "★"; case 172: return "✶"; case 173: return "✴"; case 174: return "✹"; case 175: return "✵"; case 177: return "⌖"; case 178: return "⟡"; case 179: return "⌑"; case 181: return "✪"; case 182: return "✰"; case 195: case 197: case 215: case 219: case 223: case 231: return "◀"; case 196: case 198: case 224: return "▶"; case 213: return "⌫"; case 214: return "⌦"; case 216: return "➢"; case 220: return "➲"; case 232: return "➔"; case 233: case 199: case 200: case 217: case 221: case 225: return "◭"; case 234: case 201: case 202: case 218: case 222: case 226: return "⧨"; case 239: return "⇦"; case 240: return "⇨"; case 241: return "◭"; case 242: return "⧨"; case 243: return "⬄"; case 244: return "⇳"; case 245: case 227: case 235: return "↖"; case 246: case 228: case 236: return "↗"; case 247: case 229: case 237: return "↙"; case 248: case 230: case 238: return "↘"; case 249: return "▭"; case 250: return "▫"; case 251: return "✗"; case 252: return "✓"; case 253: return "☒"; case 254: return "☑"; default: return xArrow; } } class Mq4OutputDataSeries : IMq4DoubleArray { public IndicatorDataSeries OutputDataSeries { get; private set; } private readonly IndicatorDataSeries _originalValues; private int _currentIndex; private int _shift; private double _emptyValue = EMPTY_VALUE; private readonly ChartObjects _chartObjects; private readonly int _style; private readonly int _bufferIndex; private readonly FXPT_CandleSizev2_Indicator _indicator; public Mq4OutputDataSeries(FXPT_CandleSizev2_Indicator indicator, IndicatorDataSeries outputDataSeries, ChartObjects chartObjects, int style, int bufferIndex, Func dataSeriesFactory, int lineWidth, Colors? color = null) { OutputDataSeries = outputDataSeries; _chartObjects = chartObjects; _style = style; _bufferIndex = bufferIndex; _indicator = indicator; Color = color; _originalValues = dataSeriesFactory(); LineWidth = lineWidth; } public int LineWidth { get; private set; } public Colors? Color { get; private set; } public int Length { get { return OutputDataSeries.Count; } } public void Resize(int newSize) { } public void SetCurrentIndex(int index) { _currentIndex = index; } public void SetShift(int shift) { _shift = shift; } public void SetEmptyValue(double emptyValue) { _emptyValue = emptyValue; } public Mq4Double this[int index] { get { var indexToGetFrom = _currentIndex - index + _shift; if (indexToGetFrom < 0 || indexToGetFrom > _currentIndex) return 0; if (indexToGetFrom >= _originalValues.Count) return _emptyValue; return _originalValues[indexToGetFrom]; } set { var indexToSet = _currentIndex - index + _shift; if (indexToSet < 0) return; _originalValues[indexToSet] = value; var valueToSet = value; if (valueToSet == _emptyValue) valueToSet = double.NaN; if (indexToSet < 0) return; OutputDataSeries[indexToSet] = valueToSet; switch (_style) { case DRAW_ARROW: var arrowName = GetArrowName(indexToSet); if (double.IsNaN(valueToSet)) _chartObjects.RemoveObject(arrowName); else { var color = Color.HasValue ? Color.Value : Colors.SeaGreen; _chartObjects.DrawText(arrowName, _indicator.ArrowByIndex[_bufferIndex], indexToSet, valueToSet, VerticalAlignment.Center, HorizontalAlignment.Center, color); } break; case DRAW_HISTOGRAM: if (true) { var anotherLine = _indicator.AllBuffers.FirstOrDefault(b => b.LineWidth == LineWidth && b != this); if (anotherLine != null) { var name = GetNameOfHistogramLineOnChartWindow(indexToSet); Colors color; if (this[index] > anotherLine[index]) color = Color ?? Colors.SlateGray; else color = anotherLine.Color ?? Colors.SlateGray; var lineWidth = LineWidth; if (lineWidth != 1 && lineWidth < 5) lineWidth = 5; _chartObjects.DrawLine(name, indexToSet, this[index], indexToSet, anotherLine[index], color, lineWidth); } } break; } } } private string GetNameOfHistogramLineOnChartWindow(int index) { return string.Format("Histogram on chart window {0} {1}", LineWidth, index); } private string GetArrowName(int index) { return string.Format("Arrow {0} {1}", GetHashCode(), index); } } public Dictionary ArrowByIndex = new Dictionary { { 0, xArrow }, { 1, xArrow }, { 2, xArrow }, { 3, xArrow }, { 4, xArrow }, { 5, xArrow }, { 6, xArrow }, { 7, xArrow } }; void SetIndexArrow(int index, int code) { ArrowByIndex[index] = GetArrowByCode(code); } private int _indicatorCounted; int FILE_READ = 1; int FILE_WRITE = 2; //int FILE_BIN = 8; int FILE_CSV = 8; int SEEK_END = 2; class FileInfo { public int Mode { get; set; } public int Handle { get; set; } public char Separator { get; set; } public string FileName { get; set; } public List PendingParts { get; set; } public StreamWriter StreamWriter { get; set; } public StreamReader StreamReader { get; set; } } private Dictionary _openedFiles = new Dictionary(); private int _handleCounter = 1000; class FolderPaths { public static string _2calgoAppDataFolder { get { var result = Path.Combine(SystemAppData, "2calgo"); if (!Directory.Exists(result)) Directory.CreateDirectory(result); return result; } } public static string _2calgoDesktopFolder { get { var result = Path.Combine(Desktop, "2calgo"); if (!Directory.Exists(result)) Directory.CreateDirectory(result); return result; } } static string SystemAppData { get { return Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); } } static string Desktop { get { return Environment.GetFolderPath(Environment.SpecialFolder.Desktop); } } } const int MODE_TRADES = 0; const int MODE_HISTORY = 1; const int SELECT_BY_POS = 0; const int SELECT_BY_TICKET = 1; T GetPropertyValue(Func getFromPosition, Func getFromPendingOrder, Func getFromHistory) { if (_currentOrder == null) return default(T); return GetPropertyValue(_currentOrder, getFromPosition, getFromPendingOrder, getFromHistory); } T GetPropertyValue(object obj, Func getFromPosition, Func getFromPendingOrder, Func getFromHistory) { if (obj is Position) return getFromPosition((Position)obj); if (obj is PendingOrder) return getFromPendingOrder((PendingOrder)obj); return getFromHistory((HistoricalTrade)obj); } private Mq4Double GetTicket(object trade) { return new Mq4Double(GetPropertyValue(trade, _ => _.Id, _ => _.Id, _ => _.ClosingDealId)); } private int GetMagicNumber(string label) { int magicNumber; if (int.TryParse(label, out magicNumber)) return magicNumber; return 0; } private int GetMagicNumber(object order) { var label = GetPropertyValue(order, _ => _.Label, _ => _.Label, _ => _.Label); return GetMagicNumber(label); } object _currentOrder; double GetLots(object order) { var volume = GetPropertyValue(order, _ => _.Volume, _ => _.Volume, _ => _.Volume); var symbolCode = GetPropertyValue(order, _ => _.SymbolCode, _ => _.SymbolCode, _ => _.SymbolCode); var symbolObject = MarketData.GetSymbol(symbolCode); return symbolObject.ToLotsVolume(volume); } object GetOrderByTicket(int ticket) { var allOrders = Positions.OfType().Concat(PendingOrders.OfType()).ToArray(); return allOrders.FirstOrDefault(_ => GetTicket(_) == ticket); } double GetOpenPrice(object order) { return GetPropertyValue(order, _ => _.EntryPrice, _ => _.TargetPrice, _ => _.EntryPrice); } private double GetStopLoss(object order) { var nullableValue = GetPropertyValue(order, _ => _.StopLoss, _ => _.StopLoss, _ => 0); return nullableValue ?? 0; } private double GetTakeProfit(object order) { var nullableValue = GetPropertyValue(order, _ => _.TakeProfit, _ => _.TakeProfit, _ => 0); return nullableValue ?? 0; } class ParametersKey { private readonly object[] _parameters; public ParametersKey(params object[] parameters) { _parameters = parameters; } public override bool Equals(object obj) { var other = (ParametersKey)obj; for (var i = 0; i < _parameters.Length; i++) { if (!_parameters[i].Equals(other._parameters[i])) return false; } return true; } public override int GetHashCode() { unchecked { var hashCode = 0; foreach (var parameter in _parameters) { hashCode = (hashCode * 397) ^ parameter.GetHashCode(); } return hashCode; } } } class Cache { private Dictionary _dictionary = new Dictionary(); public bool TryGetValue(out TValue value, params object[] parameters) { var key = new ParametersKey(parameters); return _dictionary.TryGetValue(key, out value); } public void Add(TValue value, params object[] parameters) { var key = new ParametersKey(parameters); _dictionary.Add(key, value); } } private static MovingAverageType ToMaType(int constant) { switch (constant) { case MODE_SMA: return MovingAverageType.Simple; case MODE_EMA: return MovingAverageType.Exponential; case MODE_LWMA: return MovingAverageType.Weighted; default: throw new ArgumentOutOfRangeException("Not supported moving average type"); } } class CachedStandardIndicators { private readonly IIndicatorsAccessor _indicatorsAccessor; public CachedStandardIndicators(IIndicatorsAccessor indicatorsAccessor) { _indicatorsAccessor = indicatorsAccessor; } } const bool True = true; const bool False = false; const bool TRUE = true; const bool FALSE = false; Mq4Null NULL; const int EMPTY = -1; const double EMPTY_VALUE = 2147483647; public const int WHOLE_ARRAY = 0; const int MODE_SMA = 0; //Simple moving average const int MODE_EMA = 1; //Exponential moving average, const int MODE_SMMA = 2; //Smoothed moving average, const int MODE_LWMA = 3; //Linear weighted moving average. const int PRICE_CLOSE = 0; //Close price. const int PRICE_OPEN = 1; //Open price. const int PRICE_HIGH = 2; //High price. const int PRICE_LOW = 3; //Low price. const int PRICE_MEDIAN = 4; //Median price, (high+low)/2. const int PRICE_TYPICAL = 5; //Typical price, (high+low+close)/3. const int PRICE_WEIGHTED = 6; //Weighted close price, (high+low+close+close)/4. const int DRAW_LINE = 0; const int DRAW_SECTION = 1; const int DRAW_HISTOGRAM = 2; const int DRAW_ARROW = 3; const int DRAW_ZIGZAG = 4; const int DRAW_NONE = 12; const int STYLE_SOLID = 0; const int STYLE_DASH = 1; const int STYLE_DOT = 2; const int STYLE_DASHDOT = 3; const int STYLE_DASHDOTDOT = 4; const int MODE_OPEN = 0; const int MODE_LOW = 1; const int MODE_HIGH = 2; const int MODE_CLOSE = 3; const int MODE_VOLUME = 4; const int MODE_TIME = 5; const int MODE_BID = 9; const int MODE_ASK = 10; const int MODE_POINT = 11; const int MODE_DIGITS = 12; const int MODE_SPREAD = 13; const int MODE_TRADEALLOWED = 22; const int MODE_PROFITCALCMODE = 27; const int MODE_MARGINCALCMODE = 28; const int MODE_SWAPTYPE = 26; const int MODE_TICKSIZE = 17; const int MODE_FREEZELEVEL = 33; const int MODE_STOPLEVEL = 14; const int MODE_LOTSIZE = 15; const int MODE_TICKVALUE = 16; /*const int MODE_SWAPLONG = 18; const int MODE_SWAPSHORT = 19; const int MODE_STARTING = 20; const int MODE_EXPIRATION = 21; */ const int MODE_MINLOT = 23; const int MODE_LOTSTEP = 24; const int MODE_MAXLOT = 25; /*const int MODE_MARGININIT = 29; const int MODE_MARGINMAINTENANCE = 30; const int MODE_MARGINHEDGED = 31;*/ const int MODE_MARGINREQUIRED = 32; const int OBJ_VLINE = 0; const int OBJ_HLINE = 1; const int OBJ_TREND = 2; const int OBJ_FIBO = 10; /*const int OBJ_TRENDBYANGLE = 3; const int OBJ_REGRESSION = 4; const int OBJ_CHANNEL = 5; const int OBJ_STDDEVCHANNEL = 6; const int OBJ_GANNLINE = 7; const int OBJ_GANNFAN = 8; const int OBJ_GANNGRID = 9; const int OBJ_FIBOTIMES = 11; const int OBJ_FIBOFAN = 12; const int OBJ_FIBOARC = 13; const int OBJ_EXPANSION = 14; const int OBJ_FIBOCHANNEL = 15;*/ const int OBJ_RECTANGLE = 16; /*const int OBJ_TRIANGLE = 17; const int OBJ_ELLIPSE = 18; const int OBJ_PITCHFORK = 19; const int OBJ_CYCLES = 20;*/ const int OBJ_TEXT = 21; const int OBJ_ARROW = 22; const int OBJ_LABEL = 23; const int OBJPROP_TIME1 = 0; const int OBJPROP_PRICE1 = 1; const int OBJPROP_TIME2 = 2; const int OBJPROP_PRICE2 = 3; const int OBJPROP_TIME3 = 4; const int OBJPROP_PRICE3 = 5; const int OBJPROP_COLOR = 6; const int OBJPROP_STYLE = 7; const int OBJPROP_WIDTH = 8; const int OBJPROP_BACK = 9; const int OBJPROP_RAY = 10; const int OBJPROP_ELLIPSE = 11; //const int OBJPROP_SCALE = 12; const int OBJPROP_ANGLE = 13; //angle for text rotation const int OBJPROP_ARROWCODE = 14; const int OBJPROP_TIMEFRAMES = 15; //const int OBJPROP_DEVIATION = 16; const int OBJPROP_FONTSIZE = 100; const int OBJPROP_CORNER = 101; const int OBJPROP_XDISTANCE = 102; const int OBJPROP_YDISTANCE = 103; const int OBJPROP_FIBOLEVELS = 200; const int OBJPROP_LEVELCOLOR = 201; const int OBJPROP_LEVELSTYLE = 202; const int OBJPROP_LEVELWIDTH = 203; const int OBJPROP_FIRSTLEVEL = 210; const int PERIOD_M1 = 1; const int PERIOD_M5 = 5; const int PERIOD_M15 = 15; const int PERIOD_M30 = 30; const int PERIOD_H1 = 60; const int PERIOD_H4 = 240; const int PERIOD_D1 = 1440; const int PERIOD_W1 = 10080; const int PERIOD_MN1 = 43200; const int TIME_DATE = 1; const int TIME_MINUTES = 2; const int TIME_SECONDS = 4; const int MODE_MAIN = 0; const int MODE_BASE = 0; const int MODE_PLUSDI = 1; const int MODE_MINUSDI = 2; const int MODE_SIGNAL = 1; const int MODE_UPPER = 1; const int MODE_LOWER = 2; const int MODE_GATORLIPS = 3; const int MODE_GATORJAW = 1; const int MODE_GATORTEETH = 2; const int CLR_NONE = 32768; const int White = 16777215; const int Snow = 16448255; const int MintCream = 16449525; const int LavenderBlush = 16118015; const int AliceBlue = 16775408; const int Honeydew = 15794160; const int Ivory = 15794175; const int Seashell = 15660543; const int WhiteSmoke = 16119285; const int OldLace = 15136253; const int MistyRose = 14804223; const int Lavender = 16443110; const int Linen = 15134970; const int LightCyan = 16777184; const int LightYellow = 14745599; const int Cornsilk = 14481663; const int PapayaWhip = 14020607; const int AntiqueWhite = 14150650; const int Beige = 14480885; const int LemonChiffon = 13499135; const int BlanchedAlmond = 13495295; const int LightGoldenrod = 13826810; const int Bisque = 12903679; const int Pink = 13353215; const int PeachPuff = 12180223; const int Gainsboro = 14474460; const int LightPink = 12695295; const int Moccasin = 11920639; const int NavajoWhite = 11394815; const int Wheat = 11788021; const int LightGray = 13882323; const int PaleTurquoise = 15658671; const int PaleGoldenrod = 11200750; const int PowderBlue = 15130800; const int Thistle = 14204888; const int PaleGreen = 10025880; const int LightBlue = 15128749; const int LightSteelBlue = 14599344; const int LightSkyBlue = 16436871; const int Silver = 12632256; const int Aquamarine = 13959039; const int LightGreen = 9498256; const int Khaki = 9234160; const int Plum = 14524637; const int LightSalmon = 8036607; const int SkyBlue = 15453831; const int LightCoral = 8421616; const int Violet = 15631086; const int Salmon = 7504122; const int HotPink = 11823615; const int BurlyWood = 8894686; const int DarkSalmon = 8034025; const int Tan = 9221330; const int MediumSlateBlue = 15624315; const int SandyBrown = 6333684; const int DarkGray = 11119017; const int CornflowerBlue = 15570276; const int Coral = 5275647; const int PaleVioletRed = 9662683; const int MediumPurple = 14381203; const int Orchid = 14053594; const int RosyBrown = 9408444; const int Tomato = 4678655; const int DarkSeaGreen = 9419919; const int Cyan = 16776960; const int MediumAquamarine = 11193702; const int GreenYellow = 3145645; const int MediumOrchid = 13850042; const int IndianRed = 6053069; const int DarkKhaki = 7059389; const int SlateBlue = 13458026; const int RoyalBlue = 14772545; const int Turquoise = 13688896; const int DodgerBlue = 16748574; const int MediumTurquoise = 13422920; const int DeepPink = 9639167; const int LightSlateGray = 10061943; const int BlueViolet = 14822282; const int Peru = 4163021; const int SlateGray = 9470064; const int Gray = 8421504; const int Red = 255; const int Magenta = 16711935; const int Blue = 16711680; const int DeepSkyBlue = 16760576; const int Aqua = 16776960; const int SpringGreen = 8388352; const int Lime = 65280; const int Chartreuse = 65407; const int Yellow = 65535; const int Gold = 55295; const int Orange = 42495; const int DarkOrange = 36095; const int OrangeRed = 17919; const int LimeGreen = 3329330; const int YellowGreen = 3329434; const int DarkOrchid = 13382297; const int CadetBlue = 10526303; const int LawnGreen = 64636; const int MediumSpringGreen = 10156544; const int Goldenrod = 2139610; const int SteelBlue = 11829830; const int Crimson = 3937500; const int Chocolate = 1993170; const int MediumSeaGreen = 7451452; const int MediumVioletRed = 8721863; const int FireBrick = 2237106; const int DarkViolet = 13828244; const int LightSeaGreen = 11186720; const int DimGray = 6908265; const int DarkTurquoise = 13749760; const int Brown = 2763429; const int MediumBlue = 13434880; const int Sienna = 2970272; const int DarkSlateBlue = 9125192; const int DarkGoldenrod = 755384; const int SeaGreen = 5737262; const int OliveDrab = 2330219; const int ForestGreen = 2263842; const int SaddleBrown = 1262987; const int DarkOliveGreen = 3107669; const int DarkBlue = 9109504; const int MidnightBlue = 7346457; const int Indigo = 8519755; const int Maroon = 128; const int Purple = 8388736; const int Navy = 8388608; const int Teal = 8421376; const int Green = 32768; const int Olive = 32896; const int DarkSlateGray = 5197615; const int DarkGreen = 25600; const int Fuchsia = 16711935; const int Black = 0; const int SYMBOL_LEFTPRICE = 5; const int SYMBOL_RIGHTPRICE = 6; const int SYMBOL_ARROWUP = 241; const int SYMBOL_ARROWDOWN = 242; const int SYMBOL_STOPSIGN = 251; /* const int SYMBOL_THUMBSUP = 67; const int SYMBOL_THUMBSDOWN = 68; const int SYMBOL_CHECKSIGN = 25; */ public const int MODE_ASCEND = 1; public const int MODE_DESCEND = 2; const int MODE_TENKANSEN = 1; const int MODE_KIJUNSEN = 2; const int MODE_SENKOUSPANA = 3; const int MODE_SENKOUSPANB = 4; const int MODE_CHINKOUSPAN = 5; const int OP_BUY = 0; const int OP_SELL = 1; const int OP_BUYLIMIT = 2; const int OP_SELLLIMIT = 3; const int OP_BUYSTOP = 4; const int OP_SELLSTOP = 5; const int OBJ_PERIOD_M1 = 0x1; const int OBJ_PERIOD_M5 = 0x2; const int OBJ_PERIOD_M15 = 0x4; const int OBJ_PERIOD_M30 = 0x8; const int OBJ_PERIOD_H1 = 0x10; const int OBJ_PERIOD_H4 = 0x20; const int OBJ_PERIOD_D1 = 0x40; const int OBJ_PERIOD_W1 = 0x80; const int OBJ_PERIOD_MN1 = 0x100; const int OBJ_ALL_PERIODS = 0x1ff; const int REASON_REMOVE = 1; const int REASON_RECOMPILE = 2; const int REASON_CHARTCHANGE = 3; const int REASON_CHARTCLOSE = 4; const int REASON_PARAMETERS = 5; const int REASON_ACCOUNT = 6; const int ERR_NO_ERROR = 0; const int ERR_NO_RESULT = 1; const int ERR_COMMON_ERROR = 2; const int ERR_INVALID_TRADE_PARAMETERS = 3; const int ERR_SERVER_BUSY = 4; const int ERR_OLD_VERSION = 5; const int ERR_NO_CONNECTION = 6; const int ERR_NOT_ENOUGH_RIGHTS = 7; const int ERR_TOO_FREQUENT_REQUESTS = 8; const int ERR_MALFUNCTIONAL_TRADE = 9; const int ERR_ACCOUNT_DISABLED = 64; const int ERR_INVALID_ACCOUNT = 65; const int ERR_TRADE_TIMEOUT = 128; const int ERR_INVALID_PRICE = 129; const int ERR_INVALID_STOPS = 130; const int ERR_INVALID_TRADE_VOLUME = 131; const int ERR_MARKET_CLOSED = 132; const int ERR_TRADE_DISABLED = 133; const int ERR_NOT_ENOUGH_MONEY = 134; const int ERR_PRICE_CHANGED = 135; const int ERR_OFF_QUOTES = 136; const int ERR_BROKER_BUSY = 137; const int ERR_REQUOTE = 138; const int ERR_ORDER_LOCKED = 139; const int ERR_LONG_POSITIONS_ONLY_ALLOWED = 140; const int ERR_TOO_MANY_REQUESTS = 141; const int ERR_TRADE_MODIFY_DENIED = 145; const int ERR_TRADE_CONTEXT_BUSY = 146; const int ERR_TRADE_EXPIRATION_DENIED = 147; const int ERR_TRADE_TOO_MANY_ORDERS = 148; const int ERR_TRADE_HEDGE_PROHIBITED = 149; const int ERR_TRADE_PROHIBITED_BY_FIFO = 150; const int ERR_NO_MQLERROR = 4000; const int ERR_WRONG_FUNCTION_POINTER = 4001; const int ERR_ARRAY_INDEX_OUT_OF_RANGE = 4002; const int ERR_NO_MEMORY_FOR_CALL_STACK = 4003; const int ERR_RECURSIVE_STACK_OVERFLOW = 4004; const int ERR_NOT_ENOUGH_STACK_FOR_PARAM = 4005; const int ERR_NO_MEMORY_FOR_PARAM_STRING = 4006; const int ERR_NO_MEMORY_FOR_TEMP_STRING = 4007; const int ERR_NOT_INITIALIZED_STRING = 4008; const int ERR_NOT_INITIALIZED_ARRAYSTRING = 4009; const int ERR_NO_MEMORY_FOR_ARRAYSTRING = 4010; const int ERR_TOO_LONG_STRING = 4011; const int ERR_REMAINDER_FROM_ZERO_DIVIDE = 4012; const int ERR_ZERO_DIVIDE = 4013; const int ERR_UNKNOWN_COMMAND = 4014; const int ERR_WRONG_JUMP = 4015; const int ERR_NOT_INITIALIZED_ARRAY = 4016; const int ERR_DLL_CALLS_NOT_ALLOWED = 4017; const int ERR_CANNOT_LOAD_LIBRARY = 4018; const int ERR_CANNOT_CALL_FUNCTION = 4019; const int ERR_EXTERNAL_CALLS_NOT_ALLOWED = 4020; const int ERR_NO_MEMORY_FOR_RETURNED_STR = 4021; const int ERR_SYSTEM_BUSY = 4022; const int ERR_INVALID_FUNCTION_PARAMSCNT = 4050; const int ERR_INVALID_FUNCTION_PARAMVALUE = 4051; const int ERR_STRING_FUNCTION_INTERNAL = 4052; const int ERR_SOME_ARRAY_ERROR = 4053; const int ERR_INCORRECT_SERIESARRAY_USING = 4054; const int ERR_CUSTOM_INDICATOR_ERROR = 4055; const int ERR_INCOMPATIBLE_ARRAYS = 4056; const int ERR_GLOBAL_VARIABLES_PROCESSING = 4057; const int ERR_GLOBAL_VARIABLE_NOT_FOUND = 4058; const int ERR_FUNC_NOT_ALLOWED_IN_TESTING = 4059; const int ERR_FUNCTION_NOT_CONFIRMED = 4060; const int ERR_SEND_MAIL_ERROR = 4061; const int ERR_STRING_PARAMETER_EXPECTED = 4062; const int ERR_INTEGER_PARAMETER_EXPECTED = 4063; const int ERR_DOUBLE_PARAMETER_EXPECTED = 4064; const int ERR_ARRAY_AS_PARAMETER_EXPECTED = 4065; const int ERR_HISTORY_WILL_UPDATED = 4066; const int ERR_TRADE_ERROR = 4067; const int ERR_END_OF_FILE = 4099; const int ERR_SOME_FILE_ERROR = 4100; const int ERR_WRONG_FILE_NAME = 4101; const int ERR_TOO_MANY_OPENED_FILES = 4102; const int ERR_CANNOT_OPEN_FILE = 4103; const int ERR_INCOMPATIBLE_FILEACCESS = 4104; const int ERR_NO_ORDER_SELECTED = 4105; const int ERR_UNKNOWN_SYMBOL = 4106; const int ERR_INVALID_PRICE_PARAM = 4107; const int ERR_INVALID_TICKET = 4108; const int ERR_TRADE_NOT_ALLOWED = 4109; const int ERR_LONGS_NOT_ALLOWED = 4110; const int ERR_SHORTS_NOT_ALLOWED = 4111; const int ERR_OBJECT_ALREADY_EXISTS = 4200; const int ERR_UNKNOWN_OBJECT_PROPERTY = 4201; const int ERR_OBJECT_DOES_NOT_EXIST = 4202; const int ERR_UNKNOWN_OBJECT_TYPE = 4203; const int ERR_NO_OBJECT_NAME = 4204; const int ERR_OBJECT_COORDINATES_ERROR = 4205; const int ERR_NO_SPECIFIED_SUBWINDOW = 4206; const int ERR_SOME_OBJECT_ERROR = 4207; class Mq4ChartObjects { private readonly ChartObjects _algoChartObjects; private readonly TimeSeries _timeSeries; private readonly Dictionary _mq4ObjectByName = new Dictionary(); private readonly List _mq4ObjectNameByIndex = new List(); public Mq4ChartObjects(ChartObjects chartObjects, TimeSeries timeSeries) { _algoChartObjects = chartObjects; _timeSeries = timeSeries; } public int ObjectsTotal(int type) { switch (type) { //{ case OBJ_TEXT: return _mq4ObjectByName.Values.OfType().Count(); //} } return 0; } public void Create(string name, int type, int window, int time1, double price1, int time2, double price2, int time3, double price3) { Mq4Object mq4Object = null; switch (type) { //{ case OBJ_TEXT: mq4Object = new Mq4Text(name, type, _algoChartObjects, _timeSeries); break; //} } if (mq4Object == null) return; _algoChartObjects.RemoveObject(name); if (_mq4ObjectByName.ContainsKey(name)) { _mq4ObjectByName.Remove(name); _mq4ObjectNameByIndex.Remove(name); } _mq4ObjectByName[name] = mq4Object; mq4Object.Set(OBJPROP_TIME1, time1); mq4Object.Set(OBJPROP_TIME2, time2); mq4Object.Set(OBJPROP_TIME3, time3); mq4Object.Set(OBJPROP_PRICE1, price1); mq4Object.Set(OBJPROP_PRICE2, price2); mq4Object.Set(OBJPROP_PRICE3, price3); mq4Object.Draw(); } public void Set(string name, int index, Mq4Double value) { if (!_mq4ObjectByName.ContainsKey(name)) return; _mq4ObjectByName[name].Set(index, value); _mq4ObjectByName[name].Draw(); } public void SetText(string name, string text, int font_size, string font, int color) { if (!_mq4ObjectByName.ContainsKey(name)) return; //{ var mq4Text = _mq4ObjectByName[name] as Mq4Text; if (mq4Text != null) mq4Text.Text = text; //} Set(name, OBJPROP_COLOR, color); } public void Delete(string name) { Mq4Object mq4Object; if (!_mq4ObjectByName.TryGetValue(name, out mq4Object)) return; mq4Object.Dispose(); _mq4ObjectByName.Remove(name); _mq4ObjectNameByIndex.Remove(name); } public string ObjectName(int index) { if (index <= 0 || index >= _mq4ObjectNameByIndex.Count) return string.Empty; return _mq4ObjectNameByIndex[index]; } private T GetObject(string name) where T : Mq4Object { Mq4Object mq4Object; if (!_mq4ObjectByName.TryGetValue(name, out mq4Object)) return null; return mq4Object as T; } } abstract class Mq4Object : IDisposable { private readonly ChartObjects _chartObjects; protected Mq4Object(string name, int type, ChartObjects chartObjects) { Name = name; Type = type; _chartObjects = chartObjects; } public int Type { get; private set; } public string Name { get; private set; } protected DateTime Time1 { get { int seconds = Get(OBJPROP_TIME1); return Mq4TimeSeries.ToDateTime(seconds); } } protected double Price1 { get { return Get(OBJPROP_PRICE1); } } protected DateTime Time2 { get { int seconds = Get(OBJPROP_TIME2); return Mq4TimeSeries.ToDateTime(seconds); } } protected double Price2 { get { return Get(OBJPROP_PRICE2); } } protected Colors Color { get { int intColor = Get(OBJPROP_COLOR); if (intColor != CLR_NONE) return Mq4Colors.GetColorByInteger(intColor); return Colors.Black; } } protected int Width { get { return Get(OBJPROP_WIDTH); } } protected int Style { get { return Get(OBJPROP_STYLE); } } public abstract void Draw(); private readonly Dictionary _properties = new Dictionary { { OBJPROP_WIDTH, new Mq4Double(1) }, { OBJPROP_COLOR, new Mq4Double(CLR_NONE) }, { OBJPROP_RAY, new Mq4Double(1) }, { OBJPROP_LEVELCOLOR, new Mq4Double(CLR_NONE) }, { OBJPROP_LEVELSTYLE, new Mq4Double(0) }, { OBJPROP_LEVELWIDTH, new Mq4Double(1) }, { OBJPROP_FIBOLEVELS, new Mq4Double(9) }, { OBJPROP_FIRSTLEVEL + 0, new Mq4Double(0) }, { OBJPROP_FIRSTLEVEL + 1, new Mq4Double(0.236) }, { OBJPROP_FIRSTLEVEL + 2, new Mq4Double(0.382) }, { OBJPROP_FIRSTLEVEL + 3, new Mq4Double(0.5) }, { OBJPROP_FIRSTLEVEL + 4, new Mq4Double(0.618) }, { OBJPROP_FIRSTLEVEL + 5, new Mq4Double(1) }, { OBJPROP_FIRSTLEVEL + 6, new Mq4Double(1.618) }, { OBJPROP_FIRSTLEVEL + 7, new Mq4Double(2.618) }, { OBJPROP_FIRSTLEVEL + 8, new Mq4Double(4.236) } }; public virtual void Set(int index, Mq4Double value) { _properties[index] = value; } public Mq4Double Get(int index) { return _properties.ContainsKey(index) ? _properties[index] : new Mq4Double(0); } private readonly List _addedAlgoChartObjects = new List(); protected void DrawText(string objectName, string text, int index, double yValue, VerticalAlignment verticalAlignment = VerticalAlignment.Center, HorizontalAlignment horizontalAlignment = HorizontalAlignment.Center, Colors? color = null) { _addedAlgoChartObjects.Add(objectName); _chartObjects.DrawText(objectName, text, index, yValue, verticalAlignment, horizontalAlignment, color); } protected void DrawText(string objectName, string text, StaticPosition position, Colors? color = null) { _addedAlgoChartObjects.Add(objectName); _chartObjects.DrawText(objectName, text, position, color); } protected void DrawLine(string objectName, int index1, double y1, int index2, double y2, Colors color, double thickness = 1.0, cAlgo.API.LineStyle style = cAlgo.API.LineStyle.Solid) { _addedAlgoChartObjects.Add(objectName); _chartObjects.DrawLine(objectName, index1, y1, index2, y2, color, thickness, style); } protected void DrawLine(string objectName, DateTime date1, double y1, DateTime date2, double y2, Colors color, double thickness = 1.0, cAlgo.API.LineStyle style = cAlgo.API.LineStyle.Solid) { _addedAlgoChartObjects.Add(objectName); _chartObjects.DrawLine(objectName, date1, y1, date2, y2, color, thickness, style); } protected void DrawVerticalLine(string objectName, DateTime date, Colors color, double thickness = 1.0, cAlgo.API.LineStyle style = cAlgo.API.LineStyle.Solid) { _addedAlgoChartObjects.Add(objectName); _chartObjects.DrawVerticalLine(objectName, date, color, thickness, style); } protected void DrawVerticalLine(string objectName, int index, Colors color, double thickness = 1.0, cAlgo.API.LineStyle style = cAlgo.API.LineStyle.Solid) { _addedAlgoChartObjects.Add(objectName); _chartObjects.DrawVerticalLine(objectName, index, color, thickness, style); } protected void DrawHorizontalLine(string objectName, double y, Colors color, double thickness = 1.0, cAlgo.API.LineStyle style = cAlgo.API.LineStyle.Solid) { _addedAlgoChartObjects.Add(objectName); _chartObjects.DrawHorizontalLine(objectName, y, color, thickness, style); } public void Dispose() { foreach (var name in _addedAlgoChartObjects) { _chartObjects.RemoveObject(name); } } } class Mq4Text : Mq4Object { private readonly TimeSeries _timeSeries; public Mq4Text(string name, int type, ChartObjects chartObjects, TimeSeries timeSeries) : base(name, type, chartObjects) { _timeSeries = timeSeries; } public string Text { get; set; } public override void Set(int index, Mq4Double value) { base.Set(index, value); switch (index) { case OBJPROP_TIME1: _index = _timeSeries.GetIndexByTime(Time1); break; } } private int _index; public override void Draw() { DrawText(Name, Text, _index, Price1, VerticalAlignment.Center, HorizontalAlignment.Center, Color); } } class Mq4Arrow : Mq4Object { private readonly TimeSeries _timeSeries; private int _index; public Mq4Arrow(string name, int type, ChartObjects chartObjects, TimeSeries timeSeries) : base(name, type, chartObjects) { _timeSeries = timeSeries; } public override void Set(int index, Mq4Double value) { base.Set(index, value); switch (index) { case OBJPROP_TIME1: _index = _timeSeries.GetIndexByTime(Time1); break; } } private int ArrowCode { get { return Get(OBJPROP_ARROWCODE); } } public override void Draw() { string arrowString; HorizontalAlignment horizontalAlignment; switch (ArrowCode) { case SYMBOL_RIGHTPRICE: horizontalAlignment = HorizontalAlignment.Right; arrowString = Price1.ToString(); break; case SYMBOL_LEFTPRICE: horizontalAlignment = HorizontalAlignment.Left; arrowString = Price1.ToString(); break; default: arrowString = FXPT_CandleSizev2_Indicator.GetArrowByCode(ArrowCode); horizontalAlignment = HorizontalAlignment.Center; break; } DrawText(Name, arrowString, _index, Price1, VerticalAlignment.Center, horizontalAlignment, Color); } } bool ObjectSet(Mq4String name, int index, Mq4Double value) { _mq4ChartObjects.Set(name, index, value); return true; } bool ObjectSetText(Mq4String name, Mq4String text, int font_size = 11, string font = null, int color = CLR_NONE) { _mq4ChartObjects.SetText(name, text, font_size, font, color); return true; } bool ObjectCreate(Mq4String name, int type, int window, int time1, double price1, int time2 = 0, double price2 = 0, int time3 = 0, double price3 = 0) { _mq4ChartObjects.Create(name, type, window, time1, price1, time2, price2, time3, price3); return true; } bool ObjectDelete(Mq4String name) { _mq4ChartObjects.Delete(name); return true; } int ObjectsTotal(int type = EMPTY) { return _mq4ChartObjects.ObjectsTotal(type); } public string ObjectName(int index) { return _mq4ChartObjects.ObjectName(index); } } //Custom Indicators Place Holder class Mq4DoubleComparer : IComparer { public int Compare(Mq4Double x, Mq4Double y) { return x.CompareTo(y); } } class Mq4String { private readonly string _value; public Mq4String(string value) { _value = value; } public static implicit operator Mq4String(string value) { return new Mq4String(value); } public static implicit operator Mq4String(int value) { return new Mq4String(value.ToString()); } public static implicit operator Mq4String(Mq4Null mq4Null) { return new Mq4String(null); } public static implicit operator string(Mq4String mq4String) { if ((object)mq4String == null) return null; return mq4String._value; } public static implicit operator Mq4String(Mq4Double mq4Double) { return new Mq4String(mq4Double.ToString()); } public static bool operator <(Mq4String x, Mq4String y) { return string.Compare(x._value, y._value) == -1; } public static bool operator >(Mq4String x, Mq4String y) { return string.Compare(x._value, y._value) == 1; } public static bool operator <(Mq4String x, string y) { return string.Compare(x._value, y) == -1; } public static bool operator >(Mq4String x, string y) { return string.Compare(x._value, y) == 1; } public static bool operator <=(Mq4String x, Mq4String y) { return string.Compare(x._value, y._value) <= 0; } public static bool operator >=(Mq4String x, Mq4String y) { return string.Compare(x._value, y._value) >= 0; } public static bool operator <=(Mq4String x, string y) { return string.Compare(x._value, y) <= 0; } public static bool operator >=(Mq4String x, string y) { return string.Compare(x._value, y) >= 0; } public static bool operator ==(Mq4String x, Mq4String y) { return string.Compare(x._value, y._value) == 0; } public static bool operator !=(Mq4String x, Mq4String y) { return string.Compare(x._value, y._value) != 0; } public static bool operator ==(Mq4String x, string y) { return string.Compare(x._value, y) == 0; } public static bool operator !=(Mq4String x, string y) { return string.Compare(x._value, y) != 0; } public override string ToString() { if ((object)this == null) return string.Empty; return _value.ToString(); } public static readonly Mq4String Empty = new Mq4String(string.Empty); public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; if (obj.GetType() != this.GetType()) return false; return Equals((Mq4String)obj); } protected bool Equals(Mq4String other) { return this == other; } public override int GetHashCode() { return (_value != null ? _value.GetHashCode() : 0); } } struct Mq4Char { char _char; public Mq4Char(byte code) { _char = Encoding.Unicode.GetString(new byte[] { code, 0 })[0]; } public Mq4Char(char @char) { _char = @char; } public static implicit operator char(Mq4Char mq4Char) { return mq4Char._char; } public static implicit operator Mq4Char(int code) { return new Mq4Char((byte)code); } public static implicit operator Mq4Char(string str) { if (string.IsNullOrEmpty(str) || str.Length == 0) return new Mq4Char(' '); return new Mq4Char(str[0]); } } struct Mq4Null { public static implicit operator string(Mq4Null mq4Null) { return (string)null; } public static implicit operator int(Mq4Null mq4Null) { return 0; } public static implicit operator double(Mq4Null mq4Null) { return 0; } } static class Comparers { public static IComparer GetComparer() { if (typeof(T) == typeof(Mq4Double)) return (IComparer)new Mq4DoubleComparer(); return Comparer.Default; } } static class DataSeriesExtensions { public static int InvertIndex(this DataSeries dataSeries, int index) { return dataSeries.Count - 1 - index; } public static Mq4Double Last(this DataSeries dataSeries, int shift, DataSeries sourceDataSeries) { return dataSeries[sourceDataSeries.Count - 1 - shift]; } } static class TimeSeriesExtensions { public static DateTime Last(this TimeSeries timeSeries, int index) { return timeSeries[timeSeries.InvertIndex(index)]; } public static int InvertIndex(this TimeSeries timeSeries, int index) { return timeSeries.Count - 1 - index; } public static int GetIndexByTime(this TimeSeries timeSeries, DateTime time) { var index = timeSeries.Count - 1; for (var i = timeSeries.Count - 1; i >= 0; i--) { if (timeSeries[i] < time) { index = i + 1; break; } } return index; } } static class Mq4Colors { public static Colors GetColorByInteger(int integer) { switch (integer) { case 16777215: return Colors.White; case 16448255: return Colors.Snow; case 16449525: return Colors.MintCream; case 16118015: return Colors.LavenderBlush; case 16775408: return Colors.AliceBlue; case 15794160: return Colors.Honeydew; case 15794175: return Colors.Ivory; case 16119285: return Colors.WhiteSmoke; case 15136253: return Colors.OldLace; case 14804223: return Colors.MistyRose; case 16443110: return Colors.Lavender; case 15134970: return Colors.Linen; case 16777184: return Colors.LightCyan; case 14745599: return Colors.LightYellow; case 14481663: return Colors.Cornsilk; case 14020607: return Colors.PapayaWhip; case 14150650: return Colors.AntiqueWhite; case 14480885: return Colors.Beige; case 13499135: return Colors.LemonChiffon; case 13495295: return Colors.BlanchedAlmond; case 12903679: return Colors.Bisque; case 13353215: return Colors.Pink; case 12180223: return Colors.PeachPuff; case 14474460: return Colors.Gainsboro; case 12695295: return Colors.LightPink; case 11920639: return Colors.Moccasin; case 11394815: return Colors.NavajoWhite; case 11788021: return Colors.Wheat; case 13882323: return Colors.LightGray; case 15658671: return Colors.PaleTurquoise; case 11200750: return Colors.PaleGoldenrod; case 15130800: return Colors.PowderBlue; case 14204888: return Colors.Thistle; case 10025880: return Colors.PaleGreen; case 15128749: return Colors.LightBlue; case 14599344: return Colors.LightSteelBlue; case 16436871: return Colors.LightSkyBlue; case 12632256: return Colors.Silver; case 13959039: return Colors.Aquamarine; case 9498256: return Colors.LightGreen; case 9234160: return Colors.Khaki; case 14524637: return Colors.Plum; case 8036607: return Colors.LightSalmon; case 15453831: return Colors.SkyBlue; case 8421616: return Colors.LightCoral; case 15631086: return Colors.Violet; case 7504122: return Colors.Salmon; case 11823615: return Colors.HotPink; case 8894686: return Colors.BurlyWood; case 8034025: return Colors.DarkSalmon; case 9221330: return Colors.Tan; case 15624315: return Colors.MediumSlateBlue; case 6333684: return Colors.SandyBrown; case 11119017: return Colors.DarkGray; case 15570276: return Colors.CornflowerBlue; case 5275647: return Colors.Coral; case 9662683: return Colors.PaleVioletRed; case 14381203: return Colors.MediumPurple; case 14053594: return Colors.Orchid; case 9408444: return Colors.RosyBrown; case 4678655: return Colors.Tomato; case 9419919: return Colors.DarkSeaGreen; case 11193702: return Colors.MediumAquamarine; case 3145645: return Colors.GreenYellow; case 13850042: return Colors.MediumOrchid; case 6053069: return Colors.IndianRed; case 7059389: return Colors.DarkKhaki; case 13458026: return Colors.SlateBlue; case 14772545: return Colors.RoyalBlue; case 13688896: return Colors.Turquoise; case 16748574: return Colors.DodgerBlue; case 13422920: return Colors.MediumTurquoise; case 9639167: return Colors.DeepPink; case 10061943: return Colors.LightSlateGray; case 14822282: return Colors.BlueViolet; case 4163021: return Colors.Peru; case 9470064: return Colors.SlateGray; case 8421504: return Colors.Gray; case 255: return Colors.Red; case 16711935: return Colors.Magenta; case 16711680: return Colors.Blue; case 16760576: return Colors.DeepSkyBlue; case 16776960: return Colors.Aqua; case 8388352: return Colors.SpringGreen; case 65280: return Colors.Lime; case 65407: return Colors.Chartreuse; case 65535: return Colors.Yellow; case 55295: return Colors.Gold; case 42495: return Colors.Orange; case 36095: return Colors.DarkOrange; case 17919: return Colors.OrangeRed; case 3329330: return Colors.LimeGreen; case 3329434: return Colors.YellowGreen; case 13382297: return Colors.DarkOrchid; case 10526303: return Colors.CadetBlue; case 64636: return Colors.LawnGreen; case 10156544: return Colors.MediumSpringGreen; case 2139610: return Colors.Goldenrod; case 11829830: return Colors.SteelBlue; case 3937500: return Colors.Crimson; case 1993170: return Colors.Chocolate; case 7451452: return Colors.MediumSeaGreen; case 8721863: return Colors.MediumVioletRed; case 13828244: return Colors.DarkViolet; case 11186720: return Colors.LightSeaGreen; case 6908265: return Colors.DimGray; case 13749760: return Colors.DarkTurquoise; case 2763429: return Colors.Brown; case 13434880: return Colors.MediumBlue; case 2970272: return Colors.Sienna; case 9125192: return Colors.DarkSlateBlue; case 755384: return Colors.DarkGoldenrod; case 5737262: return Colors.SeaGreen; case 2330219: return Colors.OliveDrab; case 2263842: return Colors.ForestGreen; case 1262987: return Colors.SaddleBrown; case 3107669: return Colors.DarkOliveGreen; case 9109504: return Colors.DarkBlue; case 7346457: return Colors.MidnightBlue; case 8519755: return Colors.Indigo; case 128: return Colors.Maroon; case 8388736: return Colors.Purple; case 8388608: return Colors.Navy; case 8421376: return Colors.Teal; case 32768: return Colors.Green; case 32896: return Colors.Olive; case 5197615: return Colors.DarkSlateGray; case 25600: return Colors.DarkGreen; case 0: default: return Colors.Black; } } } static class EventExtensions { public static void Raise(this Action action, T1 arg1, T2 arg2) { if (action != null) action(arg1, arg2); } } static class Mq4LineStyles { public static LineStyle ToLineStyle(int style) { switch (style) { case 1: return LineStyle.Lines; case 2: return LineStyle.Dots; case 3: case 4: return LineStyle.LinesDots; default: return LineStyle.Solid; } } } class Mq4TimeSeries { private readonly TimeSeries _timeSeries; private static readonly DateTime StartDateTime = new DateTime(1970, 1, 1); public Mq4TimeSeries(TimeSeries timeSeries) { _timeSeries = timeSeries; } public static int ToInteger(DateTime dateTime) { return (int)(dateTime - StartDateTime).TotalSeconds; } public static DateTime ToDateTime(int seconds) { return StartDateTime.AddSeconds(seconds); } public int this[int index] { get { if (index < 0 || index >= _timeSeries.Count) return 0; DateTime dateTime = _timeSeries[_timeSeries.Count - 1 - index]; return ToInteger(dateTime); } } } static class ConvertExtensions { public static double? ToNullableDouble(this double protection) { if (protection == 0) return null; return protection; } public static DateTime? ToNullableDateTime(this int time) { if (time == 0) return null; return Mq4TimeSeries.ToDateTime(time); } public static long ToUnitsVolume(this Symbol symbol, double lots) { return symbol.NormalizeVolume(symbol.ToNotNormalizedUnitsVolume(lots)); } public static double ToNotNormalizedUnitsVolume(this Symbol symbol, double lots) { if (symbol.Code.Contains("XAU") || symbol.Code.Contains("XAG")) return 100 * lots; return 100000 * lots; } public static double ToLotsVolume(this Symbol symbol, long volume) { if (symbol.Code.Contains("XAU") || symbol.Code.Contains("XAG")) return volume * 1.0 / 100; return volume * 1.0 / 100000; } } struct Mq4Double : IComparable, IComparable { private readonly double _value; public Mq4Double(double value) { _value = value; } public static implicit operator double(Mq4Double property) { return property._value; } public static implicit operator int(Mq4Double property) { return (int)property._value; } public static implicit operator bool(Mq4Double property) { return (int)property._value != 0; } public static implicit operator Mq4Double(double value) { return new Mq4Double(value); } public static implicit operator Mq4Double(int value) { return new Mq4Double(value); } public static implicit operator Mq4Double(bool value) { return new Mq4Double(value ? 1 : 0); } public static implicit operator Mq4Double(Mq4Null value) { return new Mq4Double(0); } public static Mq4Double operator +(Mq4Double d1, Mq4Double d2) { return new Mq4Double(d1._value + d2._value); } public static Mq4Double operator -(Mq4Double d1, Mq4Double d2) { return new Mq4Double(d1._value - d2._value); } public static Mq4Double operator -(Mq4Double d) { return new Mq4Double(-d._value); } public static Mq4Double operator +(Mq4Double d) { return new Mq4Double(+d._value); } public static Mq4Double operator *(Mq4Double d1, Mq4Double d2) { return new Mq4Double(d1._value * d2._value); } public static Mq4Double operator /(Mq4Double d1, Mq4Double d2) { return new Mq4Double(d1._value / d2._value); } public static bool operator ==(Mq4Double d1, Mq4Double d2) { return d1._value == d2._value; } public static bool operator >(Mq4Double d1, Mq4Double d2) { return d1._value > d2._value; } public static bool operator >=(Mq4Double d1, Mq4Double d2) { return d1._value >= d2._value; } public static bool operator <(Mq4Double d1, Mq4Double d2) { return d1._value < d2._value; } public static bool operator <=(Mq4Double d1, Mq4Double d2) { return d1._value <= d2._value; } public static bool operator !=(Mq4Double d1, Mq4Double d2) { return d1._value != d2._value; } public override string ToString() { return _value.ToString(); } public int CompareTo(object obj) { return _value.CompareTo(obj); } public int CompareTo(Mq4Double obj) { return _value.CompareTo(obj); } } class Mq4DoubleTwoDimensionalArray { private List _data = new List(); private List _arrays = new List(); private readonly Mq4Double _defaultValue; private readonly int _size2; public Mq4DoubleTwoDimensionalArray(int size2) { _defaultValue = 0; _size2 = size2; } public void Add(Mq4Double value) { _data.Add(value); } private void EnsureCountIsEnough(int index) { while (_arrays.Count <= index) _arrays.Add(new Mq4DoubleArray()); } public void Initialize(Mq4Double value) { for (var i = 0; i < _data.Count; i++) _data[i] = value; } public int Range(int index) { if (index == 0) return _data.Count; return this[0].Length; } public Mq4DoubleArray this[int index] { get { if (index < 0) return new Mq4DoubleArray(); EnsureCountIsEnough(index); return _arrays[index]; } } public Mq4Double this[int index1, int index2] { get { if (index1 < 0) return 0; EnsureCountIsEnough(index1); return _arrays[index1][index2]; } set { if (index1 < 0) return; EnsureCountIsEnough(index1); _arrays[index1][index2] = value; } } } class Mq4DoubleArray : IMq4DoubleArray, IEnumerable { private List _data = new List(); private readonly Mq4Double _defaultValue; public Mq4DoubleArray(int size = 0) { _defaultValue = 0; } public IEnumerator GetEnumerator() { return _data.GetEnumerator(); } private bool _isInverted; public bool IsInverted { get { return _isInverted; } set { _isInverted = value; } } public void Add(Mq4Double value) { _data.Add(value); } private void EnsureCountIsEnough(int index) { while (_data.Count <= index) _data.Add(_defaultValue); } public int Length { get { return _data.Count; } } public void Resize(int newSize) { while (newSize < _data.Count) _data.RemoveAt(_data.Count - 1); while (newSize > _data.Count) _data.Add(_defaultValue); } public Mq4Double this[int index] { get { if (index < 0) return _defaultValue; EnsureCountIsEnough(index); return _data[index]; } set { if (index < 0) return; EnsureCountIsEnough(index); _data[index] = value; Changed.Raise(index, value); } } public event Action Changed; } class Mq4MarketDataSeries : IMq4DoubleArray { private DataSeries _dataSeries; public Mq4MarketDataSeries(DataSeries dataSeries) { _dataSeries = dataSeries; } public Mq4Double this[int index] { get { return _dataSeries.Last(index); } set { } } public int Length { get { return _dataSeries.Count; } } public void Resize(int newSize) { } } class Mq4StringArray : IEnumerable { private List _data = new List(); private readonly Mq4String _defaultValue; public Mq4StringArray(int size = 0) { _defaultValue = ""; } public IEnumerator GetEnumerator() { return _data.GetEnumerator(); } private bool _isInverted; public bool IsInverted { get { return _isInverted; } set { _isInverted = value; } } public void Add(Mq4String value) { _data.Add(value); } private void EnsureCountIsEnough(int index) { while (_data.Count <= index) _data.Add(_defaultValue); } public int Length { get { return _data.Count; } } public void Resize(int newSize) { while (newSize < _data.Count) _data.RemoveAt(_data.Count - 1); while (newSize > _data.Count) _data.Add(_defaultValue); } public Mq4String this[int index] { get { if (index < 0) return _defaultValue; EnsureCountIsEnough(index); return _data[index]; } set { if (index < 0) return; EnsureCountIsEnough(index); _data[index] = value; } } } interface IMq4DoubleArray { Mq4Double this[int index] { get; set; } int Length { get; } void Resize(int newSize); } class Mq4ArrayToDataSeriesConverter { private readonly Mq4DoubleArray _mq4Array; private readonly IndicatorDataSeries _dataSeries; public Mq4ArrayToDataSeriesConverter(Mq4DoubleArray mq4Array, IndicatorDataSeries dataSeries) { _mq4Array = mq4Array; _dataSeries = dataSeries; _mq4Array.Changed += OnValueChanged; CopyAllValues(); } private void CopyAllValues() { for (var i = 0; i < _mq4Array.Length; i++) { if (_mq4Array.IsInverted) _dataSeries[_mq4Array.Length - i] = _mq4Array[i]; else _dataSeries[i] = _mq4Array[i]; } } private void OnValueChanged(int index, Mq4Double value) { int indexToSet; if (_mq4Array.IsInverted) indexToSet = _mq4Array.Length - index; else indexToSet = index; if (indexToSet < 0) return; _dataSeries[indexToSet] = value; } } class Mq4ArrayToDataSeriesConverterFactory { private readonly Dictionary _cachedAdapters = new Dictionary(); private Func _dataSeriesFactory; public Mq4ArrayToDataSeriesConverterFactory(Func dataSeriesFactory) { _dataSeriesFactory = dataSeriesFactory; } public DataSeries Create(Mq4DoubleArray mq4Array) { IndicatorDataSeries dataSeries; if (_cachedAdapters.TryGetValue(mq4Array, out dataSeries)) return dataSeries; dataSeries = _dataSeriesFactory(); new Mq4ArrayToDataSeriesConverter(mq4Array, dataSeries); _cachedAdapters[mq4Array] = dataSeries; return dataSeries; } } }  
03 Oct 2016
Downloads
516
Comments
0
Rating
5
Download
This overlay indicator sets up the 34 EMA Wave and paints the GRaB candles used extensively by Raghee Horner and followers of her trading style. Additionally this indicator draws vertical lines to show the minimum and maximum Lookback advocated by Raghee when identifying the trend in a specific time frame. For more information on what these are and how Raghee advocates using them take a look at https://youtu.be/L06MjjgwYnw Limitations: The cTrader/cAlgo API does not allow developers to detect when the Zoom level has changed or what it is.  This means I have to use a specific width setting when painting candle bodies.  The default used is 5 but I have provided a parameter that allows you to change to anywhere between 1 and 15.  If you zoom in and out all the time this can be a bit tedious but not a lot I can do about it until the API changes to allow developers to determine things like Zoom level and/or view port dimensions. Also the API dos not support colour or line setting parameters.  There is a hack/work around using Outputs but we have actual outputs in this indicator so I haven't used it.  When the API supports colour and line style as individual parameters I will update the indicator to allow customising colours used to paint candles and the look back lines. Constructive criticism and feedback are always welcome
26 Sep 2016
Downloads
237
Comments
1
Rating
0
Download