Topic: Spread limiter

One more idea for an indicator.

I think it might be useful to develop a spread limiter. By this I understand an indicator which monitors the size of a spread and limits failed entries after unexpected market events (news, interventions). It will be especially useful for those of us who use variable spread brokers.

Example:

Spread Limiter

Open position when the spread is < than ...
Open position when the spread is > than ...
Close position when the spread is > than ...
Close position when the spread is < than ...
The spread increases
The spread decreases

etc.

Indicators based on statistics are extremely useful in scalping and high frequency trading. They might be worth further consideration.

Re: Spread limiter

I agree spread should be integrated in FST. Can you elaborate more on "indis based on statistics"?

Re: Spread limiter

http://www.traderslaboratory.com/forums/market-profile/4803-trading-market-statistics-links.html

The link above presents some basic concepts of market statistics and how to trade them. VWAP is just one well known method. If you would like to investigate the matter look for "market microstructure" - in my view one of the most reliable scalping methods

Re: Spread limiter

Is anyone willing to program this indicator and post it here?

Re: Spread limiter

Thanks, I might learn a few things from this.
When you say:

ldnfx wrote:

Is anyone willing to program this indicator and post it here?

do you mean VWAP? I can take a shot at coding it, however I can't promise anything about the outcome. My schedule is a bit tight at the moment, so that means a slight delay also.

One more note - the mentioned indi handles Volume, but if one has a trading account without level II market access, volume data is somewhat not truly representative of the actual (whole)
market, therefore my question whether the indi is still usable and accurate?

Re: Spread limiter

I mean spread limiter. In my case its the most important thing at the moment as I'm tradying with variable spread.

Regarding VWAP - in forex we have tick volume which represents the relative value of activity. We dont need the actual number. I do agree that somewhat its not trully representative of the actual market, however still useful.

Regarding market microstructure - here we obviously need level II data (at least its difficult for me to think about it without level II). FX Open provides a solution which is quite close to an ECN with level II - http://www.fxopen.com/ecnforextrading.aspx

I will be able to explain the idea behind this concept on you request.

7 (edited by ldnfx 2012-06-04 17:19:14)

Re: Spread limiter

http://www.dailyforex.com/forex-articles/2012/02/Using-Volume-to-Win-75-of-Trades/10825

In 2011, Caspar Marney, head of Marney Capital and ex-UBS and HSBC trader, conducted an analysis of actual volume and tick volume in Forex. He used data from eSignal, EBS and Hotspot. For the pairs he studied, he calculated the correlation between tick volume and actual volume is over 90%.

Re: Spread limiter

The spread limiter has to be added to FST's expert, as an indicator it won't work as intended, FST "doesn't know" what is variable spread.

Re: Spread limiter

Footon, FST indicators have access to the market info and the spread. They are recalculated at every tick.
FSB indicators also have access to the spread, but it is a constant value.

Re: Spread limiter

Popov wrote:

Footon, FST indicators have access to the market info and the spread. They are recalculated at every tick.
FSB indicators also have access to the spread, but it is a constant value.

That's great news, another valuable bit learnt, but I'm getting "The name 'Spread' does not exist in the current context." error when I try to call Spread. I didn't test my indi to the latest FST, but I don't think that's the case.

Calculation block:

int iFirstBar = 1;
            double[] spr = new double[Bars];
            double point = (Digits == 5 || Digits == 3) ? 10 * Point : Point;
            double correctpoint = iPip * point;

            for (int iBar = 1; iBar < Bars; iBar++)
            {
                if (Spread <= correctpoint)
                spr[iBar] = 1;
            }

Re: Spread limiter

Try this way:

double bid = Data.Bid;
double ask = Data.Ask;

// Calculation
double spread = ask - bid;
int firstBar = 1;

// Calculation of the logic
double[] spreads = new double[Bars];
for (int bar = firstBar; bar < Bars; bar++)
     spreads[bar] = spread;

http://i.imgur.com/EkBtm.png

Prototype is attached below.

Note: Info panel is not updated at every tick I think, but spread must be correct.

Post's attachments

Spread.cs 2.46 kb, 29 downloads since 2012-06-05 

You don't have the permssions to download the attachments of this post.

Re: Spread limiter

Alright, I got the indi working, but one issue:

The info panel is really not updating, if chart is opened, then maybe 2-3 times with the incoming ticks the spread changes and then it freezes, if tabs are toggled and chart is brought back for viewing, info panel updates. It might not be a huge problem when internally it's always up to speed to the current spread, so am I right in assuming that the indi has always the latest spread value, even though it doesn't update it in the info panel?

I still do not understand why Spread declaration gives the context error, in the source it is declared as an instrument property next to others like Digits and Point, which both work very well.

Re: Spread limiter

I still do not understand why Spread declaration gives the context error, in the source it is declared as an instrument property next to others like Digits and Point, which both work very well.

Spread is not included in base class "Indicator" and you cannot access it directly as Digits and Point. You can use Data.InstrProperties.Spread instead.

You can use Point directly because it is declared in Indicator class:

protected static double Point { get { return Data.InstrProperties.Point; } }

I'll also add the Spread in next releases like that:

protected static double Spread{ get { return Data.InstrProperties.Spread; } }

You can use what is better for you:
Spread gives a number as 32;
Ask - Bid gives 0.00032.

The info panel is really not updating, if chart is opened, then maybe 2-3 times with the incoming ticks the spread changes and then it freezes

Info panel updates on a new bar or when you move the mouse over the chart.

Re: Spread limiter

Ldnfx, please find the spread indi below. The first 4 logic conditions are there, increases/decreases part is very tricky for me (altough I'm interested in this also), the indi should somehow "remember" the values which come in tick by tick and then compare them to determine increase/decrease. I believe it's achievable, but I lack the knowledge and experience of doing this. 

Thank you!

Post's attachments

Spread Limiter.cs 5.98 kb, 44 downloads since 2012-06-07 

You don't have the permssions to download the attachments of this post.

Re: Spread limiter

increases/decreases part is very tricky

The problem is that Spread is not a series of values. We have only one, current value.

for (int iBar = 1; iBar < Bars; iBar++)
    showspread[iBar] = spread / point;

The code above do not make it a series. It puts last Spread value in each cell of the array.

There is not  an easy way to compare Spread values. Even we cannot compare current spread with the previous bar one.

An indicator cannot hold an array with statistics about the spread. It will be reset many times because its constructor is called in various events.

It's possible only if FST or expert collects Spread stats and indicator has access to it.

Re: Spread limiter

indi is not working. FSB doesnt see it
http://s14.postimage.org/bdr1e98kd/spread.jpg

Re: Spread limiter

ldnfx wrote:

indi is not working. FSB doesnt see it
http://s14.postimage.org/bdr1e98kd/spread.jpg

It is meant only for FST. It cannot be used with FSB, as in FSB spread is a constant value.

Re: Spread limiter

sorry for that. i'm now testing it on FST

Re: Spread limiter

footon, thank you very much for the indicator. it works perfectly well.

Re: Spread limiter

Thank you for the feedback!

Re: Spread limiter

Wow, Footon, you have been a great contributor to FSB and FST. Thanks muchly for all you have added.

My 'secret' goal is to push EA Studio until I can net 3000 pips per day....

Re: Spread limiter

I come here from the Feature Request forum of FSB.
This indicator does not make sense for FSB since FSB uses constant Spread value for the whole data series, but I can convert it in the new indicators format for FST. I'll use it  to demonstrate some new indicator parameters.

Re: Spread limiter

Popov wrote:

I come here from the Feature Request forum of FSB.
This indicator does not make sense for FSB since FSB uses constant Spread value for the whole data series, but I can convert it in the new indicators format for FST. I'll use it  to demonstrate some new indicator parameters.

I believe the request wasn't done for FSB (the requestor is advanced user of FSB and knows it can't be achieved in FSB) but for FST. This indicator in particular is for FST. FSB won't load the indi.

Indi reads this:

namespace Forex_Strategy_Trader

Miro, if you'll convert this, make sure FST's namespace is used, it's no use in FSB.

Re: Spread limiter

Blaiserboy wrote:

Wow, Footon, you have been a great contributor to FSB and FST. Thanks muchly for all you have added.

Thank you, Dave! But couple of days ago you said you didn't saw my indi corner indis until recently, now you say you're seeing the spread limiter for the first time, what have you been up to, mate? big_smile

Re: Spread limiter

Miro, if you'll convert this, make sure FST's namespace is used, it's no use in FSB.

This is the reason I choose this indicator to demonstrate the new parameters.
As I announced earlier, all new indicators are both compatible with FSB and FST. But that doesn't mean that there is no separation in functionality.

There is a new parameter: IsBacktester. This param is equal to true when the indicator works in FSB and false when works in FST.

You can see for an example: DateFilter
Date filter works only in FSB.
I'm using IsBacktester in constructor to set an warning message when indicator is started in FST.

if (IsBacktester)
   WarningMessage = "This indicator is designed to be used in the backtester only. It doesn't work in the trader.";

This warning will be visible only in FST. I cannot demonstrate that because Date Filter is internally banned in FST, but everyone can use this technique in other indicator.


Later, In Calculation method. I'm using:

if (IsBacktester)
{
    switch (IndParam.ListParam[0].Text)
    {
        case "Do not open positions after":
            for (int bar = firstBar; bar < Bars; bar++)
                if (Time[bar] < keyDate)
                    values[bar] = 1;
            break;
        ...
    }
}
else
{
    for (int bar = firstBar; bar < Bars; bar++)
        values[bar] = 1;
}

We see that the indicator calculates signals in FSB, but sets 1s for all bars in FST (Indicator confirms both direction trade).

I'll use same format but in opposite direction for Spread Limiter:
- It will be available for loading in both programs.
- It will gives reasonable signals in FST.
- It will warn that is not suitable for FSB (when loaded there)
- It will not have any effect on backtest in FSB.
- It will not be used from Generator. I'll set IsGeneratable = false; (also new param)

Why I want to use this format:
1. You never know what a user will do. It may put this indicator in FSB.
2. It will not prevent strategy written in FST with this indicator to be loaded in FSB.
3. We'll have one set of indicators for all programs.

namespace Forex_Strategy_Trader

This namespace is no longer used. We use the following namespaces for all indicators in all three programs.

using System;
using ForexStrategyBuilder.Infrastructure.Entities;
using ForexStrategyBuilder.Infrastructure.Enums;
using ForexStrategyBuilder.Infrastructure.Interfaces;

namespace ForexStrategyBuilder.Indicators.Store
{
    public class DateFilter : Indicator
    {
        ...
    }
}