Description
USING PSAR. This robot checks for positive corelation in trend between EURUSD, USDJPY, EURJPY. if they are both trending upwards then we buy because it is a strong uptrend.
currently i used PARABORIC SAR: the current psar is below price on both at the same time EURUSD, USDJPY, EURJPY. it buys. and vice versa.
suggestions accepted.
I really need your comments they encourage me to post these bots i had beed developing and couldnt continue alone.
using System;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
public class PsarBot : Robot
{
private readonly string[] symbolNames = { "EURUSD", "USDJPY", "EURJPY" };
private readonly TimeFrame timeFrame = TimeFrame.Minute15;
private MarketSeries[] symbolSeries;
private ParabolicSAR[] parabolicSARs;
protected override void OnStart()
{
symbolSeries = new MarketSeries[symbolNames.Length];
parabolicSARs = new ParabolicSAR[symbolNames.Length];
for (int i = 0; i < symbolNames.Length; i++)
{
Symbol symbol = MarketData.GetSymbol(symbolNames[i]);
if (symbol == null)
{
Print($"Error: Symbol {symbolNames[i]} does not exist");
continue;
}
symbolSeries[i] = MarketData.GetSeries(symbol, TimeFrame.Minute15);
parabolicSARs[i] = Indicators.ParabolicSAR(symbolSeries[i], 0.02, 0.2);
}
}
protected override void OnBar()
{
for (int i = 0; i < symbolNames.Length; i++)
{
Symbol symbol = MarketData.GetSymbol(symbolNames[i]);
double psarValue = parabolicSARs[i].Result.Last(0);
double bid = symbol.Bid;
if (psarValue < bid)
{
ExecuteMarketOrder(TradeType.Buy, symbol, 1000, "PSAR Buy", 0, 10);
}
else if (psarValue > bid)
{
ExecuteMarketOrder(TradeType.Sell, symbol, 1000, "PSAR Sell", 0 , 10);
}
}
}
}
}
DA
davidmwabuka
Joined on 07.03.2023
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: POSITIVE correlation EURUSD, USDJPY, EURJPY.algo
- Rating: 0
- Installs: 830
- Modified: 16/05/2023 11:18
Warning! Running cBots downloaded from this section may lead to financial losses. Use them at your own risk.
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.
Interesting Strategy. the same concept could be applied to Pair Trading especially EURUSD GBPUSD. For example a PSAR above EURUSD and below GBPUSD, you sell EURUSD and buy GBPUSD. maybe ill try coding this later. Cheers!