MeganRatio.efs
File Name: MeganRatio.efs
Description:
Megan Ratio
Formula Parameters:
MeganRatio.efs
- MaxTradesPerYear: 8
- Trades: 3
- StartCapital: 100000
- NetProfit: 1000
Cagigas_System1.efs
- Entry (Highest Period): 20
- Exit (Lowest Period): 10
- Start Capital: 100000
- Max Trades Per Year: 8
Cagigas_System2.efs
- SMA1: 20
- SMA2: 5
- Exit (Lowest Period): 2
- Start Capital: 100000
- Max Trades Per Year: 8
Notes:
The related article is copyrighted material. If you are not a subscriber of Stocks & Commodities, please visit www.traders.com.
Download File:
MeganRatio.efs
Cagigas_System1.efs
Cagigas_System2.efs
EFS Code:
/********************************* Provided By: eSignal (Copyright c eSignal), a division of Interactive Data Corporation. 2008. All rights reserved. This sample eSignal Formula Script (EFS) is for educational purposes only and may be modified and saved under a new file name. eSignal is not responsible for the functionality once modified. eSignal reserves the right to modify and overwrite this EFS file with each new release. Description: Megan Ratio Version: 1.0 11/07/2008 Formula Parameters: Default: MaxTradesPerYear 8 Trades 3 StartCapital 100000 NetProfit 1000 Notes: The related article is copyrighted material. If you are not a subscriber of Stocks & Commodities, please visit www.traders.com. **********************************/ var fpArray = new Array(); var bVersion = null; function preMain() { setPriceStudy(true); setShowCursorLabel(false); setShowTitleParameters( false ); setStudyTitle("Megan Ratio"); var x=0; fpArray[x] = new FunctionParameter("StartCapital", FunctionParameter.NUMBER); with(fpArray[x++]){ setName("Start Capital"); setLowerLimit(0); setDefault(100000); } fpArray[x] = new FunctionParameter("NetProfit", FunctionParameter.NUMBER); with(fpArray[x++]){ setName("NetProfit"); setDefault(1000); } fpArray[x] = new FunctionParameter("MaxTradesPerYear", FunctionParameter.NUMBER); with(fpArray[x++]){ setName("Max Trades Per Year"); setLowerLimit(1); setDefault(8); } fpArray[x] = new FunctionParameter("Trades", FunctionParameter.NUMBER); with(fpArray[x++]){ setName("Total Trades"); setLowerLimit(1); setDefault(3); } } function main(MaxTradesPerYear, Trades, StartCapital, NetProfit) { var nMeganRatio = 0; var nTWR = 0; var ngeom = 0; if (bVersion == null) bVersion = verify(); if (bVersion == false) return; nTWR = (StartCapital + NetProfit) / StartCapital; ngeom = Math.pow(nTWR, 1 / Trades); nMeganRatio = MaxTradesPerYear * Math.log(ngeom); drawTextRelative( 2, TopRow3, "Megan Ratio = "+nMeganRatio.toFixed(6), Color.black, null, Text.PRESET,"Arial",12, "MeganRatio"); return; } function verify() { var b = false; if (getBuildNumber() < 779) { drawTextAbsolute(5, 35, "This study requires version 8.0 or later.", Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT, null, 13, "error"); drawTextAbsolute(5, 20, "Click HERE to upgrade.@URL=http://www.esignal.com/download/default.asp", Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT, null, 13, "upgrade"); return b; } else { b = true; } return b; }
/********************************* Provided By: eSignal (Copyright c eSignal), a division of Interactive Data Corporation. 2008. All rights reserved. This sample eSignal Formula Script (EFS) is for educational purposes only and may be modified and saved under a new file name. eSignal is not responsible for the functionality once modified. eSignal reserves the right to modify and overwrite this EFS file with each new release. Description: Cagigas System1 Version: 1.0 11/07/2008 Formula Parameters: Default: Entry (Highest Period) 20 Exit (Lowest Period) 10 Start Capital 100000 Max Trades Per Year 8 Notes: System 1 is a breakout system of using 20 and 10 periods. The related article is copyrighted material. If you are not a subscriber of Stocks & Commodities, please visit www.traders.com. **********************************/ var fpArray = new Array(); var bInit = false; var bVersion = null; function preMain() { setPriceStudy(true); setShowTitleParameters( false ); setStudyTitle("Cagigas System1"); setColorPriceBars(true); setDefaultPriceBarColor(Color.grey); setCursorLabelName("HH", 0); setCursorLabelName("LL", 1); setDefaultBarFgColor(Color.green, 0); setDefaultBarFgColor(Color.red, 1); setDefaultBarThickness(2, 0); setDefaultBarThickness(2, 1); var x=0; fpArray[x] = new FunctionParameter("Entry", FunctionParameter.NUMBER); with(fpArray[x++]){ setName("Entry (Highest Period)"); setLowerLimit(1); setDefault(20); } fpArray[x] = new FunctionParameter("Exit", FunctionParameter.NUMBER); with(fpArray[x++]){ setName("Exit (Lowest Period)"); setLowerLimit(1); setDefault(10); } fpArray[x] = new FunctionParameter("StartCapital", FunctionParameter.NUMBER); with(fpArray[x++]){ setName("Start Capital"); setLowerLimit(0); setDefault(100000); } fpArray[x] = new FunctionParameter("MaxTradesPerYear", FunctionParameter.NUMBER); with(fpArray[x++]){ setName("Max Trades Per Year"); setDefault(8); } } var xEntry = null; var xExit = null; var nPriceL = 0; var nPriceS = 0; var nTradeCounter = 0; var NetProfit = 0; var NetProfit_1 = 0 function main(Entry, Exit, MaxTradesPerYear, StartCapital) { if (bVersion == null) bVersion = verify(); if (bVersion == false) return; if (getCurrentBarIndex() == 0) return; if ( bInit == false ) { xEntry = upperDonchian(Entry); xExit = lowerDonchian(Exit); NetProfit_1 = StartCapital; bInit = true; } if(getBarState()==BARSTATE_NEWBAR) NetProfit_1 = NetProfit if (!Strategy.isLong()) { if (high(0) > xEntry.getValue(-1)) { nPriceL = Math.max(high(-1), open(0)); Strategy.doLong("Entry", Strategy.LIMIT, Strategy.THISBAR,Strategy.DEFAULT, nPriceL); } } if (Strategy.isLong()) { setPriceBarColor(Color.blue); if (low(0) < xExit.getValue(-1)) { nPriceS = Math.min(xExit.getValue(-1),open(0)); if(Strategy.isLong()) NetProfit = NetProfit_1+((nPriceS-nPriceL)* Strategy.getDefaultLotSize()); nTradeCounter ++; Strategy.doSell("Exit", Strategy.LIMIT, Strategy.THISBAR,Strategy.DEFAULT, nPriceS); var cTradeColor = Color.green; if ((nPriceS-nPriceL) < 0) cTradeColor = Color.maroon; drawTextRelative(0,BottomRow1,(nPriceS-nPriceL).toFixed(2),cTradeColor,null,Text.PRESET|Text.FRAME|Text.BOLD,"Arial",10,"TradeProfit"+rawtime(0)); } } drawTextRelative(4,BottomRow3,"Net Profit/Loss "+NetProfit.toFixed(2),Color.black,null,Text.PRESET,"Arial",12,"NetProfit"); drawTextRelative(4,BottomRow2,"Total Trades "+nTradeCounter,Color.black,null,Text.PRESET,"Arial",12,"nTradeCounter"); var nMeganRatio = 0; var nTWR = 0; var ngeom = 0; var Trades = nTradeCounter; nTWR = (StartCapital + NetProfit) / StartCapital; ngeom = Math.pow(nTWR, 1 / Trades); nMeganRatio = MaxTradesPerYear * Math.log(ngeom); drawTextRelative( 4, BottomRow1, "Megan Ratio = "+nMeganRatio.toFixed(6) , Color.black, null, Text.PRESET,"Arial",12, "MeganRatio"); return new Array(xEntry.getValue(0), xExit.getValue(0)); } function verify() { var b = false; if (getBuildNumber() < 779) { drawTextAbsolute(5, 35, "This study requires version 8.0 or later.", Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT, null, 13, "error"); drawTextAbsolute(5, 20, "Click HERE to upgrade.@URL=http://www.esignal.com/download/default.asp", Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT, null, 13, "upgrade"); return b; } else { b = true; } return b; }
/********************************* Provided By: eSignal (Copyright c eSignal), a division of Interactive Data Corporation. 2008. All rights reserved. This sample eSignal Formula Script (EFS) is for educational purposes only and may be modified and saved under a new file name. eSignal is not responsible for the functionality once modified. eSignal reserves the right to modify and overwrite this EFS file with each new release. Description: Cagigas System2 Version: 1.0 11/07/2008 Formula Parameters: Default: SMA1 20 SMA2 5 Exit (Lowest Period) 2 Start Capital 100000 Max Trades Per Year 8 Notes: System 2 is a moving average system that takes long trades after the crossover if the previous high is exceeded. We sell only if the low of two previous bars is broken. The related article is copyrighted material. If you are not a subscriber of Stocks & Commodities, please visit www.traders.com. **********************************/ var fpArray = new Array(); var bInit = false; var bVersion = null; function preMain() { setPriceStudy(true); setShowTitleParameters( false ); setStudyTitle("Cagigas System2"); setColorPriceBars(true); setDefaultPriceBarColor(Color.grey); setCursorLabelName("SMA1", 0); setCursorLabelName("SMA2", 1); setDefaultBarFgColor(Color.blue, 0); setDefaultBarFgColor(Color.fushcia, 1); setDefaultBarThickness(2, 0); setDefaultBarThickness(2, 1); var x=0; fpArray[x] = new FunctionParameter("SMA20", FunctionParameter.NUMBER); with(fpArray[x++]){ setName("SMA1"); setLowerLimit(1); setDefault(20); } fpArray[x] = new FunctionParameter("SMA5", FunctionParameter.NUMBER); with(fpArray[x++]){ setName("SMA2"); setLowerLimit(1); setDefault(5); } fpArray[x] = new FunctionParameter("Exit", FunctionParameter.NUMBER); with(fpArray[x++]){ setName("Exit (Lowest Period)"); setLowerLimit(1); setDefault(2); } fpArray[x] = new FunctionParameter("StartCapital", FunctionParameter.NUMBER); with(fpArray[x++]){ setName("Start Capital"); setLowerLimit(0); setDefault(100000); } fpArray[x] = new FunctionParameter("MaxTradesPerYear", FunctionParameter.NUMBER); with(fpArray[x++]){ setName("Max Trades Per Year"); setDefault(8); } } var xSMA20 = null; var xSMA5 = null; var xExit = null; var nPriceL = 0; var nPriceS = 0; var nTradeCounter = 0; var NetProfit = 0; var NetProfit_1 = 0 function main(SMA20, SMA5, Exit, MaxTradesPerYear, StartCapital) { if (bVersion == null) bVersion = verify(); if (bVersion == false) return; if (getCurrentBarIndex() == 0) return; if ( bInit == false ) { xSMA20 = sma(SMA20); xSMA5 = sma(SMA5); xExit = lowerDonchian(Exit); NetProfit_1 = StartCapital; bInit = true; } if(getBarState()==BARSTATE_NEWBAR) NetProfit_1 = NetProfit if (!Strategy.isLong()) { if (xSMA5.getValue(-1) > xSMA20.getValue(-1) && high(0) > high(-1)) { nPriceL = Math.max(high(-1), open(0)); Strategy.doLong("Entry", Strategy.LIMIT, Strategy.THISBAR,Strategy.DEFAULT, nPriceL); } } if (Strategy.isLong()) { setPriceBarColor(Color.blue); if (low(0) < xExit.getValue(-1)) { nPriceS = Math.min(xExit.getValue(-1),open(0)); if(Strategy.isLong()) NetProfit = NetProfit_1+((nPriceS-nPriceL)*Strategy.getDefaultLotSize()); nTradeCounter ++; Strategy.doSell("Exit", Strategy.LIMIT, Strategy.THISBAR,Strategy.DEFAULT, nPriceS); var cTradeColor = Color.green; if ((nPriceS-nPriceL) < 0) cTradeColor = Color.maroon; drawTextRelative(0,BottomRow1,(nPriceS-nPriceL).toFixed(2),cTradeColor,null,Text.PRESET|Text.FRAME|Text.BOLD,"Arial",10,"TradeProfit"+rawtime(0)); } } drawTextRelative(4,BottomRow3,"Net Profit/Loss "+NetProfit.toFixed(2),Color.black,null,Text.PRESET,"Arial",12,"NetProfit"); drawTextRelative(4,BottomRow2,"Total Trades "+nTradeCounter,Color.black,null,Text.PRESET,"Arial",12,"nTradeCounter"); var nMeganRatio = 0; var nTWR = 0; var ngeom = 0; var Trades = nTradeCounter; nTWR = (StartCapital + NetProfit) / StartCapital; ngeom = Math.pow(nTWR, 1 / Trades); nMeganRatio = MaxTradesPerYear * Math.log(ngeom); drawTextRelative( 4, BottomRow1, "Megan Ratio = "+nMeganRatio.toFixed(6), Color.black, null, Text.PRESET,"Arial",12, "MeganRatio"); return new Array(xSMA20.getValue(0), xSMA5.getValue(0)); } function verify() { var b = false; if (getBuildNumber() < 779) { drawTextAbsolute(5, 35, "This study requires version 8.0 or later.", Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT, null, 13, "error"); drawTextAbsolute(5, 20, "Click HERE to upgrade.@URL=http://www.esignal.com/download/default.asp", Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT, null, 13, "upgrade"); return b; } else { b = true; } return b; }