Manual Entry Strategy with auto activated Chandelier

If you need an Indicator or Signal developed or translated from other language, please post all Indicator development REQUESTS to this section here.

Moderator: admin

Manual Entry Strategy with auto activated Chandelier

Postby loseend » Mon Dec 10, 2018 4:44 pm

Hi there!

Apprentice can you assemble two existing strategies into one new strategy for me?

The 2 strategies are the " Manual Entry Strategy.lua" (MES) and the "Chandelier trailing stop Strategy.lua" (CTS).

The MES is very useful to determine BreakOut Entries. I changed the signal code into several versions but the general clue of the indicator is always the same: if the second-to-last price is above a given level and the last price is below then SELL - vice versa for BUY.

Also MES allows to place an Initial Stop and a Target Exit.

Once MES has opened a position you have to handle the position. As with any trade you can leave the STOP where it is waiting to be stopped out or waiting until your Limit gets executed. Or you can trail the STOP manualy or apply a Trailing Stop Strategy, whatever.

Problem with MES is that you have to be on the monitor to do all that.

Another downside: if you don't watch what's going on it may happen that MES opens a trade, the trade gets stopped out, the price hits the Entry criteria again - and MES reopens a new trade. And so on. Some poeple may find that useful but I don't. If I get stopped out I normaly won't entry that same trade again couple minutes later.

Now, my request is the following.

Once MES has opened a Trade:
1. MES should activate CTS
2. MES should BLOCK ANY NEW ENTRY after the initial Entry has been stopped out.
In other words, it should shut off.
3. a working Mandatory Closing (I found some Strategies with Mandatory Closing options on the codebase but none worked)
4. a Mandatory Opening

Regarding point 4: I leave the house at 8 o'clock in the morning but before I leave I activate MES to entry a trade at a given level. At say 2 PM the price meets that level and MES opens the trade...
But at 2:30 PM important economy numbers are scheduled in America. I don't want MES to open that trade 30 minutes before the numbers get out.

So a Mandatory Open should provide the option to open a trade >= 2:45 PM.

This is an example for how I changed the signal code for the Short side:
if Source.close[period - 1] < Entry and
Source.close[period - 2] >= Entry
then
if Direction then
SELL();
end
ONE= Source:serial(period);
end

A Mandatory Open >=2:45 PM allows MES to open a position on 2:45 (if criteria is met at 2:45) or 3 PM (if criteria is met) or 3:15, 3:30 and so on - but at no Bar CLOSE before 2:45 PM!

Regarding point 1: when MES opens a trade, say a SHORT, CTS may still be pursuing the LONG side. Obviously MES only can activate CTS once CTS flips to the SHORT side too - until then the Initial STOP remains untouched.

That's it.

Apprentice, can you do that for me?
loseend
 
Posts: 28
Joined: Tue Jul 31, 2018 12:37 pm

Re: Manual Entry Strategy with auto activated Chandelier

Postby Apprentice » Wed Dec 12, 2018 7:26 am

Your request is added to the development list under Id Number 4355
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 21584
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia


Re: Manual Entry Strategy with auto activated Chandelier

Postby loseend » Thu Dec 13, 2018 4:23 am

Wow! That was a quick shot. Thank you very much.
Couldn't take a look at it yet. Be back soon.
loseend
 
Posts: 28
Joined: Tue Jul 31, 2018 12:37 pm

Re: Manual Entry Strategy with auto activated Chandelier

Postby loseend » Thu Dec 13, 2018 10:22 am

Stunning so far. CTS gets activated and after positions been kicked out MES shuts off. "Start Trading" is working as well.
What won't work is the Mandatory Closing but I know that by now. I'm almost certain that the bug is with me - doin something wrong or so. On the other hand there ain't too much left to be done wrong.

Apprentice, can you add another option? Is it possible to tell MES whether CTS should run in BID or ASK mode?

By the way, I had to change the signal code a little.

The MES I used until now worked with
if Source.close[period - 1] < Entry and
Source.close[period - 2] >= Entry then


ENTRY on the same code comes in 1 Bar late with this new MES. Now
if Source.close[period] < Entry and
Source.close[period - 1] >= Entry then

works.

Ah, and there's another thing that is not working optimal.
If there are more than one MES active (with different Entry Levels e.g.) - they all get shut down when a running Trade, triggered by one MES, ist stopped out.

Anyway, pretty fine work you did for me. Thanks a lot!
loseend
 
Posts: 28
Joined: Tue Jul 31, 2018 12:37 pm

Re: Manual Entry Strategy with auto activated Chandelier

Postby Apprentice » Fri Dec 14, 2018 1:17 pm

Added another option for CTS as requested + fixed ids collision (it
should fix mandatory closing).
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 21584
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Manual Entry Strategy with auto activated Chandelier

Postby loseend » Sat Dec 15, 2018 8:02 am

Thanks for adding and fixing!

Most crutial effect: Mandatory Closing is working! Great!!

The fixed rest alas screws up the whole strategy.

I explain it on the basis of a Short trade:
Price hasn't made a Close below CTS' Long line but is just jerking around instead above and below that Long line.
Once CTS got triggered by this fixed version of the strategy in the first place the fixed version treats my Short trade as a Long trade! It instantly gets stopped out by CTS' Long Stop!

The unfixed version didn't behave that way.

Image shows two trades which had been opened by fixed and unfixed version.
Fixed version's position will be stopped out in a sec.
MES.CTS.png



Also there is no shutting off anymore after a trade has been closed.


This strategy has more than 2000 code lines, and even if there's a lot of copy & paste of modules in it I guess it might be too much of an input to get this thing going in detail. But it's not so bad.

I compared the total of code lines. The difference between fixed and unfixed version is 4 lines.
If I am right, adding CTS Ask/Buy mode to the strategy makes 4 lines - but at the very last code line there is funy thing, at least funny to me who hasn't got a clue with lua:
in both versions that line is assigned as "tables_monitor:RegisterModule(Modules);"
The unfixed version (filled-up by these 4 lines) claimes this line as line 2241 Col 40.
The fixed version says line 2242 Col 1.
In both versiions the second to last line is line 2241 Col 1.


Well, it looks somewhat like adding CTS Ask/Buy mode has caused the problem.
May be it's possible to just integrate the bug fix you did with Mandatory Closing into the unfixed version (.
The strategy would then be very well applicable to me. Thanks a lot!
loseend
 
Posts: 28
Joined: Tue Jul 31, 2018 12:37 pm

Re: Manual Entry Strategy with auto activated Chandelier

Postby loseend » Sun Dec 16, 2018 6:22 am

I looked for the changes you made to make Mandatory Closing work. It seems you just replaced one single number, that is you change 100 with 99. I did the same to the unfixed version and now Mandatory Closing works. Very good so far.

I think it's not that important to have the BID/ASK-mode option with Chandelier and other than that there is just one problem left to have a fully working strategy: a reliable Shut Off of MES.CTS after position got closed.


This Trade was opened by MES.CTS - Position stopped out and MES.CTS instantly shut off!
Also in this case I had another active MES.CTS pending with different Entry Level.
When MES.CTS shut off BOTH shut off (even the one that didn't trigger a trade yet)
ShutOff.png



Position stopped out
1. by CTS
2. by Limit Exit
Either way: MES.CTS DIDN'T shut off!
noShutOff.png



I wonder if the images explain much, anyway in one case ShutOff of MES.CTS worked in the other it wouldn't. Weired.


So, all thats left is the Shut-Off problem.
If you feel to have a look at it soemewhen please use the strategy I attached.
It's the Sell version of MES.CTS and I did some rearrangements of parameter groups, also I cut out options: x_shift, y_shift, Bar and crossover.
I wouldn't have to rearrange it all again if you'd use the strategy attached.

ManCTS_FBOant_SELL.lua
(83.33 KiB) Downloaded 92 times
loseend
 
Posts: 28
Joined: Tue Jul 31, 2018 12:37 pm

Re: Manual Entry Strategy with auto activated Chandelier

Postby loseend » Tue Dec 18, 2018 1:14 am

No clue whats going on but now Mandatory Closing won't work either anymore - won't work with my "rearranged" version nor with your fixed version "3".

Only thing that is reliable is activating CTS - everything else sometimes works sometimes won't.
loseend
 
Posts: 28
Joined: Tue Jul 31, 2018 12:37 pm

Re: Manual Entry Strategy with auto activated Chandelier

Postby Apprentice » Tue Dec 18, 2018 8:34 am

I've changed the strategy to close not only on stop but on
limit/manual closing too, And the strategy will check for custom ID of
the closed trade. The mandatory closing could be skipped when using
low value for Valid interval for operation in second (especially in
simulator/backtester)
ManCTS_FBOant_SELL.lua
(83.19 KiB) Downloaded 88 times
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 21584
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Next

Return to Indicator and Signal Requests

Who is online

Users browsing this forum: domi8262 and 5 guests