Cost Averaging System - page 27

[Deleted]  
Maji:
I don't mean to be rude, so please don't take it that way. Let us keep this thread focussed on the cost averaging system. I tried using CCI and Williams%R. These oscillators are too whippy, or atleast the system thinks so.

that's why I am trying to develop an appropriate filter using support and resistance. I don't mean to be rude either, I'm sorry, I thought you wanted input on this project. I'll take the support/resistance development elsewhere I guess. If you use my method (as yet incomplete) or some other way of calculating s/r I believe that is the best filter for this system, or at least what I would recommend most. I look forward to seeing whatever you decide to do with it next.

 
Maji:
Scott,

I think it is an avenue worth exploring. You can make that change in your code and see how it affects.

By the way, I still think random entry is the way to go. What we need is adequate capital to withstand the drawdowns.

With IBFX, trading nanolots and a reasonable capitalization for a few pairs maybe a way to test this system.

Good morning Maji.

Two questions for you

1). In my test for USD/CAD last night, showed many error messages complaint the invalid lotsize. Do not know why. I believe for lot size calculation, it is the same as previous version, right? I have put the trace in the code, will see if this will happen again.

2). As you suggested, I made a change to the condition for adding positions.

Strange to me, the previous selling price is 1.1335 at lot size 0.3, and the price went to 1.1366. Suppose to open another trade with lot size 0.5 since the pipstep is 30 pips. Do not know why.

BTW, after changing the code and recompiling, the MT was restarted.

Thanks!

Scott

[Deleted]  

1). In my test for USD/CAD last night, showed many error messages complaint the invalid lotsize. Do not know why. I believe for lot size calculation, it is the same as previous version, right? I have put the trace in the code, will see if this will happen again.

Your best bet are the tracers. Lot size calculation should remain same.

2). As you suggested, I made a change to the condition for adding positions.

Strange to me, the previous selling price is 1.1335 at lot size 0.3, and the price went to 1.1366. Suppose to open another trade with lot size 0.5 since the pipstep is 30 pips. Do not know why.

Check the code again. Sometimes little bugs creep in unnoticed.

 

is orderstotal broke? pyr

[Deleted]  
lowphat:
is orderstotal broke? pyr

Not that I know of. However, there maybe hidden bugs. Let me know what you see and how, and then maybe I can figure out how to squash them.

thanks.

[Deleted]  

I started https://www.mql5.com/en/forum/175440

as an attempt to #1 not derail EA threads with copyright info #2 focus efforts and communication for protecting copyright.

Copyright holders wanting help, or volunteers willing to find violators please comment in that thread.

 

A bug for variable Lots ?

Maji:
1). In my test for USD/CAD last night, showed many error messages complaint the invalid lotsize. Do not know why. I believe for lot size calculation, it is the same as previous version, right? I have put the trace in the code, will see if this will happen again.

Your best bet are the tracers. Lot size calculation should remain same.

2). As you suggested, I made a change to the condition for adding positions.

Strange to me, the previous selling price is 1.1335 at lot size 0.3, and the price went to 1.1366. Suppose to open another trade with lot size 0.5 since the pipstep is 30 pips. Do not know why.

Check the code again. Sometimes little bugs creep in unnoticed.

After adding some trace, the error message is shown as:

2006.11.02 20:45:28 Cost_Avg___RSI_w_Trend_v3 USDCAD,M15: Error: 0

2006.11.02 20:45:28 Cost_Avg___RSI_w_Trend_v3 USDCAD,M15: invalid lots amount for OrderSend function

2006.11.02 20:45:28 Cost_Avg___RSI_w_Trend_v3 USDCAD,M15: iLots for ShortTrade: 0

2006.11.02 20:45:28 Cost_Avg___RSI_w_Trend_v3 USDCAD,M15: NumOfTrades=3 Lots=0

2006.11.02 20:45:28 Cost_Avg___RSI_w_Trend_v3 USDCAD,M15: total in PlaceAddTrade:3

2006.11.02 20:45:28 Cost_Avg___RSI_w_Trend_v3 USDCAD,M15: total from CountTrades(): 3

2006.11.02 20:43:03 Cost_Avg___RSI_w_Trend_v3 EURCHF,M15: Error: 0

2006.11.02 20:43:03 Cost_Avg___RSI_w_Trend_v3 EURCHF,M15: invalid lots amount for OrderSend function

2006.11.02 20:43:03 Cost_Avg___RSI_w_Trend_v3 EURCHF,M15: iLots for ShortTrade: 0

2006.11.02 20:43:03 Cost_Avg___RSI_w_Trend_v3 EURCHF,M15: NumOfTrades=1 Lots=0

2006.11.02 20:43:03 Cost_Avg___RSI_w_Trend_v3 EURCHF,M15: total in PlaceAddTrade:1

2006.11.02 20:43:03 Cost_Avg___RSI_w_Trend_v3 EURCHF,M15: total from CountTrades(): 1

I think I have found at least one bug in the code.

The global variable Lots is set in the method PlaceFirstTrade. This will cause the above problem. Assuming we have one or more open positions for certain pair. If the MT was restarted, this method will not be invoked any more until next time all positions are closed. If this method is not invoked (after restarted MT), then the variable lotSize is always 0,

iLots = NormalizeDouble(Lots*MathPow(LotExponent,NumOfTrades),1);

the iLots will be zero too, causing the error for Invalid lots amount in ordersend function.

Suggestion: the Lots should be calculated in main start function.

Thanks!

Scott

 

Hi Maji.

I can test your EA on my MIG,CFG demo.

My mail - yan7181@hotmail.com. yan.

[Deleted]  

Scott,

Thanks for pointing that nasty little critter out.

I think you can put this statement:

total=CountTrades();

where every you see the following:

NumOfTrades = total;

That should take care of it. That total was being lost for some reason each time a subroutine was being called.

Maji

 

Forward Testing Update

Testing : Cost Averaging - RSI

TimeFrame : M5

Pair : USD/JPY; USD/CHF; GBP/USD; USD/CHF

Leverage : 1:100

Equity : 10.000 US$

LotExponent = 1.666667;

slip = 3;

Lots = 0.1;

TakeProfit = 10;

Stoploss = 500;

PipStep = 30;

MaxTrades = 10;

UseSafeMode = true;

UseRSIforAddTrade = true;

UseStopLoss = true;

TotalEquityRisk = 20;

BuyLevel = 20;

SellLevel = 80;

SlowPeriod = 14;

FastPeriod = 5;

PriceType = 1