Mindhero Strategy

The beta versions of the Trading Stations and Marketscope

Moderator: admin

Mindhero Strategy

Postby Apprentice » Wed Jan 25, 2012 4:48 am

Mindhero Strategy.lua
(16.42 KiB) Downloaded 1355 times

Please Install Mindhero indicator
viewtopic.php?f=17&t=1073&p=19474&hilit=mindhero#p19474

For now you can not use it.
There is a bug, in TS, I guess.
I will keep you informed.
Bug Fix will be included in the next official version.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Mindhero Strategy

Postby Hug Coder » Fri Jan 27, 2012 3:52 am

Nice, looking forward for a fully working version.

I have made my own version of Mindhero Strategy though. The problem you have with your strategy is that you can't get the spread, because it's "Not Supported" to use:
bid = core.host:execute("getBidPrice");
ask = core.host:execute("getAskPrice");
in a created indicator (using core.indicators:create("MINDHERO", Source, artp, cecf , atrn, true) ).

I "solve" this by creating 2 subscriptions in the Strategy:
Source = ExtSubscribe(1, nil, instance.parameters.TF, instance.parameters.Type == "Bid", "bar");
Ask = ExtSubscribe(2, nil, instance.parameters.TF, false, "bar");
Then I get the spread:
Spread = math.abs(Source.median[period] - Ask.median[period]);
and I send it to the mindhero indicator at creation (problematic if the spread varies a lot). This means it has to be modified to accept the spread as a parameter though.

The problem I have is that my strategy always acts AFTER the candle has closed. If I get a indicator signal at 12:15 in 15 min timeframe, it will enter at open price for the next candle at 12:30. I'm sure your version would do this as well. And this is of course a big problem, mindhero requires quick action at the trigger for best results.

Is there any way to act on the exact point of signal? Basically act on a non-closed candle.
Hug Coder
 
Posts: 38
Joined: Fri Jan 13, 2012 5:43 am

Re: Mindhero Strategy

Postby Hug Coder » Mon Jan 30, 2012 4:18 am

Trading Station 2 was updated yesterday. It still doesn't support getting the spread... Why wasn't this fixed?? It's very annoying.

bid = core.host:execute("getBidPrice");
ask = core.host:execute("getAskPrice");
gives error "Not Supported".

Also, Apprentice, have you had any chance to look at the mindhero indicators I sent to your mail?
Hug Coder
 
Posts: 38
Joined: Fri Jan 13, 2012 5:43 am

Re: Mindhero Strategy

Postby sunshine » Mon Jan 30, 2012 6:48 am

Hug Coder wrote:bid = core.host:execute("getBidPrice");
ask = core.host:execute("getAskPrice");
gives error "Not Supported".

The methods can be used in indicators only. In strategies you can use prices from subscribed streams.
sunshine
 

Re: Mindhero Strategy

Postby Hug Coder » Mon Jan 30, 2012 8:59 am

sunshine wrote:
Hug Coder wrote:bid = core.host:execute("getBidPrice");
ask = core.host:execute("getAskPrice");
gives error "Not Supported".

The methods can be used in indicators only. In strategies you can use prices from subscribed streams.


I know. But Strategy uses indicator to get signal! If that indicator needs bid and ask, you get error. I know I can get the spread in the Strategy, but the Indicator needs the spread, not the Strategy. I can send the spread as a parameter at creation, but after that, if the spread varies, it will not change in the indicator. And thus it would give false signal.


Also a bigger problem is the fact that signal is only sent on a closed candle. If I use the D1 timeframe, this means that if the signal happens today, the strategy will trigger tomorrow! Very big problem for Mindhero. Even for 15 or 30 min timeframe this is a big issue. 5 min is far from optimal too if you act on the next candle and not where it triggered.
Hug Coder
 
Posts: 38
Joined: Fri Jan 13, 2012 5:43 am

Re: Mindhero Strategy

Postby sunshine » Fri Feb 03, 2012 5:46 am

I have forwarded the issue to developers. Hope it will be fixed in the next release.

Thank you for reporting the problem.
sunshine
 

Re: Mindhero Strategy

Postby Hug Coder » Tue Feb 07, 2012 7:57 am

sunshine wrote:I have forwarded the issue to developers. Hope it will be fixed in the next release.

Thank you for reporting the problem.


Thanks for forwarding it! It will make the strategies that require calculation of spread (which often is variable) much more reliant.

But another issue with the Mindhero Strategy that I have in my version; the strategy always acts on closed candles and not where the indicator actually triggered.

For example, Indicator triggers at Feb 6 in D1 timeframe. Strategy triggers at Feb 7, one day after. Trigger at 11:00 in H1 indicator will give strategy buy/sell at 12:00. This is 1 hour late. It obviously hurts this strategy a lot. In general it always triggers on the next period.

Is there a workaround for this? To trigger on not-closed-candles?
Hug Coder
 
Posts: 38
Joined: Fri Jan 13, 2012 5:43 am

Re: Mindhero Strategy

Postby sunshine » Tue Feb 07, 2012 11:40 pm

The strategy code can be rewritten so that the strategy will check the conditions on a live bar. But this will cause the strategy to produce false signals.
Please read for details the article: Closed Bar against Live Bar.
sunshine
 

Re: Mindhero Strategy

Postby Hug Coder » Wed Feb 08, 2012 8:00 am

sunshine wrote:The strategy code can be rewritten so that the strategy will check the conditions on a live bar. But this will cause the strategy to produce false signals.
Please read for details the article: Closed Bar against Live Bar.


Thanks for the link, I have read the article.

The thing is though that it says:
"So, in short, for almost all signals and for many indicators, the indicator can produce "noise" – in other words, produce a false signal even if in the final version of a bar the signal does not appear."

Mindhero is one of those that need action right away, even if it turns out to be a bad signal it will most often be better than acting on next candle, especially in short term trades.

Can you please give some hint on how to do this?
I guess I could read the tick source and somehow create a candle, but how I can update the indicator with this and only use tick for the most fresh candle, I have no idea. I cannot send parameters to the indicator except on creation, right?
And will this make it act on the "real" indicator signal both in strategy backtesting and live strategy trading?
Hug Coder
 
Posts: 38
Joined: Fri Jan 13, 2012 5:43 am

Re: Mindhero Strategy

Postby sunshine » Fri Feb 10, 2012 6:08 am

To make the strategy to work on a live bar, you should:
1) Subscribe for tick prices;
2) When a new tick comes and ExtUpdate is called, convert the period and use the converted period;
3) Add checking for multiple operations within the same bar.

Let's take a closer look at each of the steps.

1) You can subscribe for ticks using the command:
Code: Select all
ExtSubscribe(2, nil, "t1", true, "tick");

2) In ExtUpdate(id, source, period), the period variable will be valid for ticks but not for indicators created on bars.
You can get the bar index when tick update in the following way:
Code: Select all
barPeriod = barSource:size() - 1;
By the way, the bar collection in the midhero strategy is called "source = ExtSubscribe...". It should be renamed because ExtUpdate has own source.

3) Keep the number of the bar for which the strategy has already generated a signal. If the number of the current bar is equal to the kept number, exit the function:
Code: Select all
if barSource:serial(barPeriods) == lastSerial then
    return;
end
When the strategy makes a trade operation (e.g. open a trade), save the number of the bar:
Code: Select all
lastSerial = barSource:serial(barPeriods)

I hope this helps.
sunshine
 

Next

Return to Beta Versions

Who is online

Users browsing this forum: No registered users and 4 guests