Forex Factory
  • Login

  • Username: Password:
  • 8:16am

  • Search
  • Home

  • Forums

  • Trades

  • Calendar

  • News

  • Market

  • Brokers

Options

Search

Subscribe to Thread

Bookmark Thread

First Page First Unread Last Page Last Post

Printable Version

Similar Threads

Help.. Pending stop order when market price and Open price between broker requirement 5 replies

Price value compare to two EMAH/L 0 replies

Yesterdays close - todays open... 1 reply

  • Platform Tech
  • /
  • Reply to Thread

EA compare yesterdays 8pm price against todays 11am price

  • Post# 1
  • Quote
  • First Post: Apr 5, 2010 5:27am
  • RichyF
    Joined Nov 2008 | 16 Posts | Status: Member
Hi guys
Happy easter to you all
Any skilled EA programmers out there that can help with a small query?

In my EA I am trying to find out what the price was yesterday at 20:00. Then compare against the price this morning (Between 10am-12:00 midday).

Inserted Code
datetime yestdatetime = StrToTime(StringConcatenate(Year(),".",Month(),".", (Day() -1), ", 20:00"));
   offset=iBarShift(NULL,PERIOD_M5,yestdatetime,false);
   YesterdayClosePrice=iClose(NULL,PERIOD_M5,offset);
   CurrentPrice=iClose("WS30",PERIOD_M5,1);
Whilst my code seems to be working (Although a little rough, new to programming) it wont go back further than 17th March. I suspect this is a problem with iBarShift possibly?

Also I am struggling to find out what the high was for the morning period (Between 10am and 12midday).

Any ideas?

Rich
  • Post# 2
  • Quote
  • Apr 5, 2010 8:12am
  • sangmane
    Joined Apr 2009 | 634 Posts | Status: Member
PHP Code:
datetime yestdatetime = StrToTime(TimeToStr(Time[0],TIME_DATE)+" 20:00")-24*60*60;
   
offset=iBarShift(NULL,PERIOD_M5,yestdatetime,false);
   
YesterdayClosePrice=iClose(NULL,PERIOD_M5,offset);
   
CurrentPrice=iClose("WS30",PERIOD_M5,1); 
  • Post# 3
  • Quote
  • Apr 5, 2010 1:40pm
  • RichyF
    Joined Nov 2008 | 16 Posts | Status: Member
Brill, Thanks Samgmane, dont fully understand it yet but I think I am getting there.

It seems to be working but still with the same problem, my backtest only goes back 11 days. As soon as I try to backtest anything but the last 11 days I get zero figures.

I am backtesting the Dow Jones Index (Hence "WS30" as my symbol). I have checked and the data is there. However I am on a demo account.

I have set offset as a double, could it be that I need a variable that can do larger numbers?

Rich
  • Post# 4
  • Quote
  • Last Post: Apr 5, 2010 2:02pm
  • Ronald Raygun
    Joined Jul 2007 | 4,248 Posts | Status: 22 y/o Investor/Trader/Programmer
PHP Code:


double LastPrice 
= iClose(NULL, 0, iBarShift(NULL, 0, StrToTime("20:00") - 24*3600, true)); 
Thread Tools Search this Thread
Show Printable Version Show Printable Version
Email This Thread Email This Thread
Search this Thread:

Advanced Search

  • Platform Tech
  • /
  • EA compare yesterdays 8pm price against todays 11am price
  • Reply to Thread
0 traders viewing now

©2013 Forex Factory, Inc. / Terms of Use / Privacy Policy

Forex Factory® is a registered trademark.

Connect

  • Facebook
  • Twitter
  • RSS

Company

  • About FF
  • FF Blog
  • Careers at FF
  • Advertising
  • Contact FF

Products

  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer

Website

  • Homepage
  • Search
  • User Guide
  • Member List
  • Online Now
  • Report a Bug