Description
This bot was created for the purpose of confirming manual trading with past data by BackTest in visual mode, but it can also be used for real trading.
//This bot was created for the purpose of confirming manual trading with past data by BackTest, but it can also be used for real trading.
//
//<<<<< Entry >>>>>
// Buy : Shift + Left Mouse
// Sell: Ctrl + Left Mouse
//
//<<<<< Close >>>>>
// We will close Profit / Loss as you set or at any time.
//
// Only profit positions : Alt + Shift + Left Mouse
// Only Loss positions : Alt + Ctrl + Left Mouse
// All positions : Alt + Shift + Ctrl + Left Mouse
//
using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
namespace cAlgo
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class SimpleKeyEntry : Robot
{
private const string HowToUseText = "<<<<< Entry >>>>>\n Buy: Shift + Left Mouse\n Sell:Ctrl + Left Mouse\n\n <<<<< Close >>>>>\n Only profit positions : Alt + Shift + Left Mouse \n Only Loss positions : Alt + Ctrl + Left Mouse \n All positions: Alt + Shift + Ctrl + Left Mouse\n";
[Parameter("Stop Loss (pips)", Group = "Protection", DefaultValue = 30, MinValue = 1)]
public int StopLossPips { get; set; }
[Parameter("Take Profit (pips)", Group = "Protection", DefaultValue = 30, MinValue = 1)]
public int TakeProfitPips { get; set; }
[Parameter("Volume", Group = "Volume", DefaultValue = 10000, MinValue = 0, Step = 1)]
public double Volume { get; set; }
private string label = "SimpleKeyEntry";
protected override void OnStart()
{
Chart.MouseDown += onChartMouseDown;
howToUseText();
}
private void howToUseText()
{
Chart.DrawStaticText(label, HowToUseText, VerticalAlignment.Bottom, HorizontalAlignment.Left, Chart.ColorSettings.ForegroundColor);
}
private void onChartMouseDown(ChartMouseEventArgs args)
{
if (args.AltKey)
{
if (args.ShiftKey && args.CtrlKey)
{
allClose();
}
else
{
if (args.ShiftKey)
{
netProfitOnlyClose();
}
else if (args.CtrlKey)
{
netLossOnlyClose();
}
}
}
else
{
if (args.ShiftKey)
{
entry(TradeType.Buy);
}
else if (args.CtrlKey)
{
entry(TradeType.Sell);
}
}
}
private void entry(TradeType type)
{
var order = ExecuteMarketOrder(type, SymbolName, Volume, label, StopLossPips, TakeProfitPips);
if (!order.IsSuccessful)
{
Print("Error:{0}", order.Error.ToString());
//throw new Exception(order.Error.ToString());
}
}
private void allClose()
{
var positions = Positions.FindAll(label);
foreach (Position p in positions)
{
ClosePosition(p);
}
}
private void netProfitOnlyClose()
{
var positions = Positions.FindAll(label);
foreach (Position p in positions)
{
if (p.NetProfit > 0)
{
ClosePosition(p);
}
}
}
private void netLossOnlyClose()
{
var positions = Positions.FindAll(label);
foreach (Position p in positions)
{
if (p.NetProfit < 0)
{
ClosePosition(p);
}
}
}
}
}
k0naka1jp
Joined on 25.05.2020
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: SimpletKeyEntry.algo
- Rating: 0
- Installs: 2010
- Modified: 13/10/2021 09:54
Comments
hey good one
Today's students face a lot of problems when they are assigned to write various writing assignments such as essays or essays. So that you do not suffer from a lot of homework, I recommend you to use this Assignmentguru online assignment writing service. This service allows you to save a lot of time and all your writing tasks will be solved without your participation by professional writers.
Different information is provided and useful in many ways in our website.
Read More : Top 10 Best Tiles Company
The information is well given, useful in many ways and a lot of help to me from here. You also know more information about NCT members.
Visit our official website : https://www.indiasolv.in/
Concrete Curing Time: Thanks for Sharing the code. This code increase my knowledge
Greetings, I'm Kyle Taylor, a student with a profound fondness for both sports and travel. When not engrossed in my studies, you'll often find me cycling, a pursuit that not only helps maintain my fitness but also facilitates an active lifestyle. Additionally, I harbor a deep passion for venturing into new locales and immersing myself in various cultures. The thrill of uncovering unfamiliar destinations and embracing diverse cultural experiences profoundly influences and broadens my perspective of the world.