Hall all, i cannot solve this problem:
i have weekly bar strategy, the strategy start the trade on monday at open; therefore I need to get on monday the open value (=to Entryprice) to calculate the stop and targets.
i cannot understand why even the expert commentary than the function Print, doesn't work until the bar is not closed, see picture, therefore i cannot save the "open" value into one variable.
I have also tried with data2 but with no success. if i put daily on data2 i cannot calculate for example: dayofweek (date of data2) = 1, to find monday and calculate open.
thanks
walter
Weekly open [SOLVED]
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: Weekly open
Have you tried using Intra-bar order generation in your strategy?i cannot understand why even the expert commentary than the function Print, doesn't work until the bar is not closed,
Btw, if your comment also applies to real-time data then I would guess this is caused by a coding issue, because in real-time you do not have to wait before the bar is closed before values of variables are updated.
Re: Weekly open
thanks for the reply, i have tried even with "bar magnifier" than with intrabarordergeneration.
if i use intrabarordergeneration the day will be multiplied by 4 in print and the strategy enter in different bar.
i think is working only with tick not with daily..
walter
if i use intrabarordergeneration the day will be multiplied by 4 in print and the strategy enter in different bar.
i think is working only with tick not with daily..
walter
- Attachments
-
- 3.png
- (194.6 KiB) Downloaded 884 times
- Andrew MultiCharts
- Posts: 1587
- Joined: 11 Oct 2011
- Has thanked: 931 times
- Been thanked: 559 times
Re: Weekly open
Hello Walter,thanks for the reply, i have tried even with "bar magnifier" than with intrabarordergeneration.
if i use intrabarordergeneration the day will be multiplied by 4 in print and the strategy enter in different bar.
i think is working only with tick not with daily..
walter
Please read how signals with/without IOG/BM are calculated.
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: Weekly open
Can you describe your problem again and provide a code example that shows it?i have weekly bar strategy, the strategy start the trade on monday at open; therefore I need to get on monday the open value (=to Entryprice) to calculate the stop and targets.
i cannot understand why even the expert commentary than the function Print, doesn't work until the bar is not closed, see picture, therefore i cannot save the "open" value into one variable.
I have no trouble trading the Monday open:
Nor are there any troubles with accessing the open value on Monday:
Code: Select all
21-7-14: Open = 1.4398
28-7-14: Open = 1.4293
4-8-14: Open = 1.4423
11-8-14: Open = 1.4452
18-8-14: Open = 1.4377
25-8-14: Open = 1.4177
1-9-14: Open = 1.4073
8-9-14: Open = 1.3833
15-9-14: Open = 1.4395
22-9-14: Open = 1.4364
Code: Select all
{
23-9-14
Forum_TradeAtMondayOpen
}
[IntrabarOrderGeneration = true];
once ClearDebug;
if (MarketPosition(0) = 0) then begin
if (DayOfWeek(DateTime) = Monday) then begin
Buy ("EL") 1 contract next bar at market;
Print(FormatDate("d-M-y", DateTime), ": Open = ", NumToStr(Open, 4));
end;
end;
if (MarketPosition(0) > 0) then begin
if (DayOfWeek(DateTime) = Friday) then
Sell ("XL") all contracts next bar at market;
end;
- Attachments
-
- scr.23-09-2014 15.22.45.png
- (5.6 KiB) Downloaded 967 times
Re: Weekly open
Thanks a lot Andrew, now the functionality is much more clear for me.
should i ask you if i can calculate only one variable on IOG?
the problem is that if i use IOG for all the code the entry is completely different because i look for close.
why i cannot use for exhample IntraBarPersist to calculate the open?
if i decide to use Data2 why i find more results for same variable?
if i ask: EP = open of data2;
i got 2 results for the same bar:
19/09/2014 0.00 95.00
19/09/2014 0.00 94.42
the first is related always to data1 and the second to data2.
thanks
should i ask you if i can calculate only one variable on IOG?
the problem is that if i use IOG for all the code the entry is completely different because i look for close.
why i cannot use for exhample IntraBarPersist to calculate the open?
if i decide to use Data2 why i find more results for same variable?
if i ask: EP = open of data2;
i got 2 results for the same bar:
19/09/2014 0.00 95.00
19/09/2014 0.00 94.42
the first is related always to data1 and the second to data2.
thanks
Re: Weekly open
maybe i have solved with this string:
if dayofweek (date of data2) = monday then EP = open of data2;
i cannot understand why if i use it, the last buy disappear from the chart...
but anyway in print still remain...
walter
if dayofweek (date of data2) = monday then EP = open of data2;
i cannot understand why if i use it, the last buy disappear from the chart...
but anyway in print still remain...
walter
- Andrew MultiCharts
- Posts: 1587
- Joined: 11 Oct 2011
- Has thanked: 931 times
- Been thanked: 559 times
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
Re: Weekly open
What happens if Monday is a holiday?maybe i have solved with this string:
if dayofweek (date of data2) = monday then EP = open of data2;
::
Re: Weekly open
you are rigth, therefore i need to do a counter of the Data2 to solve this.What happens if Monday is a holiday?maybe i have solved with this string:
if dayofweek (date of data2) = monday then EP = open of data2;
::
i will try in the next days...
w.
Re: Weekly open
Henry, this is the extracted code for you (Data 1 weekly, Data2 Dayly):Please give me the piece of code that prints the values.
Code: Select all
input: Capital (10000),LChnEn(5);
vars: TrdQty (0), Bar2 (0),MyDate (0),EP(0);
//ENTRY
if marketposition = 0 and C >= Highest(H[1],LChnEn) then begin
TrdQty = IntPortion(Capital / C );
buy ("buy CBO") TrdQty shares next bars at open ;
Bar2 = barnumber of data2;
end;
if marketposition = 1 then begin
sell ("sell CBO") TrdQty shares next bars at open;
end;
//Debug
if currentbar = 1 then cleardebug;
MyDate = datetojulian (Date of data2) ;
print (datetostring (MyDate) ," " , Barnumber of data2," " , Bar2 ," ", EP ," " );
the problem is that i cannot isolate the 1st barnumber of data2 because the main bar is weekly and is always 1.
to sole it i guess i need to invert the situation, daily for entry and weekly to calculate the channel breakout.
but the complete code is very long and complex, for this reason i was looking at this solution.
any idea?
- Attachments
-
- 1.png
- (39.34 KiB) Downloaded 874 times
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
Re: Weekly open [SOLVED]
Actually the logic is quite simple...you are rigth, therefore i need to do a counter of the Data2 to solve this.What happens if Monday is a holiday?maybe i have solved with this string:
if dayofweek (date of data2) = monday then EP = open of data2;
::
i will try in the next days...
w.
try this:
Code: Select all
if dayofweek (date) data2 < dayofweek (date[1]) data2 then ...
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
Re: Weekly open
As a practice, you should always make the fastest fractal as data1, and slower fractals as secondary datas. You will save a lot of headache in managing timing problems.::
the problem is that i cannot isolate the 1st barnumber of data2 because the main bar is weekly and is always 1.
to sole it i guess i need to invert the situation, daily for entry and weekly to calculate the channel breakout.
but the complete code is very long and complex, for this reason i was looking at this solution.
any idea?
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
Re: Weekly open
You are welcome Walter... coding is fun.TJ, you are a genius!
thank you so much, i would never thought about that simple solution....
Walter