ProRealCode - Trading & Coding with ProRealTime™
//-------------------------------------------------------------------------
// Main code : VUSA daily Buy and hold v2.0
//Timeframe 1 Day
//Posiitonsize 10
// Kasper Elsborg @Elsborgtrading
//-------------------------------------------------------------------------
//==========Parameters===============================
DEFPARAM CumulateOrders = true // Cumulating position
DEFPARAM PRELOADBARS = 500
//====================Define Tradetime===============
IF (Time >= 090000 AND Time <= 1730000) THEN //VUSA Tradetime GMT+1
Tradetime=1
else
Tradetime=0
endif
//===================================================
//==================Define ONCE's====================
ONCE entertrade=1
ONCE CountOfTrades=0
ONCE mypos=10
//ONCE dailyHigh = 0
ONCE dailyLow = 0
//ONCE weeklyHigh = 0
//ONCE monthlyHigh = 0
ONCE monthlyLow = 0
ONCE lastWeekBarIndex = 0
ONCE lastMonthBarIndex = 0
//==================
positionsize = mypos
//==================Indicators====================
lastInPeriod=currentDayOfTheMonth = 14 or currentDayOfTheMonth = 30 and entertrade and tradetime//NEED CHECK for ending dates in weekends!!!
Myema=ExponentialAverage[10](close)//34
// calculate daily high/low (include sunday values if available)
//dailyHigh = DHigh(1)
dailyLow = DLow(1)
OnMarketBarCount=barindex-tradeindex
//==============================================================================================
//NOT IN USE, but implemented in a strategy that is a non buy and hold
// it will accumulate position counts and enter OnMarketBarCount with the number of positions you sold
//NOT WORKING ATM!!
//==============================================================================================
//Once Test1=1
//if not onmarket and test1 then
//test1=0
//mypos=countofposition[1]
//elsif onmarket then
//positionsize=mypos
//test1=1
//else
//mypos=mypos
//endif
//======================================================================================================
//Accumilate Positions if no trades in the 14 days period- an alternative to lastinperiod
if OnMarketBarCount>17 then
factor=2
//elsif OnMarketBarCount>=32 then
//factor=3
else
factor=1
endif
//=====================================================================================================
// calculate weekly high/low
If DayOfWeek < DayOfWeek[1] then
//weeklyHigh = Highest[BarIndex - lastWeekBarIndex](dailyHigh)
weeklylow = lowest[BarIndex - lastWeekBarIndex](dailylow)
lastWeekBarIndex = BarIndex
ENDIF
// calculate monthly high/low
If Month <> Month[1] then
//monthlyHigh = Highest[BarIndex - lastMonthBarIndex](dailyHigh)
monthlyLow = Lowest[BarIndex - lastMonthBarIndex](dailyLow)
lastMonthBarIndex = BarIndex
ENDIF
//monthbuy=open>monthlyHigh
//weekbuy=open>weeklyHigh
//Myema50=ExponentialAverage[x1](close)//30
//Myema200=ExponentialAverage[x2](close)//90
//
//bull=1//myema50>myema200
//bear=myema50<myema200
//=====================================Trade Conditions====================================================
//==============================Limmit Trades to one every 14th day===========
currentDayOfTheMonth = Date - ((CurrentYear * 10000) + CurrentMonth * 100)
midOfMonth = 15
if currentDayOfTheMonth= 15 then
entertrade=1
elsif currentDayOfTheMonth = 14 and dayofweek=5 then
entertrade=1
elsif currentDayOfTheMonth = 13 and dayofweek=5 then
entertrade=1
else
entertrade=entertrade
endif
if currentDayOfTheMonth = 1 then
entertrade=1
if currentMonth = 2 or 4 or 6 or 9 or 11 then//30 days months
if currentDayOfTheMonth = 29 and dayofweek=5 then
entertrade=1
elsif currentDayOfTheMonth = 30 and dayofweek=5 then
entertrade=1
else
entertrade=entertrade
endif
if currentMonth = 1 or 3 or 5 or 7 or 8 or 10 or 12 then//31 days months
if currentDayOfTheMonth = 29 and dayofweek=5 then
entertrade=1
elsif currentDayOfTheMonth = 30 and dayofweek=5 then
entertrade=1
elsif currentDayOfTheMonth = 31 and dayofweek=5 then
entertrade=1
else
entertrade=entertrade
endif
endif
endif
endif
IF CurrentMonth = 1 or 2 or 3 or 4 or 5 or 6 or 7 or 8 or 9 or 10 or 11 or 12 THEN
IF OnMarketBarCount[1]<OnMarketBarCount and currentDayOfTheMonth <= midOfMonth and entertrade THEN
entertrade=1
CountOfTrades=CountOfTrades
elsif OnMarketBarCount[1]>OnMarketBarCount and currentDayOfTheMonth <= midOfMonth and entertrade THEN
entertrade=0
CountOfTrades=CountOfTrades+1
endif
IF OnMarketBarCount[1]<OnMarketBarCount and currentDayOfTheMonth >= midOfMonth and entertrade THEN
entertrade=1
CountOfTrades=CountOfTrades
elsif OnMarketBarCount[1]>OnMarketBarCount and currentDayOfTheMonth >= midOfMonth and entertrade THEN
entertrade=0
CountOfTrades=CountOfTrades+1
ENDIF
endif
//=============================================================================================================
conditionEMA=low crosses under myema and entertrade and tradetime //and bull
conditionMonthlylow=low crosses under monthlylow and entertrade and tradetime //and bull
conditionWeeklyLow= low crosses under weeklylow and entertrade and tradetime
lastInPeriod=(currentDayOfTheMonth = 14 or currentDayOfTheMonth = 30) and entertrade and tradetime//NEED CHECK for ending dates in weekends!!!
//lastInPeriod=currentDayOfTheMonth = 14 and entertrade and tradetime or currentDayOfTheMonth = 13 and dayofweek=5 and entertrade and tradetime or currentDayOfTheMonth = 30 and entertrade and tradetime or currentDayOfTheMonth = 29 and dayofweek=5 and entertrade and tradetime or currentDayOfTheMonth = 28 and dayofweek=5 and entertrade and tradetime
//conditionMonthlyHigh=high>MonthlyHigh and entertrade
//ConditionWeekleyHigh= high>weeklyHigh and entertrade and tradetime
//=======================================Enter LONG Position========================================
if conditionEMA or conditionMonthlylow or conditionWeeklylow or lastinperiod then//or conditionMonthlyHigh or ConditionWeekleyHigh then
buy Positionsize*factor shares at market
//if not conditionEMA and not conditionMonthlylow and not conditionWeeklylow and ConditionWeekleyHigh then
//buy Positionsize*factor shares at market
//endif
endif
//=====================================================================================================================================
//=============================================================GRAPH SECTION==========================================================
//=====================================================================================================================================
//========================================== rem out all lines from GRAPH SECTION to live trade the code=====================================
//once tradepricetest=1
//ONCE BrokerProfit=0
//once countofdays=0
//once AccumulatedTradeCost=tradeprice*mypos
//Comission from IG- given: the commission charge is 0.10% of total tradeprice or $10, whichever is higher
//comissiontest=0.001*tradeprice*positionsize
//IF OnMarketBarCount[1]<OnMarketBarCount then
//AccumulatedTradeCost=AccumulatedTradeCost
//if tradepricetest then
//AccumulatedTradeCost=AccumulatedTradeCost+tradeprice*mypos
//tradepricetest=0
//endif
//if comissiontest<10 then
//comission=10
//endif
//elsif OnMarketBarCount[1]>OnMarketBarCount then
//tradepricetest=1
//comission=comissiontest
//endif
//Capital = 500 // initial capital of account
//
//equity = Capital + StrategyProfit
//overnight fee from IG- given: (5 x 35.6425 x (2.5% + 0.25%))/365. This would give a total of £.0.0134 per evening.
//interestrate=0.025//2.5%
//adminfee=0.0025//0.25%
//overnightfee = (countofposition*tradeprice*(interestrate+adminfee))/365*countofdays //0.8 //broker overnight fee of a position (in money)
// ---equity = Capital + StrategyProfit
//DayChart=1 //can be set to bar qu
//
//if not onmarket then
//countofdays=0
//elsif onmarket and DayOfWeek[1]<DayOfWeek then// = DayChart then
//countofdays=countofdays+1
//else
//countofdays=countofdays
//endif
//floatingprofit = ((((close-positionprice)*pointvalue)*countofposition)/pipsize)-(overnightfee+comission)//+(overnightfee+comission) //actual trade gains
//Brokerprofit=((((close-positionprice)*pointvalue)*countofposition)/pipsize)-Floatingprofit
//BrokerProfitinProcent=(((floatingprofit-Brokerprofit)/floatingprofit)-1)*100
//TrueEquity=AccumulatedTradeCost+floatingprofit+capital
//TrueProfitInProcent=((TrueEquity/AccumulatedTradeCost)-1)*100
//graph conditionMonthlyHigh COLOURED(0,0,255) AS "conditionMonthlyHigh"
//graph ConditionWeekleyHigh COLOURED(0,255,0) AS "ConditionWeekleyHigh"
//graph TrueEquity COLOURED(0,0,255) AS "trueEquity"
//graph BrokerProfit COLOURED(255,0,0) AS "BrokerProfit"
//graph countofdays COLOURED(0,0,0) AS "countofdays"
//graph entertrade COLOURED(255,255,0) AS "entertrade"
//graph conditionWeeklyLow COLOURED(0,0,0) AS "conditionWeeklyLow"
//graph conditionEMA COLOURED(255,0,0) AS "conditionEMA"
//graph lastinperiod COLOURED(255,0,255) AS "lastinperiod"
//graph conditionMonthlylow COLOURED(0,255,255) AS "conditionMonthlylow"
//graph tradetime COLOURED(0,255,0) AS "tradetime"
//graph overnightfee COLOURED(0,0,0) AS "overnightfee"
//graph floatingprofit+capital COLOURED(0,0,0) AS "floatingprofit"
//graph BrokerProfit COLOURED(0,0,0) AS "BrokerProfit"
//graph countofdays COLOURED(255,255,255) AS "countofdays"
//graph OnMarketBarCount COLOURED(0,255,255) AS "OnMarketBarCount"
//graph CountOfTrades COLOURED(255,255,255) AS "CountOfTrades"
//graph comission COLOURED(255,0,255) AS "comission"
//graph AccumulatedTradeCost COLOURED(0,255,0) AS "AccumulatedTradeCost"
//graph tradeprice COLOURED(255,0,255) AS "tradeprice"
//graph TrueProfitInProcent COLOURED(255,0,255) AS "TrueProfitInProcent"
//graph BrokerProfit COLOURED(255,0,0) AS "BrokerProfit"
//graph BrokerProfitinProcent COLOURED(255,255,0) AS "BrokerProfitinProcent"
//graph marketchange COLOURED(255,0,0) AS "marketchange"
//=====================================================================================================================================
//=============================================================GRAPH SECTION END======================================================
//=====================================================================================================================================
//=================================EXIT and QUIT if market falls below 25% within a 365 days period
yearhigh =highest[365](high)
marketchange=((close/yearhigh)-1)*100
if onmarket and marketchange<-25 then
sell at market
elsif countofposition[1]>countofposition then
quit
endif
Here is a Buy and hold strategy on Vanguard Funds Public Limited Companey – Vanguard S&P 500 UCITS ETF
Remeber you and you only are entirely responsible for: what and how you invest your money, your risk, you gain, your losses. So do you homework an research before venturing into investing and trading. This is just an example on how it could have been if you invested 4,7 years ago, not guarantee for the future.
Cheers Kasper
//=====================================================================================================================================
//=============================================================GRAPH SECTION==========================================================
//=====================================================================================================================================
//========================================== rem out all lines from GRAPH SECTION to live trade the code=====================================
//once tradepricetest=1
//ONCE BrokerProfit=0
once countofdays=0
//once AccumulatedTradeCost=tradeprice*mypos
//Comission from IG- given: the commission charge is 0.10% of total tradeprice or $10, whichever is higher
//comissiontest=0.001*tradeprice*positionsize
//IF OnMarketBarCount[1]<OnMarketBarCount then
//AccumulatedTradeCost=AccumulatedTradeCost
//if tradepricetest then
//AccumulatedTradeCost=AccumulatedTradeCost+tradeprice*mypos
//tradepricetest=0
//endif
//if comissiontest<10 then
//comission=10
//endif
//elsif OnMarketBarCount[1]>OnMarketBarCount then
//tradepricetest=1
//comission=comissiontest
//endif
//Capital = 500 // initial capital of account
//
//equity = Capital + StrategyProfit
//overnight fee from IG- given: (5 x 35.6425 x (2.5% + 0.25%))/365. This would give a total of £.0.0134 per evening.
//interestrate=0.025//2.5%
//adminfee=0.0025//0.25%
//overnightfee = (countofposition*tradeprice*(interestrate+adminfee))/365*countofdays //0.8 //broker overnight fee of a position (in money)
// ---equity = Capital + StrategyProfit
//DayChart=1 //can be set to bar qu
//
if not onmarket then
countofdays=0
elsif onmarket and DayOfWeek[1]<DayOfWeek then// = DayChart then
countofdays=countofdays+1
else
countofdays=countofdays
endif
//floatingprofit = ((((close-positionprice)*pointvalue)*countofposition)/pipsize)-(overnightfee+comission)//+(overnightfee+comission) //actual trade gains
//Brokerprofit=((((close-positionprice)*pointvalue)*countofposition)/pipsize)-Floatingprofit
//BrokerProfitinProcent=(((floatingprofit-Brokerprofit)/floatingprofit)-1)*100
//TrueEquity=AccumulatedTradeCost+floatingprofit+capital
//TrueProfitInProcent=((TrueEquity/AccumulatedTradeCost)-1)*100
//graph conditionMonthlyHigh COLOURED(0,0,255) AS "conditionMonthlyHigh"
//graph ConditionWeekleyHigh COLOURED(0,255,0) AS "ConditionWeekleyHigh"
//graph TrueEquity COLOURED(0,0,255) AS "trueEquity"
//graph BrokerProfit COLOURED(255,0,0) AS "BrokerProfit"
//graph countofdays COLOURED(0,0,0) AS "countofdays"
graph entertrade COLOURED(255,255,0) AS "entertrade"
graph conditionWeeklyLow COLOURED(0,0,0) AS "conditionWeeklyLow"
graph conditionEMA COLOURED(255,0,0) AS "conditionEMA"
graph lastinperiod COLOURED(255,0,255) AS "lastinperiod"
graph conditionMonthlylow COLOURED(0,255,255) AS "conditionMonthlylow"
//graph tradetime COLOURED(0,255,0) AS "tradetime"
//graph overnightfee COLOURED(0,0,0) AS "overnightfee"
//graph floatingprofit+capital COLOURED(0,0,0) AS "floatingprofit"
//graph BrokerProfit COLOURED(0,0,0) AS "BrokerProfit"
//graph countofdays COLOURED(255,255,255) AS "countofdays"
//graph OnMarketBarCount COLOURED(0,255,255) AS "OnMarketBarCount"
//graph CountOfTrades COLOURED(255,255,255) AS "CountOfTrades"
//graph comission COLOURED(255,0,255) AS "comission"
//graph AccumulatedTradeCost+capital COLOURED(0,255,0) AS "AccumulatedTradeCost"
//graph tradeprice COLOURED(255,0,255) AS "tradeprice"
//graph TrueProfitInProcent COLOURED(255,0,255) AS "TrueProfitInProcent"
//graph BrokerProfit COLOURED(255,0,0) AS "BrokerProfit"
//graph BrokerProfitinProcent COLOURED(255,255,0) AS "BrokerProfitinProcent"
//graph marketchange COLOURED(255,0,0) AS "marketchange"
//=====================================================================================================================================
//=============================================================GRAPH SECTION END======================================================
//=====================================================================================================================================
It took a couple of tries and emails from IG’s part to finally come up with the formular for my chosen Instrument- the Vanguard Funds Public Limited Companey – Vanguard S&P 500 UCITS ETF. For a positionsize of 5 it would yield (5 x 35.6425 x (2.5% + 0.25%))/365. This would give a total of £.0.0134 per evening. I rewrote the formula to overnightfee=(positionsize x tradeprice x 0.0275)/365. Comission is a ballance. The commission pr trade, charge is 0.10% of total tradeprice or $10, whichever is higher- so the code takes care of this, but around 290 positions is the ballance. It also dependant on the current price. However more or less 600 position buy a month is rather costly. We could take trades 4 time a year, so comission becomes insignicant. But for large account that can afford these trades it’s left as 2 trades a month. We will see that the comission is almost not important anyway. I make a total of 10 x 2 positions a month which is 20 euro a month in commision. In the end it’s a matter of choice of how much you spend to make money vs. How much you can afford save each month
The Graph code for checking the overnight fee, comission, is
//=====================================================================================================================================
//=============================================================GRAPH SECTION==========================================================
//=====================================================================================================================================
//========================================== rem out all lines from GRAPH SECTION to live trade the code=====================================
//once tradepricetest=1
//ONCE BrokerProfit=0
once countofdays=0
once AccumulatedTradeCost=tradeprice*mypos
//Comission from IG- given: the commission charge is 0.10% of total tradeprice or $10, whichever is higher
comissiontest=0.001*tradeprice*positionsize
IF OnMarketBarCount[1]<OnMarketBarCount then
AccumulatedTradeCost=AccumulatedTradeCost
if tradepricetest then
AccumulatedTradeCost=AccumulatedTradeCost+tradeprice*mypos
tradepricetest=0
endif
if comissiontest<10 then
comission=10
endif
elsif OnMarketBarCount[1]>OnMarketBarCount then
tradepricetest=1
comission=comissiontest
endif
//Capital = 500 // initial capital of account
//
//equity = Capital + StrategyProfit
//overnight fee from IG- given: (5 x 35.6425 x (2.5% + 0.25%))/365. This would give a total of £.0.0134 per evening.
interestrate=0.025//2.5%
adminfee=0.0025//0.25%
overnightfee = (countofposition*tradeprice*(interestrate+adminfee))/365*countofdays //0.8 //broker overnight fee of a position (in money)
// ---equity = Capital + StrategyProfit
//DayChart=1 //can be set to bar qu
if not onmarket then
countofdays=0
elsif onmarket and DayOfWeek[1]<DayOfWeek then// = DayChart then
countofdays=countofdays+1
else
countofdays=countofdays
endif
//floatingprofit = ((((close-positionprice)*pointvalue)*countofposition)/pipsize)-(overnightfee+comission)//+(overnightfee+comission) //actual trade gains
//Brokerprofit=((((close-positionprice)*pointvalue)*countofposition)/pipsize)-Floatingprofit
//BrokerProfitinProcent=(((floatingprofit-Brokerprofit)/floatingprofit)-1)*100
//TrueEquity=AccumulatedTradeCost+floatingprofit+capital
//TrueProfitInProcent=((TrueEquity/AccumulatedTradeCost)-1)*100
//graph conditionMonthlyHigh COLOURED(0,0,255) AS "conditionMonthlyHigh"
//graph ConditionWeekleyHigh COLOURED(0,255,0) AS "ConditionWeekleyHigh"
//graph TrueEquity COLOURED(0,0,255) AS "trueEquity"
//graph BrokerProfit COLOURED(255,0,0) AS "BrokerProfit"
//graph countofdays COLOURED(0,0,0) AS "countofdays"
//graph entertrade COLOURED(255,255,0) AS "entertrade"
//graph conditionWeeklyLow COLOURED(0,0,0) AS "conditionWeeklyLow"
//graph conditionEMA COLOURED(255,0,0) AS "conditionEMA"
//graph lastinperiod COLOURED(255,0,255) AS "lastinperiod"
//graph conditionMonthlylow COLOURED(0,255,255) AS "conditionMonthlylow"
//graph tradetime COLOURED(0,255,0) AS "tradetime"
graph overnightfee COLOURED(0,0,0) AS "overnightfee"
//graph floatingprofit+capital COLOURED(0,0,0) AS "floatingprofit"
//graph BrokerProfit COLOURED(0,0,0) AS "BrokerProfit"
//graph countofdays COLOURED(255,255,255) AS "countofdays"
//graph OnMarketBarCount COLOURED(0,255,255) AS "OnMarketBarCount"
//graph CountOfTrades COLOURED(255,255,255) AS "CountOfTrades"
graph comission COLOURED(255,0,255) AS "comission"
//graph AccumulatedTradeCost+capital COLOURED(0,255,0) AS "AccumulatedTradeCost"
//graph tradeprice COLOURED(255,0,255) AS "tradeprice"
//graph TrueProfitInProcent COLOURED(255,0,255) AS "TrueProfitInProcent"
//graph BrokerProfit COLOURED(255,0,0) AS "BrokerProfit"
//graph BrokerProfitinProcent COLOURED(255,255,0) AS "BrokerProfitinProcent"
//graph marketchange COLOURED(255,0,0) AS "marketchange"
//=====================================================================================================================================
//=============================================================GRAPH SECTION END======================================================
//=====================================================================================================================================
//=====================================================================================================================================
//=============================================================GRAPH SECTION==========================================================
//=====================================================================================================================================
//========================================== rem out all lines from GRAPH SECTION to live trade the code=====================================
//once tradepricetest=1
//ONCE BrokerProfit=0
once countofdays=0
once AccumulatedTradeCost=tradeprice*mypos
//Comission from IG- given: the commission charge is 0.10% of total tradeprice or $10, whichever is higher
comissiontest=0.001*tradeprice*positionsize
IF OnMarketBarCount[1]<OnMarketBarCount then
AccumulatedTradeCost=AccumulatedTradeCost
if tradepricetest then
AccumulatedTradeCost=AccumulatedTradeCost+tradeprice*mypos
tradepricetest=0
endif
if comissiontest<10 then
comission=10
endif
elsif OnMarketBarCount[1]>OnMarketBarCount then
tradepricetest=1
comission=comissiontest
endif
Capital = 500 // initial capital of account
//
//equity = Capital + StrategyProfit
//overnight fee from IG- given: (5 x 35.6425 x (2.5% + 0.25%))/365. This would give a total of £.0.0134 per evening.
interestrate=0.025//2.5%
adminfee=0.0025//0.25%
overnightfee = (countofposition*tradeprice*(interestrate+adminfee))/365*countofdays //0.8 //broker overnight fee of a position (in money)
// ---equity = Capital + StrategyProfit
//DayChart=1 //can be set to bar qu
//
if not onmarket then
countofdays=0
elsif onmarket and DayOfWeek[1]<DayOfWeek then// = DayChart then
countofdays=countofdays+1
else
countofdays=countofdays
endif
floatingprofit = ((((close-positionprice)*pointvalue)*countofposition)/pipsize)-(overnightfee+comission)//+(overnightfee+comission) //actual trade gains
//Brokerprofit=((((close-positionprice)*pointvalue)*countofposition)/pipsize)-Floatingprofit
//BrokerProfitinProcent=(((floatingprofit-Brokerprofit)/floatingprofit)-1)*100
TrueEquity=AccumulatedTradeCost+floatingprofit+capital
//TrueProfitInProcent=((TrueEquity/AccumulatedTradeCost)-1)*100
//graph conditionMonthlyHigh COLOURED(0,0,255) AS "conditionMonthlyHigh"
//graph ConditionWeekleyHigh COLOURED(0,255,0) AS "ConditionWeekleyHigh"
graph TrueEquity COLOURED(0,0,255) AS "trueEquity"
//graph BrokerProfit COLOURED(255,0,0) AS "BrokerProfit"
//graph countofdays COLOURED(0,0,0) AS "countofdays"
//graph entertrade COLOURED(255,255,0) AS "entertrade"
//graph conditionWeeklyLow COLOURED(0,0,0) AS "conditionWeeklyLow"
//graph conditionEMA COLOURED(255,0,0) AS "conditionEMA"
//graph lastinperiod COLOURED(255,0,255) AS "lastinperiod"
//graph conditionMonthlylow COLOURED(0,255,255) AS "conditionMonthlylow"
//graph tradetime COLOURED(0,255,0) AS "tradetime"
//graph overnightfee COLOURED(0,0,0) AS "overnightfee"
graph floatingprofit+capital COLOURED(0,0,0) AS "floatingprofit"
//graph BrokerProfit COLOURED(0,0,0) AS "BrokerProfit"
//graph countofdays COLOURED(255,255,255) AS "countofdays"
//graph OnMarketBarCount COLOURED(0,255,255) AS "OnMarketBarCount"
//graph CountOfTrades COLOURED(255,255,255) AS "CountOfTrades"
//graph comission COLOURED(255,0,255) AS "comission"
graph AccumulatedTradeCost+capital COLOURED(0,255,0) AS "AccumulatedTradeCost"
//graph tradeprice COLOURED(255,0,255) AS "tradeprice"
//graph TrueProfitInProcent COLOURED(255,0,255) AS "TrueProfitInProcent"
//graph BrokerProfit COLOURED(255,0,0) AS "BrokerProfit"
//graph BrokerProfitinProcent COLOURED(255,255,0) AS "BrokerProfitinProcent"
//graph marketchange COLOURED(255,0,0) AS "marketchange"
//=====================================================================================================================================
//=============================================================GRAPH SECTION END======================================================
//=====================================================================================================================================
//=====================================================================================================================================
//=============================================================GRAPH SECTION==========================================================
//=====================================================================================================================================
//========================================== rem out all lines from GRAPH SECTION to live trade the code=====================================
//once tradepricetest=1
//ONCE BrokerProfit=0
once countofdays=0
once AccumulatedTradeCost=tradeprice*mypos
//Comission from IG- given: the commission charge is 0.10% of total tradeprice or $10, whichever is higher
comissiontest=0.001*tradeprice*positionsize
IF OnMarketBarCount[1]<OnMarketBarCount then
AccumulatedTradeCost=AccumulatedTradeCost
if tradepricetest then
AccumulatedTradeCost=AccumulatedTradeCost+tradeprice*mypos
tradepricetest=0
endif
if comissiontest<10 then
comission=10
endif
elsif OnMarketBarCount[1]>OnMarketBarCount then
tradepricetest=1
comission=comissiontest
endif
Capital = 500 // initial capital of account
//
//equity = Capital + StrategyProfit
//overnight fee from IG- given: (5 x 35.6425 x (2.5% + 0.25%))/365. This would give a total of £.0.0134 per evening.
interestrate=0.025//2.5%
adminfee=0.0025//0.25%
overnightfee = (countofposition*tradeprice*(interestrate+adminfee))/365*countofdays //0.8 //broker overnight fee of a position (in money)
// ---equity = Capital + StrategyProfit
//DayChart=1 //can be set to bar qu
//
if not onmarket then
countofdays=0
elsif onmarket and DayOfWeek[1]<DayOfWeek then// = DayChart then
countofdays=countofdays+1
else
countofdays=countofdays
endif
floatingprofit = ((((close-positionprice)*pointvalue)*countofposition)/pipsize)-(overnightfee+comission)//+(overnightfee+comission) //actual trade gains
//Brokerprofit=((((close-positionprice)*pointvalue)*countofposition)/pipsize)-Floatingprofit
//BrokerProfitinProcent=(((floatingprofit-Brokerprofit)/floatingprofit)-1)*100
TrueEquity=AccumulatedTradeCost+floatingprofit+capital
TrueProfitInProcent=((TrueEquity/AccumulatedTradeCost)-1)*100
//graph conditionMonthlyHigh COLOURED(0,0,255) AS "conditionMonthlyHigh"
//graph ConditionWeekleyHigh COLOURED(0,255,0) AS "ConditionWeekleyHigh"
//graph TrueEquity COLOURED(0,0,255) AS "trueEquity"
//graph BrokerProfit COLOURED(255,0,0) AS "BrokerProfit"
//graph countofdays COLOURED(0,0,0) AS "countofdays"
//graph entertrade COLOURED(255,255,0) AS "entertrade"
//graph conditionWeeklyLow COLOURED(0,0,0) AS "conditionWeeklyLow"
//graph conditionEMA COLOURED(255,0,0) AS "conditionEMA"
//graph lastinperiod COLOURED(255,0,255) AS "lastinperiod"
//graph conditionMonthlylow COLOURED(0,255,255) AS "conditionMonthlylow"
//graph tradetime COLOURED(0,255,0) AS "tradetime"
//graph overnightfee COLOURED(0,0,0) AS "overnightfee"
//graph floatingprofit+capital COLOURED(0,0,0) AS "floatingprofit"
//graph BrokerProfit COLOURED(0,0,0) AS "BrokerProfit"
//graph countofdays COLOURED(255,255,255) AS "countofdays"
//graph OnMarketBarCount COLOURED(0,255,255) AS "OnMarketBarCount"
//graph CountOfTrades COLOURED(255,255,255) AS "CountOfTrades"
//graph comission COLOURED(255,0,255) AS "comission"
//graph AccumulatedTradeCost+capital COLOURED(0,255,0) AS "AccumulatedTradeCost"
//graph tradeprice COLOURED(255,0,255) AS "tradeprice"
graph TrueProfitInProcent COLOURED(255,0,255) AS "TrueProfitInProcent"
//graph BrokerProfit COLOURED(255,0,0) AS "BrokerProfit"
//graph BrokerProfitinProcent COLOURED(255,255,0) AS "BrokerProfitinProcent"
//graph marketchange COLOURED(255,0,0) AS "marketchange"
//=====================================================================================================================================
//=============================================================GRAPH SECTION END======================================================
//=====================================================================================================================================
//=====================================================================================================================================
//=============================================================GRAPH SECTION==========================================================
//=====================================================================================================================================
//========================================== rem out all lines from GRAPH SECTION to live trade the code=====================================
//once tradepricetest=1
//ONCE BrokerProfit=0
//once countofdays=0
//once AccumulatedTradeCost=tradeprice*mypos
//Comission from IG- given: the commission charge is 0.10% of total tradeprice or $10, whichever is higher
//comissiontest=0.001*tradeprice*positionsize
//IF OnMarketBarCount[1]<OnMarketBarCount then
//AccumulatedTradeCost=AccumulatedTradeCost
//if tradepricetest then
//AccumulatedTradeCost=AccumulatedTradeCost+tradeprice*mypos
//tradepricetest=0
//endif
//if comissiontest<10 then
//comission=10
//endif
//elsif OnMarketBarCount[1]>OnMarketBarCount then
//tradepricetest=1
//comission=comissiontest
//endif
//Capital = 500 // initial capital of account
//
//equity = Capital + StrategyProfit
//overnight fee from IG- given: (5 x 35.6425 x (2.5% + 0.25%))/365. This would give a total of £.0.0134 per evening.
//interestrate=0.025//2.5%
//adminfee=0.0025//0.25%
//overnightfee = (countofposition*tradeprice*(interestrate+adminfee))/365*countofdays //0.8 //broker overnight fee of a position (in money)
// ---equity = Capital + StrategyProfit
//DayChart=1 //can be set to bar qu
//
//if not onmarket then
//countofdays=0
//elsif onmarket and DayOfWeek[1]<DayOfWeek then// = DayChart then
//countofdays=countofdays+1
//else
//countofdays=countofdays
//endif
//floatingprofit = ((((close-positionprice)*pointvalue)*countofposition)/pipsize)-(overnightfee+comission)//+(overnightfee+comission) //actual trade gains
//Brokerprofit=((((close-positionprice)*pointvalue)*countofposition)/pipsize)-Floatingprofit
//BrokerProfitinProcent=(((floatingprofit-Brokerprofit)/floatingprofit)-1)*100
//TrueEquity=AccumulatedTradeCost+floatingprofit+capital
//TrueProfitInProcent=((TrueEquity/AccumulatedTradeCost)-1)*100
//graph conditionMonthlyHigh COLOURED(0,0,255) AS "conditionMonthlyHigh"
//graph ConditionWeekleyHigh COLOURED(0,255,0) AS "ConditionWeekleyHigh"
//graph TrueEquity COLOURED(0,0,255) AS "trueEquity"
//graph BrokerProfit COLOURED(255,0,0) AS "BrokerProfit"
//graph countofdays COLOURED(0,0,0) AS "countofdays"
//graph entertrade COLOURED(255,255,0) AS "entertrade"
//graph conditionWeeklyLow COLOURED(0,0,0) AS "conditionWeeklyLow"
//graph conditionEMA COLOURED(255,0,0) AS "conditionEMA"
//graph lastinperiod COLOURED(255,0,255) AS "lastinperiod"
//graph conditionMonthlylow COLOURED(0,255,255) AS "conditionMonthlylow"
//graph tradetime COLOURED(0,255,0) AS "tradetime"
//graph overnightfee COLOURED(0,0,0) AS "overnightfee"
//graph floatingprofit+capital COLOURED(0,0,0) AS "floatingprofit"
//graph BrokerProfit COLOURED(0,0,0) AS "BrokerProfit"
//graph countofdays COLOURED(255,255,255) AS "countofdays"
//graph OnMarketBarCount COLOURED(0,255,255) AS "OnMarketBarCount"
//graph CountOfTrades COLOURED(255,255,255) AS "CountOfTrades"
//graph comission COLOURED(255,0,255) AS "comission"
//graph AccumulatedTradeCost+capital COLOURED(0,255,0) AS "AccumulatedTradeCost"
//graph tradeprice COLOURED(255,0,255) AS "tradeprice"
//graph TrueProfitInProcent COLOURED(255,0,255) AS "TrueProfitInProcent"
//graph BrokerProfit COLOURED(255,0,0) AS "BrokerProfit"
//graph BrokerProfitinProcent COLOURED(255,255,0) AS "BrokerProfitinProcent"
graph marketchange COLOURED(255,0,0) AS "marketchange"
//=====================================================================================================================================
//=============================================================GRAPH SECTION END======================================================
//=====================================================================================================================================
//=====================================================================================================================================
//=============================================================GRAPH SECTION==========================================================
//=====================================================================================================================================
//========================================== rem out all lines from GRAPH SECTION to live trade the code=====================================
//once tradepricetest=1
ONCE BrokerProfit=0
once countofdays=0
once AccumulatedTradeCost=tradeprice*mypos
//Comission from IG- given: the commission charge is 0.10% of total tradeprice or $10, whichever is higher
comissiontest=0.001*tradeprice*positionsize
IF OnMarketBarCount[1]<OnMarketBarCount then
AccumulatedTradeCost=AccumulatedTradeCost
if tradepricetest then
AccumulatedTradeCost=AccumulatedTradeCost+tradeprice*mypos
tradepricetest=0
endif
if comissiontest<10 then
comission=10
endif
elsif OnMarketBarCount[1]>OnMarketBarCount then
tradepricetest=1
comission=comissiontest
endif
Capital = 500 // initial capital of account
//
//equity = Capital + StrategyProfit
//overnight fee from IG- given: (5 x 35.6425 x (2.5% + 0.25%))/365. This would give a total of £.0.0134 per evening.
interestrate=0.025//2.5%
adminfee=0.0025//0.25%
overnightfee = (countofposition*tradeprice*(interestrate+adminfee))/365*countofdays //0.8 //broker overnight fee of a position (in money)
// ---equity = Capital + StrategyProfit
//DayChart=1 //can be set to bar qu
//
if not onmarket then
countofdays=0
elsif onmarket and DayOfWeek[1]<DayOfWeek then// = DayChart then
countofdays=countofdays+1
else
countofdays=countofdays
endif
floatingprofit = ((((close-positionprice)*pointvalue)*countofposition)/pipsize)-(overnightfee+comission)//+(overnightfee+comission) //actual trade gains
Brokerprofit=((((close-positionprice)*pointvalue)*countofposition)/pipsize)-Floatingprofit
BrokerProfitinProcent=(((floatingprofit-Brokerprofit)/floatingprofit)-1)*100
TrueEquity=AccumulatedTradeCost+floatingprofit+capital
TrueProfitInProcent=((TrueEquity/AccumulatedTradeCost)-1)*100
//graph conditionMonthlyHigh COLOURED(0,0,255) AS "conditionMonthlyHigh"
//graph ConditionWeekleyHigh COLOURED(0,255,0) AS "ConditionWeekleyHigh"
graph TrueEquity COLOURED(0,0,255) AS "trueEquity"
//graph BrokerProfit COLOURED(255,0,0) AS "BrokerProfit"
//graph countofdays COLOURED(0,0,0) AS "countofdays"
//graph entertrade COLOURED(255,255,0) AS "entertrade"
//graph conditionWeeklyLow COLOURED(0,0,0) AS "conditionWeeklyLow"
//graph conditionEMA COLOURED(255,0,0) AS "conditionEMA"
//graph lastinperiod COLOURED(255,0,255) AS "lastinperiod"
//graph conditionMonthlylow COLOURED(0,255,255) AS "conditionMonthlylow"
//graph tradetime COLOURED(0,255,0) AS "tradetime"
//graph overnightfee COLOURED(0,0,0) AS "overnightfee"
graph floatingprofit+capital COLOURED(0,0,0) AS "floatingprofit"
//graph BrokerProfit COLOURED(0,0,0) AS "BrokerProfit"
//graph countofdays COLOURED(255,255,255) AS "countofdays"
//graph OnMarketBarCount COLOURED(0,255,255) AS "OnMarketBarCount"
//graph CountOfTrades COLOURED(255,255,255) AS "CountOfTrades"
//graph comission COLOURED(255,0,255) AS "comission"
//graph AccumulatedTradeCost+capital COLOURED(0,255,0) AS "AccumulatedTradeCost"
//graph tradeprice COLOURED(255,0,255) AS "tradeprice"
graph TrueProfitInProcent COLOURED(255,0,255) AS "TrueProfitInProcent"
graph BrokerProfit COLOURED(255,0,0) AS "BrokerProfit"
graph BrokerProfitinProcent COLOURED(255,255,0) AS "BrokerProfitinProcent"
//graph marketchange COLOURED(255,0,0) AS "marketchange"
//=====================================================================================================================================
//=============================================================GRAPH SECTION END======================================================
//=====================================================================================================================================
//=====================================================================================================================================
//=============================================================GRAPH SECTION==========================================================
//=====================================================================================================================================
//========================================== rem out all lines from GRAPH SECTION to live trade the code=====================================
//once tradepricetest=1
ONCE BrokerProfit=0
once countofdays=0
once AccumulatedTradeCost=tradeprice*mypos
//Comission from IG- given: the commission charge is 0.10% of total tradeprice or $10, whichever is higher
comissiontest=0.001*tradeprice*positionsize
IF OnMarketBarCount[1]<OnMarketBarCount then
AccumulatedTradeCost=AccumulatedTradeCost
if tradepricetest then
AccumulatedTradeCost=AccumulatedTradeCost+tradeprice*mypos
tradepricetest=0
endif
if comissiontest<10 then
comission=10*countoftrades
endif
elsif OnMarketBarCount[1]>OnMarketBarCount then
tradepricetest=1
comission=comissiontest*countoftrades
endif
Capital = 500 // initial capital of account
//
//equity = Capital + StrategyProfit
//overnight fee from IG- given: (5 x 35.6425 x (2.5% + 0.25%))/365. This would give a total of £.0.0134 per evening.
interestrate=0.025//2.5%
adminfee=0.0025//0.25%
overnightfee = (countofposition*tradeprice*(interestrate+adminfee))/365*countofdays //0.8 //broker overnight fee of a position (in money)
// ---equity = Capital + StrategyProfit
//DayChart=1 //can be set to bar qu
//
if not onmarket then
countofdays=0
elsif onmarket and DayOfWeek[1]<DayOfWeek then// = DayChart then
countofdays=countofdays+1
else
countofdays=countofdays
endif
floatingprofit = ((((close-positionprice)*pointvalue)*countofposition)/pipsize)-(overnightfee+comission)//+(overnightfee+comission) //actual trade gains
Brokerprofit=((((close-positionprice)*pointvalue)*countofposition)/pipsize)-Floatingprofit
BrokerProfitinProcent=(((floatingprofit-Brokerprofit)/floatingprofit)-1)*100
TrueEquity=AccumulatedTradeCost+floatingprofit+capital
TrueProfitInProcent=((TrueEquity/AccumulatedTradeCost)-1)*100
//graph conditionMonthlyHigh COLOURED(0,0,255) AS "conditionMonthlyHigh"
//graph ConditionWeekleyHigh COLOURED(0,255,0) AS "ConditionWeekleyHigh"
graph TrueEquity COLOURED(0,0,255) AS "trueEquity"
//graph BrokerProfit COLOURED(255,0,0) AS "BrokerProfit"
//graph countofdays COLOURED(0,0,0) AS "countofdays"
//graph entertrade COLOURED(255,255,0) AS "entertrade"
//graph conditionWeeklyLow COLOURED(0,0,0) AS "conditionWeeklyLow"
//graph conditionEMA COLOURED(255,0,0) AS "conditionEMA"
//graph lastinperiod COLOURED(255,0,255) AS "lastinperiod"
//graph conditionMonthlylow COLOURED(0,255,255) AS "conditionMonthlylow"
//graph tradetime COLOURED(0,255,0) AS "tradetime"
//graph overnightfee COLOURED(0,0,0) AS "overnightfee"
graph floatingprofit+capital COLOURED(0,0,0) AS "floatingprofit"
//graph BrokerProfit COLOURED(0,0,0) AS "BrokerProfit"
//graph countofdays COLOURED(255,255,255) AS "countofdays"
//graph OnMarketBarCount COLOURED(0,255,255) AS "OnMarketBarCount"
//graph CountOfTrades COLOURED(255,255,255) AS "CountOfTrades"
//graph comission COLOURED(255,0,255) AS "comission"
//graph AccumulatedTradeCost+capital COLOURED(0,255,0) AS "AccumulatedTradeCost"
//graph tradeprice COLOURED(255,0,255) AS "tradeprice"
graph TrueProfitInProcent COLOURED(255,0,255) AS "TrueProfitInProcent"
graph BrokerProfit COLOURED(255,0,0) AS "BrokerProfit"
graph BrokerProfitinProcent COLOURED(255,255,0) AS "BrokerProfitinProcent"
//graph marketchange COLOURED(255,0,0) AS "marketchange"
//=====================================================================================================================================
//=============================================================GRAPH SECTION END======================================================
VUSA daily Buy and hold v2.0
This topic contains 19 replies,
has 6 voices, and was last updated by Elsborgtrading
8 years, 8 months ago.
| Forum: | ProOrder: Automated Strategies & Backtesting |
| Language: | English |
| Started: | 04/14/2017 |
| Status: | Active |
| Attachments: | 9 files |
The information collected on this form is stored in a computer file by ProRealCode to create and access your ProRealCode profile. This data is kept in a secure database for the duration of the member's membership. They will be kept as long as you use our services and will be automatically deleted after 3 years of inactivity. Your personal data is used to create your private profile on ProRealCode. This data is maintained by SAS ProRealCode, 407 rue Freycinet, 59151 Arleux, France. If you subscribe to our newsletters, your email address is provided to our service provider "MailChimp" located in the United States, with whom we have signed a confidentiality agreement. This company is also compliant with the EU/Swiss Privacy Shield, and the GDPR. For any request for correction or deletion concerning your data, you can directly contact the ProRealCode team by email at privacy@prorealcode.com If you would like to lodge a complaint regarding the use of your personal data, you can contact your data protection supervisory authority.