Code: Select all
[IntrabarOrderGeneration = True];
var: Exit_Price(0) ;
if currenttime_s = 200000
then Exit_Price = Close ;
Any help is appreciated very much.
Code: Select all
[IntrabarOrderGeneration = True];
var: Exit_Price(0) ;
if currenttime_s = 200000
then Exit_Price = Close ;
not sure what you mean by: "until a new tick occurs"How to catch and hold a price at a certain time if IOG is true? The following code holds Exit_Price = 0 if no tick closes exactly at 200000. If a tick occurs – by accident – at 200000 Exit_Price holds the close of that tick until a new tick occurs. Exit_Price is then reset to 0.
Code: Select all
var:
time.check(0),
Exit_Price(0) ;
if date > date[1] then time.check = 0;
While time.check = 0
Begin
Exit_Price = Close;
if currenttime_s > 195959 then time.check = 1;
End;
still don't understand what you want.Thanks for your reply but ...
... This is what I meant with "until a new tick occurs"...
Many thanks in advance.
Code: Select all
[IntrabarOrderGeneration = True];
vars: time.check(0) ,
Exit_Price(0) ;
if time.check = 0 then Exit_Price = Close ;
if currenttime_s >= 200000 then time.check = 1 ;
WOW WOW WOW... hold the water... that's a whole new different explanation....Thank you for your effort to understand. Hope the following makes it clear:
...
... (is does not matter that it is traded a few seconds before – what matters is that it is the last traded price at 200000)....
Many thanks again.
I think there is a bug in the WHILE keyword.Thanks for your reply but unfortunately your suggested code led to crashes of MC (maybe forced by a loop within the code) - saw this never before.
Nevertheless this code would keep my problem of changing the value of Exit_Price on every new tick. This is what I meant with "until a new tick occurs". Up to now I know how to let Exit_Price get and hold the Close but only as long as no new tick (tick not bar!) shows up. This is how IOG works as I experience it.
So my question still is: How to catch the Close at a certain time AND hold it unchanged in a variable even if IOG is true and tick after tick (after that certain point in time) comes in?
Many thanks in advance.
Code: Select all
var:
time.check(0),
Exit_Price(0) ;
if date > date[1] then time.check = 0;
if time.check = 0
Begin
Exit_Price = Close;
if currenttime_s > 195959 then time.check = 1;
End;
are you using this on a daily chart !?TJ, thank you again.
Unfortunately - after serious examiniation - your last suggestion also did not work. The reason for this is the same I mentioned before: with IOG = true all vars are reset to their initial value tick by tick. So you may assign the latest close price to the variable Exit_Price but with the next occurring tick Exit_Price is first reset to 0 and - depending on the code - every new tick assigns its close price to Exit_Price. You could check it yourself and tell me if I am wrong. Thank you.
Code: Select all
//data1 and data2 in 24H format; both charts use same local time from 08:00 to 22:00
[IntrabarOrderGeneration = True];
Inputs: Exit_Time_s(200000) ;
var: hold_close(0) ;
//piranhaxp' suggestion
if date <> date[1] and time_s < Exit_Time_s then begin
hold_close = 0 ;
end ;
if time_s[1] < Exit_Time_s and time_s >= Exit_Time_s then hold_close = close[1];
//Entry Long
if date = currentdate
and OpenD(0) data2 < HighD(1) data2
then buy 1 contracts next bar OpenD(0) limit ;
//Exit at Exit_Time_s Close LMT
if marketposition > 0
and currenttime_s >= Exit_Time_s
then begin
sell all contracts next bar hold_close points limit ;
buytocover all contracts next bar hold_close points limit ;
end ;
print(File("C:\TEST1.txt"),hold_close," ",currenttime_s);
Code: Select all
//data1 and data2 in 24H format; both charts use same local time from 08:00 to 22:00
[IntrabarOrderGeneration = True];
Inputs: Exit_Time_s(200000) ;
var: hold_close(0) ;
var: todayOpen(0);
var: prevHigh(0);
var: actlimit(0);
var: todayPos(0);
prevHigh=HighD(1) data2;
todayOpen=OpenD(0);
actlimit = hold_close;
//piranhaxp' suggestion
if date <> date[1] and time_s < Exit_Time_s then begin
hold_close = 0 ;
todayPos = 0;
end ;
//Entry Long
if marketposition=0 and todayPos < 1 then begin
if todayOpen < prevHigh then begin
buy 1 contracts next bar todayOpen limit ;
end;
end;
//Exit at Exit_Time_s Close LMT
if marketposition <> 0 then begin
if time_s >= Exit_Time_s
then begin
hold_close = close[1];
todayPos=1;
sell all contracts next bar at actlimit stop ;
buytocover all contracts next bar at actlimit stop ;
end ;
end ;
SetExitOnClose;
print(File("d:\TEST1.txt"),hold_close," ",currenttime_s);
Code: Select all
[IntrabarOrderGeneration = True];
Inputs: Exit_Time_s(200000);
var: hold_close(0) ;
var: todayOpen(0);
var: prevHigh(0);
var: actlimit(0);
var: todayPos(0);
prevHigh=HighD(1) data2;
todayOpen=OpenD(0);
actlimit = hold_close;
//piranhaxp' suggestion
if date <> date[1] and time_s < Exit_Time_s then begin
hold_close = 0 ;
todayPos = 0;
end ;
//Entry Long
if marketposition=0 and todayPos < 1 then begin
if todayOpen < prevHigh then begin
buy 1 contracts next bar todayOpen limit ;
todayPos=1;
end;
end;
if marketposition <> 0 then begin
if time_s >= Exit_Time_s
then begin
hold_close = close[1];
todayPos=1;
sell all contracts next bar at actlimit stop ;
buytocover all contracts next bar at actlimit stop ;
end ;
end ;
SetExitOnClose;
print(File("d:\TEST1.txt"), date, " , ", time_s, " , ", hold_close);
Code: Select all
[IntrabarOrderGeneration = True];
Inputs: Exit_Time_s(200000);
var: hold_close(0) ;
var: todayOpen(0);
var: prevHigh(0);
var: actentrylimit(0);
var: actexitlimit(0);
var: todayPos(0);
prevHigh=HighD(1) data2;
todayOpen=OpenD(0) data2;
actentrylimit=OpenD(0);
actexitlimit = hold_close;
//piranhaxp' suggestion
if date <> date[1] and time_s < Exit_Time_s then begin
hold_close = 0 ;
todayPos = 0;
end ;
//Entry Long
if marketposition=0 and todayPos < 1 then begin
if todayOpen < prevHigh then begin
buy 1 contracts next bar actentrylimit limit ;
todayPos=1;
end;
end;
if marketposition <> 0 then begin
if time_s >= Exit_Time_s
then begin
hold_close = close[1];
todayPos=1;
sell all contracts next bar at actexitlimit stop ;
buytocover all contracts next bar at actexitlimit stop ;
end ;
end ;
SetExitOnClose;
print(File("d:\TEST1.txt"), date, " , ", time_s, " , ", hold_close);