TheNiatpac's avatar
TheNiatpac
TheNiatpac's avatar

Info

Username:TheNiatpac
Name:TheNiatpac
Member since: 03 Jun 2020

About

None

Signature

None

Last Algorithm Comments

@Currency Strength Meter (Pro) Ver2.01:  16 May 2022, 19:41


v2.02 Optimise: Indicators calculation, Displaying of Label and Code Structure;

@Currency Strength Meter (Pro) Ver1.11:  11 May 2022, 23:50


v2.01 Alt+MouseLeftClick in the chart, to turn off/on AutoSet Y-Axis viewable range; Optimise displaying of labels; Fixed bug of total spread;

@Currency Strength Meter (Pro) Ver1.11:  07 May 2022, 13:59


You can join my Telegram Group for easy discussion there. https://t.me/cTraderFXClub

@Currency Strength Meter (Pro) Ver1.11:  07 May 2022, 13:52


firemyst  Labels are shown at the end of the indicator, it's working normally also, just tick all 'Yes' on the setting page under the Label group.

@Currency Strength Meter (Pro) Ver1.11:  07 May 2022, 13:49


firemyst  It's working perfectly here. I only use it in TimeFrame 1minute(intraday) and 4minute(weekly long) You can set Y-range auto-scaled by put 0/0, to viewable range +-.  

@Currency Strength Meter (Pro) Ver1.11:  30 Apr 2022, 02:46


v1.11 Label can show or (set to 0) hide the spread sum of relevant symbols, and also displayed as pointer gap; User can adjust Y-axis Gridline gap value (0 to hide);

@Currency Strength Meter (Basic):  29 Apr 2022, 21:37


v1.11 Synchronize indicator calculation with Pro version;

@Currency Strength Meter (Pro) Ver1.10:  28 Apr 2022, 00:21


v1.10 Improve calculation and efficiency, (add 'pips-value' factor to the results according to base currency), optimise chart view settings; v1.09 Reformat marker's value (+0.0 -0.0), hide pointer when Digitals and Name both off; Y-range can be auto-arranged if set to 0/0; Y-Axis Gridline can be set off;

@Synchronized Crosshair:  25 Apr 2022, 13:31


Thanks, amusleh it works. Though the highlight on vertical and horizontal lines is a bit annoying. I believe there is no way to get rid of the highlights and keep the time value displaying, simultaneously for the moment. Anyway, the solution is good.

@Currency Strength Meter (Pro) Ver1.08:  25 Apr 2022, 12:15


v1.08  Auto-scroll to two trading hours before Reset-Time-Point;

Last Forum Posts

@ChartMouseEventArgs release Alt key not work as it suppose?:  16 May 2022, 22:47


Thanks, I decide to use Chart.MouseDown to clear the message. :)

amusleh said:

Hi,

Try Ctrl button instead of Alt:

using cAlgo.API;

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewIndicator : Indicator
    {
        private ChartStaticText tx_Rsch;

        protected override void Initialize()
        {
            tx_Rsch = Chart.DrawStaticText("Debugging", "Start Debugging..", VerticalAlignment.Bottom, HorizontalAlignment.Center, Color.FromHex("AAEEDDCC"));
            Chart.MouseMove += Chart_MouseMove;
            Chart.MouseLeave += Chart_MouseLeave;
        }

        public override void Calculate(int index)
        {
        }

        private void Chart_MouseMove(ChartMouseEventArgs obj)
        {
            tx_Rsch.Text = obj.CtrlKey ? string.Format("X: {0}  Y: {1}", obj.MouseX, obj.MouseY) : string.Empty;
        }

        private void Chart_MouseLeave(ChartMouseEventArgs obj)
        {
            tx_Rsch.Text = string.Empty;
        }
    }
}

Alt pauses the indicator event loop until you click somewhere or press another keyboard key.

@ChartMouseEventArgs release Alt key not work as it suppose?:  14 May 2022, 23:44


Hello,

I have the below code, which is supposed to display Mouse X, Y values when I was moving the mouse with Alt pressed in the chart area. And release Alt, moving the mouse should make the message disappear.

The message appearing with Alt pressed has no problem. However, when I release the Alt key, the message does not always disappear, esp. when I stopped moving the mouse and then release the Alt key, even if the mouse moves again, the message stays still. Can you explain and help optimise the coding?

BTW, when I activate another window e.g. visual studio and move the mouse back to the chart with this indicator, releasing Alt did make the message disappear every time. But, by clicking the chart to activate cTrader window, the problem back again. It is strange, isn't it?

Thanks.

using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewIndicator : Indicator
    {
    
        private ChartStaticText tx_Rsch;

        protected override void Initialize()
        {
            tx_Rsch = Chart.DrawStaticText("Debugging", "Start Debugging..", VerticalAlignment.Bottom, HorizontalAlignment.Center, Color.FromHex("AAEEDDCC"));
            Chart.MouseMove += Chart_MouseMove;
        }

        public override void Calculate(int index)
        {
        }
        
        
        private void Chart_MouseMove(ChartMouseEventArgs obj)
        {   
            if      (  obj.AltKey ) { tx_Rsch.Text = string.Format("X: {0}  Y: {1}", obj.MouseX, obj.MouseY); }
            else if ( !obj.AltKey ) { tx_Rsch.Text = ""; } 
        }
        
    }

}

@cBots loading other Symbols' Bars causes CPU in usage even nothing run OnTick() ?:  09 May 2022, 11:50


Thanks for your reply. Your explanation makes sense.

Interestingly, I found if I minimize the window, the CPU usage gets back to a normal level, when cBots keeps on. Anyway, it's not a big issue. 

Thanks again.

amusleh said:

Hi,

CPU usage can be related to lots of things, and you can't micro manage it.

When you load the bars of multiple symbols it subscribes to their incoming bars and that can increase slightly the CPU usage even if market is closed.

The cTrader CPU usage on Task manager is not just the amount of CPU cycles that is used by your cBot.

@ChartObjectsUpdatedEventArgs How can I get Y value from a Horizental Line?:  08 May 2022, 00:55


I have resolved this problem by bringing another method to return the Y-value.

        private double HLineYValue(string s_HLineNm) //Return HorizentalLine's Y-Value by HorizentalLine'sName
        {
            var hLines = Chart.FindAllObjects(ChartObjectType.HorizontalLine);
            foreach (ChartHorizontalLine hline in hLines) { if (hline.Name == s_HLineNm) { return hline.Y; } } 
            return 0;
        }

TheNiatpac said:

Hello,

I use the below event to detect if a HorizentalLine has been modified. And the code can easily get horizentalLine's name, but how can I get the Y value of the modified horizentalLine?

The code below,  horizentalLine.Y.ToString("0.0") report error.

Thanks, if any advice.

        private void Chart_ObjectsModified(ChartObjectsUpdatedEventArgs obj)
        {
            var horizentalLine = obj.ChartObjects.FirstOrDefault(iObject => iObject.ObjectType == ChartObjectType.HorizontalLine);
            if (horizentalLine != null) 
            {
                Print("Found object with name {0}, Y-Value: {1}", horizentalLine.Name, horizentalLine.Y.ToString("0.0");
            }
        }

@Synchronized Zooming:  08 May 2022, 00:52


Thanks, I look forward to having this indicator. :)

amusleh said:

Hi,

We will consider developing such an indicator.

@cBots loading other Symbols' Bars causes CPU in usage even nothing run OnTick() ?:  08 May 2022, 00:37


Hello, 

I have the below code which my cBots need to load other symbols' data OnStart(), and no lines OnTick(). However...

I found my CPU is in steady high (not bursting) usage when I launched 2 cBots in different charts, even when the market is closed. After taking out other lines of the codes, I found that loading other symbols data might be the reason. See below 2 screen chops of comparison. (My CPU is a bit old i7 7th generation, but not the reason causing the issue.)

Can you confirm my guess, and advise any optimising method to reduce CPU usage?

Thanks in advance.

P.S. the test is in TimeFrame.Minute

using System;
using cAlgo.API;
using cAlgo.API.Internals;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class TestGroupA : Robot
    {
        [Parameter("Reset Date",    DefaultValue = "2022-05-06",    Group = "Alignment"     )] public string ResetDate  { get; set; }
        [Parameter("Reset Time",    DefaultValue = "04:29:00",      Group = "Alignment"     )] public string ResetTime  { get; set; }

        //Bars to load for Calculate 
        private Bars EURUSD, EURGBP, EURAUD, EURNZD, EURCAD, EURCHF, EURJPY;        
        private Bars GBPUSD,         GBPAUD, GBPNZD, GBPCAD, GBPCHF, GBPJPY;
        private Bars AUDUSD,                 AUDNZD, AUDCAD, AUDCHF, AUDJPY;
        private Bars NZDUSD,                         NZDCAD, NZDCHF, NZDJPY;
        private Bars USDCAD,                                 CADCHF, CADJPY;
        private Bars USDCHF,                                         CHFJPY;
        private Bars USDJPY;

        //Index at OpenTime of LastBar of EachSymbol;
        private int in_EURUSD, in_EURGBP, in_EURAUD, in_EURNZD, in_EURCAD, in_EURCHF, in_EURJPY;
        private int in_GBPUSD,            in_GBPAUD, in_GBPNZD, in_GBPCAD, in_GBPCHF, in_GBPJPY;
        private int in_AUDUSD,                       in_AUDNZD, in_AUDCAD, in_AUDCHF, in_AUDJPY;
        private int in_NZDUSD,                                  in_NZDCAD, in_NZDCHF, in_NZDJPY;
        private int in_USDCAD,                                             in_CADCHF, in_CADJPY;
        private int in_USDCHF,                                                        in_CHFJPY;
        private int in_USDJPY;


        protected override void OnStart()
        {
        //1.GetBars for EachSymbol 
            EURUSD = MarketData.GetBars(Bars.TimeFrame, "EURUSD");  GBPUSD = MarketData.GetBars(Bars.TimeFrame, "GBPUSD");  AUDUSD = MarketData.GetBars(Bars.TimeFrame, "AUDUSD");  NZDUSD = MarketData.GetBars(Bars.TimeFrame, "NZDUSD");
            EURGBP = MarketData.GetBars(Bars.TimeFrame, "EURGBP");  GBPAUD = MarketData.GetBars(Bars.TimeFrame, "GBPAUD");  AUDNZD = MarketData.GetBars(Bars.TimeFrame, "AUDNZD");  NZDCAD = MarketData.GetBars(Bars.TimeFrame, "NZDCAD");
            EURAUD = MarketData.GetBars(Bars.TimeFrame, "EURAUD");  GBPNZD = MarketData.GetBars(Bars.TimeFrame, "GBPNZD");  AUDCAD = MarketData.GetBars(Bars.TimeFrame, "AUDCAD");  NZDCHF = MarketData.GetBars(Bars.TimeFrame, "NZDCHF");
            EURNZD = MarketData.GetBars(Bars.TimeFrame, "EURNZD");  GBPCAD = MarketData.GetBars(Bars.TimeFrame, "GBPCAD");  AUDCHF = MarketData.GetBars(Bars.TimeFrame, "AUDCHF");  NZDJPY = MarketData.GetBars(Bars.TimeFrame, "NZDJPY");
            EURCAD = MarketData.GetBars(Bars.TimeFrame, "EURCAD");  GBPCHF = MarketData.GetBars(Bars.TimeFrame, "GBPCHF");  AUDJPY = MarketData.GetBars(Bars.TimeFrame, "AUDJPY");  
            EURCHF = MarketData.GetBars(Bars.TimeFrame, "EURCHF");  GBPJPY = MarketData.GetBars(Bars.TimeFrame, "GBPJPY");                                                          USDCAD = MarketData.GetBars(Bars.TimeFrame, "USDCAD");
            EURJPY = MarketData.GetBars(Bars.TimeFrame, "EURJPY");                                                          USDCHF = MarketData.GetBars(Bars.TimeFrame, "USDCHF");  CADCHF = MarketData.GetBars(Bars.TimeFrame, "CADCHF");
                                                                    USDJPY = MarketData.GetBars(Bars.TimeFrame, "USDJPY");  CHFJPY = MarketData.GetBars(Bars.TimeFrame, "CHFJPY");  CADJPY = MarketData.GetBars(Bars.TimeFrame, "CADJPY");

        //2.Get Index# for EachSymbol at Reset-DateTime 
            DateTime dateTime = DateTime.Parse(ResetDate + " " + ResetTime).Add(-Application.UserTimeOffset); //Convert to ServerTime

            in_EURUSD = EURUSD.OpenTimes.GetIndexByTime(dateTime);  in_GBPUSD = GBPUSD.OpenTimes.GetIndexByTime(dateTime);  in_AUDUSD = AUDUSD.OpenTimes.GetIndexByTime(dateTime);  in_NZDUSD = NZDUSD.OpenTimes.GetIndexByTime(dateTime);
            in_EURGBP = EURGBP.OpenTimes.GetIndexByTime(dateTime);  in_GBPAUD = GBPAUD.OpenTimes.GetIndexByTime(dateTime);  in_AUDCAD = AUDCAD.OpenTimes.GetIndexByTime(dateTime);  in_NZDCAD = NZDCAD.OpenTimes.GetIndexByTime(dateTime);
            in_EURAUD = EURAUD.OpenTimes.GetIndexByTime(dateTime);  in_GBPCAD = GBPCAD.OpenTimes.GetIndexByTime(dateTime);  in_AUDNZD = AUDNZD.OpenTimes.GetIndexByTime(dateTime);  in_NZDCHF = NZDCHF.OpenTimes.GetIndexByTime(dateTime);
            in_EURCAD = EURCAD.OpenTimes.GetIndexByTime(dateTime);  in_GBPNZD = GBPNZD.OpenTimes.GetIndexByTime(dateTime);  in_AUDCHF = AUDCHF.OpenTimes.GetIndexByTime(dateTime);  in_NZDJPY = NZDJPY.OpenTimes.GetIndexByTime(dateTime);
            in_EURNZD = EURNZD.OpenTimes.GetIndexByTime(dateTime);  in_GBPCHF = GBPCHF.OpenTimes.GetIndexByTime(dateTime);  in_AUDJPY = AUDJPY.OpenTimes.GetIndexByTime(dateTime);
            in_EURCHF = EURCHF.OpenTimes.GetIndexByTime(dateTime);  in_GBPJPY = GBPJPY.OpenTimes.GetIndexByTime(dateTime);                                                          in_USDCAD = USDCAD.OpenTimes.GetIndexByTime(dateTime);
            in_EURJPY = EURJPY.OpenTimes.GetIndexByTime(dateTime);                                                          in_USDCHF = USDCHF.OpenTimes.GetIndexByTime(dateTime);  in_CADCHF = CADCHF.OpenTimes.GetIndexByTime(dateTime);
                                                                    in_USDJPY = USDJPY.OpenTimes.GetIndexByTime(dateTime);  in_CHFJPY = CHFJPY.OpenTimes.GetIndexByTime(dateTime);  in_CADJPY = CADJPY.OpenTimes.GetIndexByTime(dateTime);

        //Debugging:
            string msg  = string.Format("At the Reset-DateTime: {0}", dateTime.Add(Application.UserTimeOffset).ToString("yyyy-MM-dd HH:mm:ss"));
            msg += string.Format("\nEURUSD's Index#: {0}", in_EURUSD);
            msg += string.Format("\nGBPUSD's Index#: {0}", in_GBPUSD);
            msg += string.Format("\n\nCPU is 12% used, even no calculation OnTick()...?");
            Chart.DrawStaticText("msg", msg, VerticalAlignment.Bottom, HorizontalAlignment.Center, Color.Aquamarine);
        //Debugging END

        }

        protected override void OnTick()
        {

        }

        protected override void OnStop()
        {

        }

    }

}

@ChartObjectsUpdatedEventArgs How can I get Y value from a Horizental Line?:  06 May 2022, 18:57


Hello,

I use the below event to detect if a HorizentalLine has been modified. And the code can easily get horizentalLine's name, but how can I get the Y value of the modified horizentalLine?

The code below,  horizentalLine.Y.ToString("0.0") report error.

Thanks, if any advice.

        private void Chart_ObjectsModified(ChartObjectsUpdatedEventArgs obj)
        {
            var horizentalLine = obj.ChartObjects.FirstOrDefault(iObject => iObject.ObjectType == ChartObjectType.HorizontalLine);
            if (horizentalLine != null) 
            {
                Print("Found object with name {0}, Y-Value: {1}", horizentalLine.Name, horizentalLine.Y.ToString("0.0");
            }
        }

@Synchronized Zooming:  05 May 2022, 18:47


Hello, 

We have Synchronized Scrolling and Synchronized Crosshair as the customised indicator, thanks to Spotware developers. :)

Can we also have a Synchronized Zooming indicator?

Thanks,

@Chart.ZoomLevel dis Chart.ScrollXTo ?:  02 May 2022, 13:14


OK, thanks. Though it's not a big issue.

amusleh said:

Hi,

It works fine, sometimes ScrollXTo and ZoomLevel can cause chart reload due to lack of data, and that will re-initialize your indicator.

Notifications only work on live environment, not in back test.

@Chart.ZoomLevel dis Chart.ScrollXTo ?:  30 Apr 2022, 22:54


Hi,

I encountered an interesting problem. One of my indicators needs to set the chart zoom level and Scroll bar a bit in the initialize(). The code works fine, when I switch TimeFrames away from the gap of Tick500 to Tick300, i.e. Tick300->Tick250 or to smaller.  Tick500->Tick750 or larger, both scenarios are fine.

BUT, when the TimeFrame switch from Tick500->Tick300, the Chart.ScrollXTo doesn't work. And... Tick300->Tick500, the Chart.ZoomLevel seems 'destroyed' Chart.ScrollXTo. 

I guess ScrollXTo is always operated before Chart.ZoomLevel change, no matter where I put the code before or after ZoomLevel change?

        protected override void Initialize()
        {
            //Chart.ScrollXTo(Chart.FirstVisibleBarIndex - 5);

            if      (TimeFrame >= TimeFrame.Tick500) { Chart.ZoomLevel = 35; }
            else if (TimeFrame  < TimeFrame.Tick500) { Chart.ZoomLevel = 20; }

            Chart.ScrollXTo(Chart.FirstVisibleBarIndex - 5);

            Notifications.SendEmail("123@hotmail.com", "456@coldmail.com", "USD MORE Active" , "No Content"));
        }

P.S. One little more question, if I put 'Notification.SendEmail' in the indicator's Initialize(), will the mail be sent? I checked the reference says Notification won't work in backtesting, but didn't mention about indicator Initialize(). 

Please help, much appreciated if any advice.

Thanks. :)

Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.
free  18 May 2022
Group A / B to display 8 major currencies' strengths; Import and display Economic Calendar's Key Events; Align all indicators at a setting DateTime (Reset-Time-Point); Shift+click scrolling to 15 minutes ahead of Reset-Time-Point; Ctrl+click reset viewable Y-Range as settings; Labels can display or hide Total Spread, Indicator Name and Value; Apply to only TimeFrame by time; Require access to your local file system.   Updates: (full logs please see source code) v2.02 Optimise: Indicators calculation, Displaying of Label and Code Structure;   Notes: Recommend USDJPY as BaseBar in the chart;  Zoom to 5% for TimeFrame.1Minute as an intraday view, 4Minute for one week view; Make sure to fill Reset-Time-Point within 1 or 2 days for an intraday view, within 5-10 days for one week view; Economic KeyEvent's txt file in (GMT+1) time can be downloaded every week from the pinned message at Telegram Group: cTrader FOREX Club, you may find it very easy to modify by yourself; If you use the group function to display indicators in 2 or more charts, highly recommend downloading Synchronized Crosshair ,  Synchronized Scrolling to work together. Both indicators are made by Spotware .   Screenshots: This is a typical setting for intraday use (never mind about the background colour, it's another indicator's performance): Where you can set file path for economic key events: Don't forget to set a point of 'Reset Date-Time', and  adjust the viewable range when the market moves out of default setting: Labels can display Total Spread, Indicator Name and Value, and hide them all by turning the 3 settings off. Have Fun!
free  18 May 2022
The file is named 'Currency Strength Value' Group A / B to display 8 major currencies' strengths; Align all indicators at a setting DateTime (Reset-Time-Point); Apply to only TimeFrame by time; Pro version is now available.  Notes: Recommend USDJPY as BaseBar in the chart;  Zoom to 5% for TimeFrame.1Minute as an intraday view, 4Minute for one week view; Make sure to fill Reset-Time-Point within 1 or 2 days for an intraday view, within 5-10 days for one week view;  
Warning! Executing cBots downloaded from this section may result in loss of funds. Use them at your own risk.

No uploaded.