I've created a couple of indicators by plagerizing existing indicators. I would like to create a strategy that would only be run at close of a bar let's say for the hour or 15min chart. Specifically I'm looking to play off of the weekend gap to trigger my trade. What if statement would I need to make sure my code only runs at the close of a bar?
Thanks...Dave
My First Strategy Attempt
-
- Posts: 8
- Joined: Tue Apr 15, 2008 4:31 pm
- Location: Sacramento CA
- Terranin
- Site Admin
- Posts: 833
- Joined: Sat Oct 21, 2006 4:39 pm
Re: My First Strategy Attempt
patronus wrote:I've created a couple of indicators by plagerizing existing indicators. I would like to create a strategy that would only be run at close of a bar let's say for the hour or 15min chart. Specifically I'm looking to play off of the weekend gap to trigger my trade. What if statement would I need to make sure my code only runs at the close of a bar?
Thanks...Dave
You need to set timeframe first
SetCurrencyAndTimeframe('EURUSD', PERIOD_M15);
also you need to have some global variable that will keep your previous time
var
PrevTime: TDateTime;
do not forget to initialize it in ResetStrategy procedure
then you need to write some code:
Code: Select all
if Time(0) <> PrevTime then
begin
PrevTime := Time(0);
... // here it is new bar appears
end;
Here we caught the event when new bar just appears with different time mark. So if you want to work with a bar that was closed you should use index = 1.
Hasta la vista
Mike
Mike
Who is online
Users browsing this forum: No registered users and 20 guests