Description
You can find the pip value for any lotsize for 8 major currencies. and 28 pairs.
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
using System.Threading;
using cAlgo.Properties;
namespace cAlgo
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
public class PipValue : Indicator
{
[Parameter("Lotsize", DefaultValue = 0.01, MinValue = 0.01)]
public double _Lot { get; set; }
double EURUSD;
double GBPUSD;
double AUDUSD;
double NZDUSD;
double USDCAD;
double USDCHF;
double USDJPY;
Form1pips form_ = new Form1pips();
Thread thread_;
protected override void Initialize()
{
// Initialize and create nested indicators
EURUSD = MarketData.GetBars(TimeFrame, "EURUSD").ClosePrices.LastValue;
GBPUSD = MarketData.GetBars(TimeFrame, "GBPUSD").ClosePrices.LastValue;
AUDUSD = MarketData.GetBars(TimeFrame, "AUDUSD").ClosePrices.LastValue;
NZDUSD = MarketData.GetBars(TimeFrame, "NZDUSD").ClosePrices.LastValue;
USDCAD = MarketData.GetBars(TimeFrame, "USDCAD").ClosePrices.LastValue;
USDCHF = MarketData.GetBars(TimeFrame, "USDCHF").ClosePrices.LastValue;
USDJPY = MarketData.GetBars(TimeFrame, "USDJPY").ClosePrices.LastValue;
double price = _Lot * 10;
double priceJPY = _Lot * 1000;
thread_ = new Thread(() => form_.ShowDialog());
thread_.SetApartmentState(ApartmentState.STA);
thread_.Start();
form_.lotsize_pipvalue.Text = _Lot.ToString();
form_.gbp_pipValue.Text = "$" + Math.Round(price * GBPUSD, 2).ToString();
form_.aud_pipValue.Text = "$" + Math.Round(price * AUDUSD, 2).ToString();
form_.nzd_pipValue.Text = "$" + Math.Round(price * NZDUSD, 2).ToString();
form_.usd_pipValue.Text = "$" + Math.Round(price, 2).ToString();
form_.cad_pipValue.Text = "$" + Math.Round(price / USDCAD, 2).ToString();
form_.chf_pipValue.Text = "$" + Math.Round(price / USDCHF, 2).ToString();
form_.jpy_pipValue.Text = "$" + Math.Round(priceJPY / USDJPY, 2).ToString();
if (Settings.Default["form"] != null)
{
((Form1pips)Settings.Default["form"]).Close();
}
Settings.Default["form"] = form_;
Print(" form: " + Settings.Default["form"].ToString());
}
public override void Calculate(int index)
{
// Calculate value at specified index
// Result[index] = ...
}
}
}
ZuniSoft
Joined on 11.03.2019
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: Pip Value.algo
- Rating: 0
- Installs: 2003
- Modified: 13/10/2021 09:54
Note that publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section, please use the Copyright Infringement Notification form to submit a claim.
Comments
Log in to add a comment.
Hi
with this code you assume that you have USD Account, but it also possible having other Account or other currency account. May you update reading Account currency ?