Hello to you all,
I hope that someone here can help me with the following problem, because I don’t know how to code it.
I trade dax futures in the 1 min frame.
When my indicator gives the right signal, I buy 1 future long.
If the index drops more than 30 point below my entry point I buy another one. If it drops more than 60 point below the first entry point I buy another one
My TARGET pPROFIT is pointofpositionprice +14 pips.
It allways reaches this target, but sometimes I first have a drawdown of 100 pips before it does so and sometimes it crushes through the 14 pips and keeps on climbing.
So I would like to implement a trailingstop SET STOP pTRAILING 14
I tried different methods, but it doesn’t work.
Below is what I have now.
In attachment I try to explain what I mean. I appologise if I didn’t make myself clear.
Many thanks in advance!
All the best with your coding and trading!!!
DEFPARAM CumulateOrders = true
indicator1 = CALL "long DAX 1 Beste"[28,7,35,19](close)
c2 = (indicator1 >= 2)
if time>081000 and time<212500 AND ONMARKET = 0 then
IF c2 THEN
BUY 2 SHARES AT MARKET
ENDIF
endif
if longonmarket and countofposition = 2 and positionprice - close > 30 then
buy 1 shares at market
endif
if longonmarket and countofposition = 3 and positionprice - close > 50 then
buy 1 shares at market
endif
if longonmarket and countofposition = 4 and positionprice - close > 100 then
buy 1 shares at market
endif
SET TARGET pPROFIT +14
Did you try looking in the Snippet Link Library … link to a Topic containing 4 Trailing SL below (it’s Log 11 in the Snippet Library)
Snippet Link Library
https://www.prorealcode.com/topic/trailing-stop-and-breakeven-codes/#post-93285
Let us know how you get on please?
EDIT / PS
There are several more rows containing Trailing Stops in that Link Library … use the ‘Find’ function on Trailing.
I’ve just ‘named as Type’ … 10 x Trailing Stop snippets … filter on column B on the Link below
Snippet Link Library
Fantastic! I didn’t know about this snippet list.
I am going to search through the list and try them out tomorrow and I will keep you posted.
Many thanks and good night!
Dear GraHal,
I tried the different trailing setups from the snippet link library, but they never give an outcome as good as just setting the pPROFIT +14.(attachment 18/12/2018 (when PRT started to load dayround FDAX) till today)
The problem is that quite some times the index goes a bit in the good direction and then falls back so the (trailing) stoploss is hit. If I set the trailingstart too high( >20), the results drop (trail 1) so I don’t know how to adjust this.
When I trade manually and when the index > 14 point above start, I set a trailing stop manually at the broker. If I set a goal > 14 I go overnight and my position could be forcefully closed by IB. 🙁
When I fully autotrade I miss the extra “index-up” when there is one and that could be a major extra bonus.
Any idea’s?
Many thanks and have a wonderful weekend!
Attachment was not included… Sorry
Since you don’t know how the market will behave, how do you want to know in advance the best trailing stop setting in points? Trailing stop is sometimes not a good choice, because it cuts dramatically the profit in the overall results.
In your averaging down scenario, I would say that if you want to include a trailing stop, the MFE type one would be the first idea to start with. But there will always a setting in points that sometimes would act as the best choice and sometimes not ..!
Thank you Nicolas for your reply. Indeed you are right.(as if somebody would have doubted that 🙂 )
I tested the different kind of trailingstops in the snippet library, but there is no good outcome for such short trades.
I stick to the TARGET pPROFIT and a STOP pLOSS. Works best.
After 6 months of testing and auto-paper-trading, I hope to go live in January.
I will keep you posted…
If I want to do the same for short, then I am not able to sellshort another share.
Does anybody know what I do wrong?
It doesn’t add more short and it doesn’t exitshort when time > 215500
DEFPARAM CumulateOrders = false
indicator1 = CALL "Short Dax 1 min 07012020"[73, 15, 30, 84](close)
c1 = (indicator1 =< -3)
if time>085900 and time<212500 and NOT SHORTONMARKET THEN
IF c1 THEN
SELLSHORT 2 SHARES AT MARKET
ENDIF
endif
if shortonmarket and countofposition = 2 and close-positionprice > 30 then
sellshort 1 shares at market
endif
SET target pPROFIT +12
if time > 215500 and countofposition > 1 then
exitshort 1 share at market
endif
It doesn’t add more short orders because you have set CumulateOrders to false! 😉
COUNTOFPOSITION is negative for short orders, you should code it like this:
if time > 215500 and countofposition < -1 then
Ok. That was not so smart of me… Many thanks Nicolas.
Now I tried:
DEFPARAM CumulateOrders = true
indicator1 = CALL "Short Dax 1 min 07012020"[73, 15, 30, 84](close)
c1 = (indicator1 =< -3)
if time>085900 and time<212500 and NOT SHORTONMARKET THEN
IF c1 THEN
SELLSHORT 2 SHARES AT MARKET
ENDIF
endif
if shortonmarket and countofposition = -2 and positionprice - close > 30 then
sellshort 1 shares at market
endif
SET target pPROFIT +12
if time > 215500 and countofposition < -1 then
exitshort 1 share at market
endif
but it still won’t go short 1 more share when the future goes up more than 30 points from entry…
What do I do wrong?
ooooh I see I must put “close – positionprice > 30 ” off course!!!
Sorry and many thanks!
Dear All,
I want to reset my system when the highest value of the last 85 candles/bars – the close[0] > 120 pips
I do this like this:
High[85] – close[0]>120 but that doesn’t seem to work
or
HIGHEST[85](High) – close[0]>120 but that doesn’t seem to work either???
Can anyone help me?
Many thanks!
Your line is correct if you trade DAX or SP500, while it won’t work with FX pairs, add PIPSIZE:
HIGHEST[85](High) – close[0]>120*pipsize
I think this should do.
Dear Roberto,
It was in DAX.
I couldn’t understand why it didn’t work so I closed PRT and restarted my PC and now it works perfect.
Many thanks and good trading!
Ladis