Period Converter / Offline Charts and USD EUR Index
Results 1 to 2 of 2

Thread: Period Converter / Offline Charts and USD EUR Index

  1. #1
    I'd like to make an offline chart of numerous distinct principal currency indices. I don't like how all of the current currency strength meter work with moving averages,are weighted or are based around the 100 worth.

    Therefor I compute the actual worth of almost any major currencies like this:

    Inserted Code /* 1 haphazard Currency is going to be defined with the value 1. * predefine variables */ EUR = 1; USD = 1/iClose(EURUSD,Stage (),I); // USD/EUR * 1 EUR = USD CHF = 1/iClose(USDCHF,Period(),I) * USD; // CHF/USD * 1 USD = CHF GBP = 1/iClose(EURGBP,Period(),I); The benefit now is, that every currency pair can be calculated by simply dividing the 2 corresponding values but currently the EUR is capped at 1 so I calculated the relative value.

    Inserted Code // EUR rel = EUR / EUR USD CHF GBP lt;=gt; 1 / (USD CHF GBP) // USD rel = USD / EUR USD CHF GBP lt;=gt; 1 / (EUR CHF GBP) basket= EUR USD CHF GBP; EURRel#91;I#93; = EUR/basket; USDRel#91;I#93; = USD/basket; CHFRel#91;I#93; = CHF/basket; GBPRel#91;I#93; = GBP/basket;
    Creating an indior that shows these values isn't enough since the changes Aren't large enough to be observable. But if we produce an offline chart we can observe the movement as well as the tendencies of the underlying currency and use this to ascertain the trend of our pairs.

    This is the first time I'm using the FileOpenHistory Function. I tried to change the time converter to make a 1 minute offline chart based on these calculations but I got a Background Base error.

    Because we don't have tick worth of all of the currencies we don't get 100% accurate historic candles (low and higher value) but since I'm trading on higher timeframes it does not matter for me. Once I made a 1 minute offlinechart I am just going to utilize the interval converter convert it into an hourly chart and everything will be fine.

    For Your 1 minute timeframe we have to accept that we simply know the open and close of the bars.

    Inserted Code int barsMin = MathMin(MathMin(iBars(EURUSD,Period()),iBars(USDCH F,Stage ())),iBars(EURGBP,Stage ())); start_pos=barsMin-1; double low(int shift) return (MathMin(close(shift),open(shift))); dual high(int shift) return (MathMax(close(shift),open(shift))); double open(int shift) USD = 1/iOpen(EURUSD,Period(),shift); CHF = 1/iOpen(USDCHF,Period(),shift) * USD; GBP = 1/iOpen(EURGBP,Period(),shift); basket= EUR USD CHF GBP; return (EUR/basket); double close(int shift) USD = 1/iClose(EURUSD,Period(),shift); CHF = 1/iClose(USDCHF,Period(),shift) * USD; GBP = 1/iClose(EURGBP,Period(),shift); basket= EUR USD CHF GBP; return (EUR/basket); double quantity (int shift) USD = 1/iVolume(EURUSD,Period(),shift); CHF = 1/iVolume(USDCHF,Period(),shift) * USD; GBP = 1/iVolume(EURGBP,Period(),shift); basket= EUR USD CHF GBP; return(EUR/basket);
    Cann somebody please take a peek and tell me why this script Isn't working? I tried to be careful when changing the interval converter.
    https://www.nigeriaforextrading.com/...2352869715.mq4

  2. #2
    Breaking the issue down. I am not able to create a single legitimate bar. Here's the simplest code I can write but it outputs the same error. Where is my error?

    Inserted Code #property indior_chart_window #property copyright // ------------------------------------------------------------------ #include lt;WinUser32.mqhgt; #include lt;stdlib.mqhgt; // ------------------------------------------------------------------ #import user32.dll int RegisterWindowMessageA(string lpString); #import // ------------------------------------------------------------------ extern int TimeFrame = 2; extern bool EmulateOnLineChart = true; extern bool StrangeSymbolName = false; // ------------------------------------------------------------------ int HstHandle = -1, LastFPos = 0, MT4InternalMsg = 0; string SymbolName; double EUR,USD,CHF,GBP,basket; // ------------------------------------------------------------------ void UpdateChartWindow() static int hwnd = 0; if(hwnd == 0) hwnd = WindowHandle(SymbolName, TimeFrame); if(hwnd! = 0) Print(Chart window found ); if(EmulateOnLineChart MT4InternalMsg == 0) MT4InternalMsg = RegisterWindowMessageA(MetaTrader4_Internal_Messag e); if(hwnd! = 0) if(PostMessageA(hwnd, WM_COMMAND, 0x822c, 0) == 0) hwnd = 0if(hwnd! = 0 MT4InternalMsg ! = 0) PostMessageA(hwnd, MT4InternalMsg, 2, 1); return; int init() return (0); // ------------------------------------------------------------------ int start() static double BoxPoints, UpWick, DnWick; static double PrevLow, PrevHigh, PrevOpen, PrevClose, CurVolume, CurLow, CurHigh, CurOpen, CurClose; static datetime PrevTime; // ------------------------------------------------------------------ // This can be simply executed ones, and then the very first tick arives. if(HstHandle lt; 0) FILE_WRITE); if(HstHandle lt; 0) Print(Error: can't create / open history file: ErrorDescription(GetLastError()) : SymbolName TimeFrame .hst); return(-1); // // write hst file header int HstUnused#91;13#93;; FileWriteInteger(HstHandle, 400, LONG_VALUE); // Version FileWriteString(HstHandle,, 64);// Copyright FileWriteString(HstHandle, SymbolName, 12);// Symbol FileWriteInteger(HstHandle, TimeFrame, LONG_VALUE);// Stage FileWriteInteger(HstHandle, Digits, LONG_VALUE);// Digits FileWriteInteger(HstHandle, 0, LONG_VALUE);// Time Sign FileWriteInteger(HstHandle, 0, LONG_VALUE);// Last Sync FileWriteArray(HstHandle, HstUnused, 0, 13);// Unused // // process historical data int I = Bars-2; //--------------------------------------------------------------------------- while(I gt; Bars-3) // update low before high or the reverse depending on preceding bar PrevHigh = 1; PrevLow = 0; PrevOpen = 1; PrevClose = 0; PrevTime = Time#91;I#93;; CurVolume = 4; FileWriteInteger(HstHandle, PrevTime, LONG_VALUE); FileWriteDouble(HstHandle, PrevOpen, DOUBLE_VALUE); FileWriteDouble(HstHandle, PrevLow, DOUBLE_VALUE); FileWriteDouble(HstHandle, PrevHigh, DOUBLE_VALUE); FileWriteDouble(HstHandle, PrevClose, DOUBLE_VALUE); FileWriteDouble(HstHandle, CurVolume, DOUBLE_VALUE); FileFlush(HstHandle); I--; return(0); // End historical data / Init //---------------------------------------------------------------------------- // HstHandle not lt; 0 so we constantly enter here after history done // Begin live data feed FileSeek(HstHandle, LastFPos, SEEK_SET); return(0); // ------------------------------------------------------------------ int deinit() if(HstHandle gt;= 0) FileClose(HstHandle); HstHandle = -1; Opinion (); return(0); // ------------------------------------------------------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners.