1 registered members (SBGuy),
652
guests, and 3
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Need help with this
[Re: jcl]
#454595
09/11/15 10:15
09/11/15 10:15
|
Joined: Jun 2015
Posts: 6
Alessio
OP
Newbie
|
OP
Newbie
Joined: Jun 2015
Posts: 6
|
|
|
|
Re: Need help with this
[Re: Alessio]
#454683
09/14/15 17:23
09/14/15 17:23
|
Joined: Sep 2015
Posts: 8
Toronado
Newbie
|
Newbie
Joined: Sep 2015
Posts: 8
|
Alessio, jcl, I decided to sketch this out to help my learning. Posted here for anyone reading back. This now charts the price movements and, I think, shows that it doesn't trade because the conditions are never met:
function run ()
{
//no trade costs...
BarPeriod = 5;
Spread = 0;
Slippage = 0;
RollLong = RollShort = 0;
vars Price = series(priceClose());
var HighC = MaxVal(Price,6);
var LowC = MinVal(Price,6);
var PriceRange = (priceHigh()-priceLow());
var BuyStop = priceClose() + 1*PIP;
var SellStop = priceLow() - 1*PIP;
TakeProfit = 150*PIP;
Stop = 200*PIP;
if (Price[0] > (HighC + PriceRange))
enterLong(1,BuyStop, TakeProfit, Stop);
if (Price[0] < (LowC - PriceRange))
enterShort(1,SellStop);
plot("HighC", HighC + PriceRange, MAIN, GREEN);
plot("LowC", LowC - PriceRange, MAIN, RED);
set(PLOTNOW+PLOTLONG);
}
Changing the conditions for a trade confirms this:
var priceTrigger = PriceRange / 2;
if (Price[0] >= (HighC + priceTrigger))
enterLong(1,BuyStop, TakeProfit, Stop);
if (Price[0] <= (LowC - priceTrigger))
enterShort(1,SellStop);
That changes the trigger condition to a smaller distance and this causes the strategy to trade infrequently at a loss (in my tests).
Last edited by Toronado; 09/14/15 17:28.
|
|
|
|