You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Cost Averaging RSI w-Trend v3
Testing : Cost Averaging RSI w-Trend v3
TimeFrame : M30
Pair : USD/JPY; USD/CHF; GBP/USD; USD/CHF
LotExponent = 1.666667;
slip = 3;
pLots = 0.1;
TakeProfit = 20;
Stoploss = 500;
PipStep = 25;
MaxTrades = 10;
UseStopLoss = false;
TotalEquityRisk = 5;
UseSafeMode = true;
UseRSIforAddTrade = true;
BuyLevel = 20;
SellLevel = 80;
SlowPeriod = 9;
FastPeriod = 5;
PriceType = 5;
UseTrend = true;
sMAPeriod = 20;
MAPeriod = 10;
MATimeFrame = 1440;
MAMethod = 0;
MAPrice = 5;
UseMASlope = true;
MinPips = 10;
MALookBack = 5;
UseTrailingStop = false;
TrailStart = 50;
TrailStop = 50;
MM = false;
RiskPercent = 0.1;
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.
MajiMaji,
Seems the above solution wouldn't fix the issue. In my previous message, you could see the value of total is calculated correctly, but the the value of Lots is wrong in PlaceAddTrade, which is reset to 0 whenever MT is restarted or the system is re-compiled.
For my own test, I could put
Lots = pLots;
before calling PlaceAddTrade() in start().
Please correct me if I am missing sth.
Thanks!
Scott
Maji,
Seems the above solution wouldn't fix the issue. In my previous message, you could see the value of total is calculated correctly, but the the value of Lots is wrong in PlaceAddTrade, which is reset to 0 whenever MT is restarted or the system is re-compiled.
For my own test, I could put
Lots = pLots;
before calling PlaceAddTrade() in start().
Please correct me if I am missing sth.
Thanks!
Scottforex4syg
I think that you can fix this problem by doing the change explained by maji in post #229.
Maji,
Seems the above solution wouldn't fix the issue. In my previous message, you could see the value of total is calculated correctly, but the the value of Lots is wrong in PlaceAddTrade, which is reset to 0 whenever MT is restarted or the system is re-compiled.
For my own test, I could put
Lots = pLots;
before calling PlaceAddTrade() in start().
Please correct me if I am missing sth.
Thanks!
ScottScott,
Let me try to analyze the code here.
total=CountTrades();
NumOfTrades = total;
iLots = NormalizeDouble(Lots*MathPow(LotExponent,NumOfTrades),1);
total is finding the number of trades in that symbol with the given Magic Number, whenever the program reaches that point. Then you are using that to calculate iLots. Now, Lots is an extern variable with global scope, so it will not change within the EA, unless I messed it up and changed it somewhere. Thus, you should now have the right iLots.
Let me know if anyone else thinks different. I thank Scott and other for helping to test and debug the system.
Scott,
You are right. Lots should be calculated as such. I forgot that I had changed Lots to pLots when I introduced Money Management.
I have to remember to update this in my other versions.
Thanks.
Scott,
Let me try to analyze the code here.
total=CountTrades();
NumOfTrades = total;
iLots = NormalizeDouble(Lots*MathPow(LotExponent,NumOfTrades),1);
total is finding the number of trades in that symbol with the given Magic Number, whenever the program reaches that point. Then you are using that to calculate iLots. Now, Lots is an extern variable with global scope, so it will not change within the EA, unless I messed it up and changed it somewhere. Thus, you should now have the right iLots.
Let me know if anyone else thinks different. I thank Scott and other for helping to test and debug the system.One of us must missing sth here.
iLots = NormalizeDouble(Lots*MathPow(LotExponent,NumOfTrades),1);
The only posibility causing iLots to be zero is the variable Lots and NumOfTrades, other can not lead to the zero of iLots. So far, is this right? From my trace, it is seen that the NumOfTrades is not zero, e.g., NumOfTrades=3. So adding the line
total=CountTrades();
would not resolve the issue. Hopefully, so far, it is right. Then it must be caused by the value of Lots. Lets see how the variable Lots causes a problem.
As you see in the code, Lots is a global variable (by the way, it is not external variable, pLots is external variable). The globale variable Lots is set inside the method PlaceFirstTrade as:
void PlaceFirstTrade()
{
if (!ShortTrade && !LongTrade)
{
total=CountTrades();
NumOfTrades = total;
if(MM==true)
Lots = LotSize();
else
Lots = pLots;
....
}
This is the only place the variable Lots is calcuated when the first trade is added. This value of the global variable can be used by other method in the system. If you never turn off your PC, and never close your MT, this would have no problem. That is why most people can not see this problem if they did not turn off the MT. Problem happened to me because I restarted the MT. Lets see why the PB can happen after restarted MT.
When the MT restart, the global variable is now initialized again as zero (and lossing the previous value). So far, it is right?
Since one or more positions were opened before the turn off the MT, the total number of the pair is now larger than 0, and the system will not invoke the method PlaceFirstTrade to open the first trade. So the global variable will not be calcuated by the method. It is zero when calling PlaceAddTrade to add other trades. Please see the trace (shown inside of PlaceAddTrade), and you will see the value of Lots is really 0
========================================================
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
========================================================
Hopefully we are clear about these. If you calcuate the Lots in start() rather than in PlaceFirstTrade(), I believe the problem will disappear.
Thanks!
Scott
Absolutely champ... but remember, no pain... no gain
Here is the version that uses the RSI without any kind of trend filters. It is used on 15 m charts, with buy and sell levels at 20 and 80, with the long and short RSI periods at 9 and 4. The price type is "5" and I add trades using RSI. It made good profits because of the lacklustre market this week.