Hi,
I am wanting to create a code so that the profit target must be reach in the next period.
I am having problems with the backtesting showing that a trade was successful because the trigger bar was long enough that the profit target was within the trigger bar, even though the market didn’t trade there after the order was triggered.
Thanks! I really appreciate it!
Here is the code I have currently..
if not shortonmarket then
sellshort 15 share at shortLevel limit
endif
if not longonmarket then
buy 15 share at longLevel limit
endif
set stop ploss stoploss
set target pPROFIT profi
endif
sorry I think there was a problem with the code… Just to be sure
if not shortonmarket then
sellshort 15 share at shortLevel limit
endif
if not longonmarket then
buy 15 share at longLevel limit
endif
set target pPROFIT profi
set stop ploss stoploss
endif
It’s a common “problem” with the tester. Because each conditions are only tested once per bar, the tester don’t have any idea of when the price has reach your short or long levels limit. And if your stoploss and takeprofit prices were include in the same bar, tester consider the takeprofit firstly.
Also, when you use pPROFIT ou pLOSS you are defining point values, like 15 points for 0.0015 pips for forex pairs for example.
Awesome thanks Nicholas for your help.