Hello there every, new to this group.
Im attempting to set up an auto trader based on the MACd and i cant work out why its buying and selling at the same time. See attached pic
Nothing i change seems to make a difference to it, can any body please assist?
Cheers
DJ
Please post your code so we can help find out any issue.
We need to be able to replicate your trades.
You also need to tell us:
- Instrument
- Time frame used
Here is my code
Not sure what u mean by Instrument sorry
1 min time frame on the any market/chart i apply it too
hope that helps, if u need more please let me know
cheers
DJ
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// Prevents the system from placing new orders on specified days of the week
daysForbiddenEntry = OpenDayOfWeek = 0
// Conditions to enter long positions
indicator1 = MACDline[12,26,9](close)
indicator2 = ExponentialAverage[9](indicator1)
c1 = (indicator1 < indicator2)
IF c1 AND not daysForbiddenEntry THEN
BUY 1 CONTRACT AT MARKET
ENDIF
// Conditions to enter short positions
indicator3 = MACDline[12,26,9](close)
indicator4 = ExponentialAverage[9](indicator3)
c2 = (indicator3 > indicator4)
IF c2 AND not daysForbiddenEntry THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
// Stops and targets
SET STOP pTRAILING 10
SET TARGET pPROFIT 100
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// Prevents the system from placing new orders on specified days of the week
daysForbiddenEntry = OpenDayOfWeek = 0
// Conditions to enter long positions
indicator1 = MACDline[12,26,9](close)
indicator2 = ExponentialAverage[9](indicator1)
c1 = (indicator1 < indicator2)
IF c1 AND not daysForbiddenEntry THEN
BUY 1 CONTRACT AT MARKET
ENDIF
// Conditions to enter short positions
indicator3 = MACDline[12,26,9](close)
indicator4 = ExponentialAverage[9](indicator3)
c2 = (indicator3 > indicator4)
IF c2 AND not daysForbiddenEntry THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
// Stops and targets
SET STOP pTRAILING 10
SET TARGET pPROFIT 100
i cant work out why its buying and selling at the same time
Your code doesn’t do above on my platform … it does attached.
EDIT / PS
What do you have spread set at?
If you have it set at 10 then it will do what you are experiencing due to your TS of 10.
you can see on the chart that its making 2 orders at a time.
yet on the closed list there doesnt appear to be multiple transactions at the same time
i asked in another thread what MAE and MFE stand for, so i best get these dumb questions out of the way as well Abs Perf? Relate Per%? what do they mean please?
Does nbr bars refer to the points/pips of trade?
Also, i have a trailing stop of 10 set why is it then on the losing trades that the nbr bars showing 10 + shouldnt this close the trade at 10 losing points instead of the 20, 23, 19 that it shows?
cheers
DJ
It’s because your trailing stop is hit, usually within the first bar, since it’s really tight.
As you can see from my Pic1 (the same as your, but abridged), the first two trades are tagged both as ENTRY first, then as TRAILING STOP on exit. While the third one hit your target profit.
You can easily spot them on pic2.
Mine is on DAX, 1h, that’s what I meant by “instrument“.
so from my coding what do i need to change to stop it happening please?
whats a more reasonable trailing stop, take profit margin to assist it?
Its interesting to see the same strategy do completely different things , on the left is the asx200 index, which is after hours now, and then on the right the EUR/USD, being a FX trade im guessing the market doesnt shut down like each countries local Stockmarkets.
whats a more reasonable trailing stop, take profit margin to assist it?
Try using the Optimiser to determine above.
Have you watched Nicolas videos?
i cant work out why its buying and selling at the same time
Your code doesn’t do above on my platform … it does attached.
EDIT / PS
What do you have spread set at?
If you have it set at 10 then it will do what you are experiencing due to your TS of 10.
If i have what part set at 10? the TS or something else?
If i have what part set at 10? the TS or something else?
See red squiggly line on attached