- Joined
- 31 May 2015
- Posts
- 17
- Reactions
- 0
FirstBar = DateNum() != Ref(DateNum(),-1);
FirstHigh = ValueWhen(FirstBar ,H);
I'm trying to get HHV of first 5 bars of the day on EUR/USD (timeframe 1 H). I know how to get the first bar of the day and value for first high:
Code:FirstBar = DateNum() != Ref(DateNum(),-1); FirstHigh = ValueWhen(FirstBar ,H);
but don't know how to get HHV of first 5 bars. Thanks for prompt.
bars = 5;
dn = DateNum();
newday = dn != Ref(dn,-1);
FirstHigh = ValueWhen( Barssince( newday ) == bars-1, HHV( H, bars ) );
Plot( C, "Price", colorDefault, styleCandle, Null, Null, 0, 1 );
Plot( FirstHigh, "HHV" + bars, colorGreen, styleStaircase | styleDashed, Null, Null, 0, 1 );
Code:bars = 5; dn = DateNum(); newday = dn != Ref(dn,-1); FirstHigh = ValueWhen( Barssince( newday ) == bars-1, HHV( H, bars ) ); Plot( C, "Price", colorDefault, styleCandle, Null, Null, 0, 1 ); Plot( FirstHigh, "HHV" + bars, colorGreen, styleStaircase | styleDashed, Null, Null, 0, 1 );
trash (or anyone else),
Would you be interested in a small job? Will pay (small) fee. Uses AHK (AutoHotKey macro software).
I've done half of it but got stuck. Involves getting orders into TWS from a csv file.
Why AHK?
Just use Amibroker's IBcontroller.
Hey,
IBcontroller doesn't let you create conditional orders.
Yes, you can but rather read from TWS API docs http://i.imgur.com/42UM2KV.png
You have to monitor on your end.
SetTradeDelays(0,0,0,0);
bars= 10;
firstBar = DateNum() != Ref(DateNum(),-1);
max_from_bars = ValueWhen(BarsSince(firstBar)==bars-1, HHV(H,bars));
min_from_bars = ValueWhen(BarsSince(firstBar)==bars-1, LLV(L,bars));
range = max_from_bars - min_from_bars;
Buy = H > max_from_bars AND BarsSince(firstBar)>=bars ;
Sell = L < min_from_bars OR H >= max_from_bars+range;
Short = L < min_from_bars AND BarsSince(firstBar)>=bars;
Cover = H > max_from_bars OR L <= min_from_bars-range;
BuyPrice = Max(O,max_from_bars);
SellPrice = 0;
ShortPrice = Min(O,min_from_bars);
CoverPrice = 0;
ApplyStop(stopTypeProfit,stopModePoint,range);
ApplyStop(stopTypeLoss,stopModePoint,range);
Do you know ValueWhen references the future and is therefore misleading in backtesting?I implemented simple breakout from range (from first 10 bars during a day) as below and try to add break even (after reaching 20% of target) to the code but I don't know if it is possible without using loops. Thanks for prompt
Do you know ValueWhen references the future and is therefore misleading in backtesting?
Not necessarily. Valuewhen can reference historical data.
Do you know ValueWhen references the future and is therefore misleading in backtesting?
Yes in this case it defaults to n = 1.
Firstbar = any day other than yesterday (random day)
ValueWhen BarsSince Firstbar is equivalent to 9 (any bar 9 days from random day), returns the HHV(H, 10), most recently (1)
Is not ---- Ref(HHV(H, 10), -1); the same?
bars = 5;
dn = DateNum();
newday = dn != Ref(dn,-1);
FirstHigh = ValueWhen( Barssince( newday ) == bars-1, HHV( H, bars ) );
bars = 5;
mth = Month();
newmonth = mth != Ref(mth,-1);
FirstHigh = ValueWhen( Barssince( newmonth ) == bars-1, HHV( H, bars ) );
Plot( C, "Price", colorDefault, styleCandle, Null, Null, 0, 1 );
Plot( FirstHigh, "HHV" + bars, colorGreen, styleStaircase | styleDashed, Null, Null, 0, 1 );
SetTradeDelays(0,0,0,0);
bars= 10;
firstBar = DateNum() != Ref(DateNum(),-1);
max_from_bars = ValueWhen(BarsSince(firstBar)==bars-1, HHV(H,bars));
min_from_bars = ValueWhen(BarsSince(firstBar)==bars-1, LLV(L,bars));
range = max_from_bars - min_from_bars;
Buy = H > max_from_bars AND BarsSince(firstBar)>=bars ;
Sell = L < min_from_bars OR H >= max_from_bars+range;
Short = L < min_from_bars AND BarsSince(firstBar)>=bars;
Cover = H > max_from_bars OR L <= min_from_bars-range;
BuyPrice = Max(O,max_from_bars);
SellPrice = 0;
ShortPrice = Min(O,min_from_bars);
CoverPrice = 0;
ApplyStop(stopTypeProfit,stopModePoint,range);
ApplyStop(stopTypeLoss,stopModePoint,range);
As far as I know you should use daily time frame to test and use:Some help please.
I'm testing on a weekly time frame.
I want to ensure my Buyprice <=H and >=L on a daily time frame.
I've tried priceboundcheck and TimeFrameSet(InDaily), but no luck.
As far as I know you should use daily time frame to test and use:
TimeFrameSet(inWeekly);
//your calculations
TimeFrameRestore();
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?