/*[[ Name := WPR for Multi Pair Author := Gary Hensley Lots := 1 Stop Loss := 0 Take Profit := 0 Trailing Stop := 0 ]]*/ // ==================================================================================================== // Testing //===================================================================================================== var: BeginYear(2000),BeginMonth(0),BeginDay(0); if IsTesting=True then if ((TimeYear(Time[0])*10000)+(TimeMonth(Time[0])*100)+TimeDay(Time[0])) < ((BeginYear*10000)+(BeginMonth*100)+BeginDay) then exit; // ==================================================================================================== // Check for Open Orders and set variables for direction // ==================================================================================================== var: cnt(0),OpenTrades(0),dir(0); var: lasttime(0); OpenTrades = 0; for cnt=1 to TotalTrades { if OrderValue(cnt,VAL_SYMBOL)=Symbol then { OpenTrades=1; If OrderValue(cnt,VAL_TYPE)=OP_BUY then dir=1; If OrderValue(cnt,VAL_TYPE)=OP_SELL then dir=-1; }; }; // ==================================================================================================== // Indicator for this chart // ==================================================================================================== var: IND(0),vI(0); ind=iWPR(14,0); if ind>-50 then vI=1; if ind<-50 then vI=-1; SetGlobalVariable(AccountNumber+"_IND_"+symbol,vI); // ==================================================================================================== // Get Short Term Indicators from pairs // ==================================================================================================== var: EU_Trig(0),GU_Trig(0),UC_Trig(0),UJ_Trig(0); GU_Trig=GetGlobalVariable(AccountNumber+"_IND_GBPUSD"); EU_Trig=GetGlobalVariable(AccountNumber+"_IND_EURUSD"); UC_Trig=GetGlobalVariable(AccountNumber+"_IND_USDCHF"); UJ_Trig=GetGlobalVariable(AccountNumber+"_IND_USDJPY"); var:vTrig(0); vTrig=GU_TRIG+EU_TRIG-UC_TRIG-UJ_TRIG; // ==================================================================================================== // Buy/Sell Indicator // ==================================================================================================== var: bsi(0); bsi=0; if vTrig>2 then bsi=1; if vTrig<-2 then bsi=-1; if Symbol>"USD" then bsi=bsi*-1; Comment("BSI: ",bsi,"\nTRIG: ",vTrig); // ==================================================================================================== // Lot Calculation //===================================================================================================== defines: UsePct(10),MaxLots(100); var: vLots(0),vSL(0),vTP(0); vSL=0; vTP=0; vLots = Lots; if UsePct>0 then { vLots = Floor(balance*(UsePct/100)/1000); if vLots<1 then vLots= 1; if vLots>MaxLots then vLots=MaxLots; }; // ==================================================================================================== // Entry //===================================================================================================== if OpenTrades = 0 then { if bsi>0 then //buy { SetOrder(OP_BUY,vLots,Ask,3,vSL,vTP,Blue); exit; }; if bsi<0 then //sell { SetOrder(OP_SELL,vLots,Bid,3,vSL,vTP,Red); exit; }; }; // =================================================================================================