0% found this document useful (0 votes)
107 views3 pages

Trendy v3.1 Trading Strategy Code

trading strategy

Uploaded by

fornabin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
107 views3 pages

Trendy v3.1 Trading Strategy Code

trading strategy

Uploaded by

fornabin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

#region Using declarations

using System;
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
#endregion

/*
Trendy v3.0 MA
Version: 3.0 Oct 19, 2024
Strategy by Khanh Nguyen
*/

namespace [Link]
{
public class Trendy31 : KCAlgoBase
{
// Strategy variables
private T3TrendFilter T3TrendFilter1;
private double Up;
private double Down;

protected override void OnStateChange()


{
[Link]();

if (State == [Link])
{
Description = "Strategy based on the T3TrendFilter indicator.";
Name = "Trendy v3.1";
StrategyName = "Trendy";
Version = "3.1 Nov. 2024";
Credits = "Strategy by Khanh Nguyen";
StrategySettings = "Unirenko 1-44-46";

Contracts = 1;
InitialStop = 62;
ProfitTarget = 16;
// Filter settings
Factor = 0.5;
Period1 = 1;
Period2 = 1;
Period3 = 1;
Period4 = 1;
Period5 = 9;
}
else if (State == [Link])
{
InitializeIndicators();
}
}

protected override void OnBarUpdate()


{
if (CurrentBars[0] < BarsRequiredToTrade)
return;

// Update trend filter values


Up = [Link][0][0];
Down = [Link][1][0];

[Link]();
}

protected override bool validateEntryLong()


{
// Validate long entry based on T3TrendFilter
return Up >= 5 && Down == 0 && Uptrend;
}

protected override bool validateEntryShort()


{
// Validate short entry based on T3TrendFilter
return Down <= -5 && Up == 0 && Downtrend;
}

protected override bool validateExitLong()


{
// Logic for validating long exits
// return isLong && momoDown;
return false;
}

protected override bool validateExitShort()


{
// Logic for validating short exits
// return isShort && momoUp;
return false;
}

#region Indicators
protected override void InitializeIndicators()
{
// Initialize the T3TrendFilter indicator
T3TrendFilter1 = T3TrendFilter(Close, Factor, Period1, Period2,
Period3, Period4, Period5, false);
AddChartIndicator(T3TrendFilter1);
}
#endregion

#region Properties

[NinjaScriptProperty]
[Display(Name = "Factor", Order = 1, GroupName = "04. Filters Settings -
T3TrendFilter")]
public double Factor { get; set; }

[NinjaScriptProperty]
[Display(Name = "Period1", Order = 2, GroupName = "04. Filters Settings -
T3TrendFilter")]
public int Period1 { get; set; }

[NinjaScriptProperty]
[Display(Name = "Period2", Order = 3, GroupName = "04. Filters Settings -
T3TrendFilter")]
public int Period2 { get; set; }

[NinjaScriptProperty]
[Display(Name = "Period3", Order = 4, GroupName = "04. Filters Settings -
T3TrendFilter")]
public int Period3 { get; set; }

[NinjaScriptProperty]
[Display(Name = "Period4", Order = 5, GroupName = "04. Filters Settings -
T3TrendFilter")]
public int Period4 { get; set; }

[NinjaScriptProperty]
[Display(Name = "Period5", Order = 6, GroupName = "04. Filters Settings -
T3TrendFilter")]
public int Period5 { get; set; }

#endregion
}
}

You might also like