//+------------------------------------------------------------------+ //| BuySellBasketTotal.mq4 | //| Copyright © 2004, MetaQuotes Software Corp. | //| http://www.metaquotes.net/ | //+------------------------------------------------------------------+ #property copyright "Copyright © 2004, MetaQuotes Software Corp." #property link "http://www.metaquotes.net/" #property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 Green #property indicator_color2 Red //---- input parameters extern int look_back= 0; extern int DisplayBars = 500; extern string basket1= "USDCHF"; extern string basket2= "EURCHF"; extern string basket3= "EURUSD"; double Pair1,Pair2,Pair3; double Pair1_now,Pair2_now,Pair3_now; double Pair1_pips,Pair2_pips,Pair3_pips; double myPoint1, myPoint2, myPoint3; //---- buffers double PipsBuyBuffer[]; double PipsSellBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { string short_name; //---- 2 additional buffers are used for counting. // IndicatorBuffers(3); //---- indicator line SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,PipsBuyBuffer); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1,PipsSellBuffer); //---- name for DataWindow and indicator subwindow label short_name="BuySellBasket"; IndicatorShortName(short_name); SetIndexLabel(0,"PipsBuy"); SetIndexLabel(1,"PipsSell"); //---- GetPoints(); //---- return(0); } //+------------------------------------------------------------------+ //| BuySellBasket Total | //+------------------------------------------------------------------+ int start() { int i,counted_bars=IndicatorCounted(); double rel,negative,positive; static bool HaveSpreads = false; static bool HavePoints = false; //---- //---- if (DisplayBars < 1) i=Bars-1; else i = DisplayBars; while(i>=0) { Pair1= iOpen(basket1, 0, i + look_back); Pair2= iOpen(basket2, 0, i + look_back); Pair3= iOpen(basket3, 0, i + look_back); Pair1_now= iClose(basket1, 0, i); Pair2_now= iClose(basket2, 0, i); Pair3_now= iClose(basket3, 0, i); // Buy Pair1_pips = (Pair1_now - Pair1)/myPoint1; Pair2_pips = (Pair2_now - Pair2)/myPoint2; Pair3_pips = (Pair3_now - Pair3)/myPoint3; PipsBuyBuffer[i] = Pair1_pips + Pair2_pips + Pair3_pips; // Sell Pair1_pips = (Pair1 - Pair1_now)/myPoint1; Pair2_pips = (Pair2 - Pair2_now)/myPoint2; Pair3_pips = (Pair3 - Pair3_now)/myPoint3; PipsSellBuffer[i] = Pair1_pips + Pair2_pips + Pair3_pips; i--; } //---- return(0); } double dPoint(string sym) { double _Point; if (StringFind(sym, "JPY")>=0) _Point=0.01; else _Point=0.0001; return (_Point); } void GetPoints() { myPoint1 = dPoint(basket1); myPoint2 = dPoint(basket2); myPoint3 = dPoint(basket3); } //+------------------------------------------------------------------+