Trailing Stop is not Executed in Backtesting. No Errors.... Please help because I'm stumped. - page 2

 
35806:

i though that if you do () in those brackets it refers to the current order... the order selected earlier in the code. I can't stare at the code for hours. That would be completely inefficient j/k. Ok i read how to do a print statement and i seel what you mean. Sorry for the misunderstanding, I'm a beginner and don't really know the terms. I thought you meant printing the errorlog. I will print all the variables and post again. Thank you for all of your help.

Once an order is placed . . . .

This

if(SellStopPrice==Ask && OrdersTotal()<1 && SellTicket==0)  

and this . .

if(BuyStopPrice==Bid && OrdersTotal()<1 && BuyTicket==0) 

are both false because OrdersTotal() is no longer < 1 so the OrderModifys don't get called.

 

I ran your code on AUDUSD

Strategy Tester Report

Movingvaveragejstrategery

IBFX-MT4-Demo2 (Build 402)


SymbolAUDUSD (Australian Dollar vs US Dollar)
Period1 Hour (H1) 2007.04.05 19:00 - 2011.07.29 21:00 (2007.04.01 - 2011.07.31)
ModelEvery tick (the most precise method based on all available least timeframes)
ParametersStopLoss=300; TakeProfit=450; TrailingStop=100; MinimumProfit=200; MagicNumber=426; MAPeriod=20; VicOne=100; VicTwo=200; MAFrame=5; MAMethod=1; MAPrice=0; Lots=0.03;
Bars in test27035Ticks modelled32213284Modelling quality89.67%
Mismatched charts errors0
Initial deposit10000.00
Total net profit-4736.03Gross profit16571.79Gross loss-21307.82
Profit factor0.78Expected payoff-1.12
Absolute drawdown4752.25Maximal drawdown4779.88 (47.67%)Relative drawdown47.67% (4779.88)
Total trades4238Short positions (won %)2119 (34.31%)Long positions (won %)2119 (54.60%)
Profit trades (% of total)1884 (44.45%)Loss trades (% of total)2354 (55.55%)
Largestprofit trade14.25loss trade-10.99
Averageprofit trade8.80loss trade-9.05
Maximumconsecutive wins (profit in money)14 (132.03)consecutive losses (loss in money)14 (-127.49)
Maximalconsecutive profit (count of wins)132.03 (14)consecutive loss (count of losses)-127.49 (14)
Averageconsecutive wins2consecutive losses2

 

Here is the updated code for both. I hope that this is what you were looking for. The trailing stop still isn't initiated so i don't have anyway of diagnosising this problem. My suspicion is that it has something to do with the order not being selected and therefore trailing stop is not being initiated... I don't know if this is actually the case.

 

oh thanks. looks like i still have some work to do haha. So, to clarify, i should delete the parameter orderstotal<1?

 

once again thank you for all of your help. you were a lot of help.

 

I was running it on euro because it has the lowest spread.

 

will you send me the updated code?

 
35806:

will you send me the updated code?

Look at the last post on page 1
Reason: