PARMAR 3P Trading System

Well, as promised here is the MetaTrader 4 Expert Advisor code for the DayBreakTrail Strategy. However, please take very important note of the following:

DISCLAIMER!
I am in no way responsible or liable
for any losses you may incur with the use of this code.
Use at your own risk!

Consider this code as a BETA version, as it has never been tested in any other environment but my own. Use it only on a Demo Account for now. If you are bold enough to risk using it on a live account, you assume all the risk. If you encounter any bugs, please feel free to report them to me using Private Message or e-Mail. DO NOT POST BUG REPORTS HERE ON THE THREAD. This thread is for discussing the strategy and/or the general use of the EA, but not for reporting bugs.

Now, back to the fun stuff! This EA uses Market Orders and not Pending orders. This means that it does not need to compensate for the average spread on the High breakout, because it monitors the Bid price for breakouts and automatically compensates for opening slippage. With this EA, you can also run the PARMAR-1P strategy but it is unable to run the PARMAR-3P.

EDIT: The latest update I made to the downloadable ZIP archive, now contains a PDF document describing all the parameter settings for the EA. The latest version of the EA also now automates the identification of the Opening Session Hour.

NB! Use a H1 Chart and attach the EA to it. All the parameter settings are stored in Global Variables. Once the EA has been assigned to a chart, any changes you wish to make to the parameters, have to be made to the Global Variables, even if you remove and later add the EA again, even if you close and later reopen MetaTrader, even if your PC crashes, you will always need to make the changes to the Global Variables (Press F3) for that specific symbol and timeframe (H1 Chart).

OK! So have some fun playing around with the EA in the Strategy Tester (or Demo Account) and discovering all the parameters.

DayBreakTrail (Version 1.013) - DayBreakTrail.v1.013.zip (284 KB)

EDIT: Updated EA to Version 1.013 for automated Session Open Hour, and added PDF documentation on parameter settings.

Hi to all,
I have defined the allowable slippage when submit the order to the market, the problem is this :

In the case of those two orders, had you set the maximum slippage allowed, they would never have been opened in the first place since they triggered the stop-loss at the same time they were opened (equivalent to a boundary violation), probably caused by a widening spread.

DukasCopy has dynamic spreadā€¦and I have noted that when the order is filled the spread is 25pips ā€¦ :o
so I have developed some fix in the code :

1)now I use only market order ā€¦ I have deleted pending orderā€¦ and this is crucial because before place an order I check if the spread is tight or wide.

2)When I move the Stop Loss to BreakEven I add an offset of 0.5pips ā€¦ in this way if the order is closed the trade is positive. When I move the Stop Loss the second time I remove the offset.

With only this 2 fix I have increased the gain from 17% to 42%ā€¦wow!!!

[B]PERIOD[/B] : 2014-02-01 00:00:00 - 2014-09-01 00:00:00
[B]CANDLE TYPE[/B] : DAILY BAR (GMT 00 and no NY CLOSE) Sunday No trade
[B]Symbol[/B] : GBP/USD
[B]STRATEGY [/B]: DayBreak.Trail
[B]STOP LOSS[/B] : 5 pips
[B]TRAILING STOP[/B] : 5 pips
[B]BREAKEVEN OFFSET[/B] : 0.5 pips
[B]MAX SPREAD ACCEPTED[/B] : 2pips
[B]GAIN (IN PIPS) : 210[/B]

backtesting.rar - Speedy Share - upload your files here

Thank you Carnino

Congratulations! Good for you!

[ul]
[li]Yes, in my EA I also use [I]Market Orders [/I]instead of [I]Pending Orders[/I].
[/li][li]I also check for a [I]Maximum Allowable Spread[/I] before placing the [I]Market Order[/I].
[/li][li]In previous EA versions, I also used a [I]Break-Even Offset[/I] (as can be seen in my back-tests). However, in my current EA version, I decided on using a different approach where the [I]Trailing Step[/I] and the [I]Trailing Stop[/I] can be different values. This allows for the simulation of a [I]Break-Even Offset[/I] but also allows for more flexible Step/Stop variations.
[/li][/ul]
Again, well done on your back-test, but I still see you are not implementing the correct volume. Please remember that Money Management is VERY IMPORTANT if you want to succeed.

Also, back-test for a longer period. Your current date range is too short for proper analysis. You did not provide any metrics, so do not know if you actually calculated them or not, but always get into the habit of doing so for the sake of comparing results.

I have a question about slippage :

I read that slippage can occour when an order is Filled or when an order is Closedā€¦ so :

-) set slippage limit when I submit an order ā€¦limit slippage on opening orders.
-) set slippage limit when I close an order with function close()ā€¦ limit the slippage on closing orders.
-) but when an order reaches Stop Loss ā€¦ how Can I control slippage??.. Maybe it is more convenient donā€™t set stop loss and close always orders with close() function?? What do you think?

thanks to all.

I donā€™t know enough about the [I]JForex programing API[/I] to be able to answer where you can define that, but in [I]MetaTrader[/I] you can define both the ENTER and EXIT Slippage limits.

However, please remember that during the EXIT (StopLoss or TakeProfit or Close), if the slippage is higher than the limit, then the order will NOT CLOSE. That means that it will remain OPEN, so you should have a mechanism to check for that and in the case the loss gets too large (a Catastrophic Stop-Loss Level), you [B]force a close[/B] irrespective of the slippage or current market prices.

[B]EDIT: Sorry, but I was incorrect! Seems I was wrong and in [I]MetaTrader[/I] you cannot set slippage limit on the [I]StopLoss[/I] or [I]TakeProfit[/I]. You can only control maximum slippage on the Open and the Close operations.[/B]

I was reviewing the metrics you have calculated in one of the previous posts :

Metrics (in your case)
Avg. Profit = 7.61 pips, Avg. Loss = 4.23 pips,
Good Trades = 47, Bad Trades = 64, Total Trades = 111

Profit factor = Gross Profit / Gross Loss
Profit factor = (Avg. Profit x Good Trades) / (Avg. Loss x Bad Trades)
In your case: Profit Factor = 357.67 pips / 270.72 pips = 1.321181

Reward:Risk Ratio = Avg. Profit / Avg. Loss
In your case: R:R Ratio = 7.61 pips / 4.23 pips = 1.799054 = 179.9054%

Kelly Criterion = Win Rate - (1 - Win Rate) / Risk Reward Ratio
In your case: Kelly = (47/111) - (64/111)/(7.61/4.23) = 0.102935 = 10.2935%

The Kelly Criterion can be used to increase the Risk%, but I also use it to measure how ā€œsafeā€ a strategy is. If the Kelly is high then it means that it is safer and the Risk of Ruin is lower and will be less likely to have high drawdowns.

I have a doubt about the correctness of the calculation of Gross Profit and Gross Loss,
because it is true that there are Good Trades = 47, Bad Trades = 64
but [B]in reality there are a lot of trades (~ 33) that are about at breakevenā€¦ so for these trades the Avg. Profit/Loss is around 0 pipsā€¦This has a substantial impact in the calculation of Gross Profit and Gross Loss.[/B]

do you agree?

Since your [I]FX Backtesting [/I]report does not include the [I]Gross Profit[/I], [I]Gross Loss [/I]or [I]Profit Facor[/I], these metrics have to be calculated from the information you have there.

So, ā€œBad Tradesā€ = All Trades with a Loss (< 0), ā€œGood Tradesā€ = All Trades that are not BAD (>= 0), which includes Break-even. This means that:

ā€œAverage Lossā€ is for all ā€œBad Tradesā€ and ā€œAverage Profitā€ is for all ā€œGood Tradesā€

Gross Loss = Average Loss x Bad Trades
Gross Profit = Average Profit x Good Trades

Also, surely [I]JForex[/I] provides a Back-testing report of some kind. Have you ever tried looking at that report as well?

first of allā€¦ thanks!!!

My question about parameters:

ā€œintOpenHourā€ : so if my broker is GMT + 3, I have to set midnight, so 0. correct?

thx

At this moment, yes, but remember Daylight Savings!
How is DST handled by your broker?
Is it a UTC+2/3 broker or a UTC+3/4 broker?

A good way to do it, is to look at your [I]Brokers Server Time [/I]and comparing it to the [I]Session Open Times on MyFXBook[/I] and then calculating what offset to use.

Carnino,
Thanks for the EA,
In your back test of the EA, you excluded Mondays trades. how do we disable Mondays trading on the EA?.And kindly include inputs for days of the week that a trader wants the EA to trade

Only in the initial stages of this thread, was Mondays ignored due to a misunderstanding of how [I]Vijay[/I] described the original strategy. Once, it was understood that Mondays should be included, all the most recent back-tests include Mondays (example Post #628).

Originally, the code had a day selector, but since back-tests demonstrated that all days were approximately equivalent in profitability, the option was removed. Unless you can give me a compelling reason to do so, I will not be adding weekly day filter.

I have manually calculated the metrics for the last report that I postā€¦ but the results seem a little too highā€¦


N.B. :

in the calculation of PROFIT FACTOR AND R:R I I have not considered B.E. tradesā€¦because Iā€™m not sure how to add them to the calculation.

Thanks to all.

If I add :

  1. B.E. Trades Gross to Gross Profit (because it has positive expectation ) for the profit factor calculation
  2. B.E. Trades Average Profit to total Average Profit for the R:R RAtio calculation

the results are :


I hope that the calculations are accurate.

Thanks to all

bye bye

Sorry, but your calculations are off because you ignored my explanation with regards to Break-Even trades.

Here are the metrics:

Total Trades = 122
Bad Trades = 51 ( profit < 0 )
Good Trades = 71 ( profit >= 0; includes break-even )
Average Loss = 4.92 pips ( profit < 0 )
Average Profit = 6.49 pips ( profit >= 0; includes break-even )

Win Rate = Good Trades / Total Trades = 71 / 122 = 58.1967%

R:R Ratio = Avg. Profit / Avg. Loss = 6.49 / 4.92 = 131.9106%

Gross Loss = Avg. Loss x Bad Trades = 4.92 x 51 = 250.92 pips
Gross Profit = Avg. Profit x Good Trades = 6.49 x 71 = 460.79 pips

Profit Factor = Gross Profit / Gross Loss = 460.79 / 250.92 = 1.836402

Kelly = WinRate - (1 - WinRate) / RR = 26.5061%

Sorry I havenā€™t read this :

Since your FX Backtesting report does not include the Gross Profit, Gross Loss or Profit Facor, these metrics have to be calculated from the information you have there.

So, ā€œBad Tradesā€ = All Trades with a Loss (< 0), ā€œGood Tradesā€ = All Trades that are not BAD (>= 0), which includes Break-even. This means that:

ā€œAverage Lossā€ is for all ā€œBad Tradesā€ and ā€œAverage Profitā€ is for all ā€œGood Tradesā€

Gross Loss = Average Loss x Bad Trades
Gross Profit = Average Profit x Good Trades

Also, surely JForex provides a Back-testing report of some kind. Have you ever tried looking at that report as well?

In the calculations above, I thought B.E. trades should be considered as a different category from winning or losing trades, because the expected value in pips is equal to 0.3ā€¦and this significantly lowers the average profit

but to make a general evaluation of the results I think youā€™re right and that your calculations are correct.

Thank you. :wink:

[B]P.S. : JForex Back-testing report is even poorer than the FxBacktesting report [/B]

Hi to all,

I add money management to the strategyā€¦1% on current equity
The results are very terrible all the gain is litterally eated by Commissions Costā€¦

Commissions cost is the spreadā€¦itā€™s right?
But if a trade closes in positive also only of 0.5pips ā€¦ whyI have a negative effect on equity? I donā€™t understand.

N.B : for DukasCopy 0.01 is a miniLot (1Pip/1$)


I post the results :

Report of dukasCopy : report.zip - Speedy Share - upload your files here
Report of FxBacktesting : backtestingWithBalance.zip

Thanks to all.

P.S.= in the next improvement I must fix candle Time , in a way that I look at NY daily High/Low

Carnino.
Thank you again for the EA.
For us to test on demo/live as from next week, we will need detailed information on the parameter settings.
Regards

[ol]
[li]In the correct definitions of the terms, a volume of 0.01 is called a [B][I]MicroLot[/I][/B] and a [I]MiniLot[/I] is 0.10 of volume.
[/li]
However, when looking at the report and the values used, it does seem that [I]Dukascopy[/I] is considering 0.01 to be a Minilot and is misusing or misrepresenting the terms which are common to all of us and well defined all over. [B]This can really cause confusion and misunderstandings.[/B]

[li]Commission and Spread are two different types of trading costs that a broker uses. There are also other types of trading costs such as swap or rollover as well. I suggest you do some extra reading and research on this. Good place to review is BabyPips School of Pipsology and Investopedia, but the [I]Dukascopy[/I] website also has information on this.
[/li]

[li]Since your reports donā€™t exactly explain things well, it is difficult to understand how the commission is being calculated and the value applied to each trade.
[/li]
However according to the Dukascopy website, for a Balance Deposit lower than $5000, commission is $35 for every Million Dollars traded (equivalent to 0.0035%). For swap free accounts, an extra $5 per million is charged.

In reference to the [I]JForex[/I] report, and using your first trade as an example of a trade at a price of 1.62902 and a volume of 1.8 Minilots (correcting for the term misuse issue), the traded amount would be $29322.36 and the commission would be $1.03 for the opening and another equivalent value for the closing (you get charged twice per trade). Applying the same principal to all 122 trades, results in a total commission of $278.61 which is somewhat different to the value of $370 reported but still in the same order of values.

To verify my calculations, I compared them to the results on the web calculator and they were equivalent (give or take a cent due to rounding error).

EDIT: According to the JForex Report, and the Turnover and Commission reported, it seems to be using a Rate of $48 per Million. However, according to the JForex documentation for the Historical Tester, you can set the commission rate during the Tester Account setup. So, I suggest you set it to $35 so that the correct commission is calculated.

Now, I do not know much about [I]Dukascopy[/I] and have never traded with them, but it seems that they charge a very high amount of commission, which is not very good for scalping strategies or strategies like the ones on this thread.

[li]Independently of the above, trading has costs (spread, commission, etc.) and your selection of the strategy and its parameters are crucial to success. In this case, the selection of a stop size of 5 pips, may not be sufficient to cover those costs, and you will have to increase the value of the parameter in order for the results to be better and still provide you the profitability you desire.
[/li]
What you can do is back-test with different stop sizes such as 8 pips or 10 pips and see what works better for you.
[/ol]
Regards, Carnino.

Yes, I know and in my post I informed everyone that I would provide those details later this week.

For now, please play around with some of the parameters in the [I]Strategy Tester[/I], or look at the source code, as some of the settings are easy to understand.

Later, I will provide full details! Please be patient!

From the DukasCopy Site :

[B]The volume commission is charged in the primary currency for each opening or closing trade[/B]. Volume commission rate is expressed in USD per 1 million USD traded.

I thought that the volume commission is charged every 30 days according to the volume traded and not on every trade [B]2 times [/B] .

[B]Thank you very much Carnino for posts and support ā€¦ [/B]

Wowā€¦a strategy with a gain of 42% and a win rate 58.1967% in the last backtestingā€¦has almost a negative balance at the end of the test for Commissionsā€¦

I feel a little frustrated for bad results

:(:(:frowning: