Optimizer problem
6 replies
chuso
7 years ago #116198
Hello, I have a problem with Optimizer.
When I set on Put values to parameters It shows new parameters for each Bolinger Band, and I want the same parameter (Period and Std dev) in all bands.
pBB_UP_5 and pBB_UP_6, and pBB_UP_8 and pBB_UP_9 shud be the same than pBB_UP_2 and pBB_UP_3.
I only want 2 parameters, not 6.
I atached you the ninja code.
Regards.
tomas262
7 years ago #141084
chuso
7 years ago #141089
Hello, this is the code:
/*
NinjaTrader Strategy of Original strategy
Generated by StrategyQuant version 3.8.1
Generated at Fri Jan 20 10:46:00 GMT 2017
Tested on NG, M15, 30.06.2003 – 15.12.2016
Spread: 1.0, Slippage: 2.5, Min distance of stop from price: 0.0
*/
#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Indicator;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Strategy;
#endregion
namespace NinjaTrader.Strategy
{
///
/// Enter the description of your strategy here
///
[Description(“Enter the description of your strategy here”)]
public class Originalstrategy : SQManagedStrategy
{
#region Variables
// Wizard generated variables
protected int _pBB_UP_2 = 100;
protected int _pBB_UP_3 = 2;
protected int _pBB_UP_4 = 0;
protected int _pBB_UP_5 = 100;
protected int _pBB_UP_6 = 2;
protected int _pBB_UP_7 = 0;
protected int _pBB_UP_8 = 100;
protected int _pBB_UP_9 = 2;
protected int _pBB_UP_10 = 1;
protected double _StopLossPips = 70;
protected double _ProfitTargetPips = 140;
// User defined variables (add any user defined variables below)
#endregion
///
/// This method is used to configure the strategy and is called once before any strategy method is called.
///
protected override void Initialize()
{
base.Initialize();
ReplacePendingOrders = false;
ExitOnClose = true;
MinimumPTSL = 30;
MaximumPTSL = 300;
PendingOrderValidOneBar = false;
BarsRequired = 120;
StrictStopPrices = true;
LimitSignalsToRange = true;
TimeRangeFrom = 1000;
TimeRangeTo = 2000;
// Strategy Parameters
pBB_UP_2 = 100;
pBB_UP_3 = 2;
pBB_UP_4 = 0;
pBB_UP_5 = 100;
pBB_UP_6 = 2;
pBB_UP_7 = 0;
pBB_UP_8 = 100;
pBB_UP_9 = 2;
pBB_UP_10 = 1;
StopLossPips = 70;
ProfitTargetPips = 140;
MaxTradesPerDay = 0; // 0 means unlimited
}
///
/// Called on each bar update event (incoming tick)
///
protected override void OnBarUpdate()
{
// ——————————————
// STRATEGY MANAGEMENT
// ——————————————
if(Bars.FirstBarOfSession) tradesPerDay = 0;
// Stop/Limit order expiration handling
// Long ——–
if(pendingEntryOrder != null && pendingEntryOrder.OrderAction == OrderAction.Buy) {
}
// Short ——–
if(pendingEntryOrder != null && pendingEntryOrder.OrderAction == OrderAction.SellShort) {
}
// ——————————————
// ENTRY RULES
// ——————————————
tradeEntered = false;
if(sqCheckTimeWithinRange()) {
// Long ——–
if(maxTradesPerDay == 0 || tradesPerDay sqBBUp(pBB_UP_2, pBB_UP_3, pBB_UP_4, 0)) && (sqBBUp(pBB_UP_5, pBB_UP_6, pBB_UP_7, 0) > sqBBUp(pBB_UP_8, pBB_UP_9, pBB_UP_10, 0)));
if(LongEntryCondition == true) {
if(Position.MarketPosition == MarketPosition.Flat) {
sqEnterLong();
}
}
}
// Short ——–
if(maxTradesPerDay == 0 || tradesPerDay < maxTradesPerDay) {
bool ShortEntryCondition = ((Close[0] < sqBBUp(pBB_UP_2, pBB_UP_3, pBB_UP_4, 0)) && (sqBBUp(pBB_UP_5, pBB_UP_6, pBB_UP_7, 0) < sqBBUp(pBB_UP_8, pBB_UP_9, pBB_UP_10, 0)));
if(ShortEntryCondition == true) {
if(Position.MarketPosition == MarketPosition.Flat) {
sqEnterShort();
}
}
}
}
}
override protected void sqDefineStopLoss(int direction) {
stopLoss.type = CalculationMode.Ticks;
if(direction == 1) {
// long
stopLoss.value = StopLossPips;
} else {
// short
stopLoss.value = StopLossPips;
}
}
override protected void sqDefineProfitTarget(int direction) {
profitTarget.type = CalculationMode.Ticks;
if(direction == 1) {
// long
profitTarget.value = ProfitTargetPips;
} else {
// short
profitTarget.value = ProfitTargetPips;
}
}
#region Properties
[Description("")]
[GridCategory("Strategy Parameters")]
public int pBB_UP_2
{
get { return _pBB_UP_2; }
set { _pBB_UP_2 = value; }
}
[Description("")]
[GridCategory("Strategy Parameters")]
public int pBB_UP_3
{
get { return _pBB_UP_3; }
set { _pBB_UP_3 = value; }
}
[Description("")]
[GridCategory("Strategy Parameters")]
public int pBB_UP_4
{
get { return _pBB_UP_4; }
set { _pBB_UP_4 = value; }
}
[Description("")]
[GridCategory("Strategy Parameters")]
public int pBB_UP_5
{
get { return _pBB_UP_5; }
set { _pBB_UP_5 = value; }
}
[Description("")]
[GridCategory("Strategy Parameters")]
public int pBB_UP_6
{
get { return _pBB_UP_6; }
set { _pBB_UP_6 = value; }
}
[Description("")]
[GridCategory("Strategy Parameters")]
public int pBB_UP_7
{
get { return _pBB_UP_7; }
set { _pBB_UP_7 = value; }
}
[Description("")]
[GridCategory("Strategy Parameters")]
public int pBB_UP_8
{
get { return _pBB_UP_8; }
set { _pBB_UP_8 = value; }
}
[Description("")]
[GridCategory("Strategy Parameters")]
public int pBB_UP_9
{
get { return _pBB_UP_9; }
set { _pBB_UP_9 = value; }
}
[Description("")]
[GridCategory("Strategy Parameters")]
public int pBB_UP_10
{
get { return _pBB_UP_10; }
set { _pBB_UP_10 = value; }
}
[Description("")]
[GridCategory("Strategy Parameters")]
public double StopLossPips
{
get { return _StopLossPips; }
set { _StopLossPips = value; }
}
[Description("")]
[GridCategory("Strategy Parameters")]
public double ProfitTargetPips
{
get { return _ProfitTargetPips; }
set { _ProfitTargetPips = value; }
}
#endregion
}
}
tomas262
7 years ago #141124
Hello,
thanks for the code. Can you also provide the STR project file which I could check? You can send to [email protected] alternatively
chuso
7 years ago #141190
Already sent
chuso
7 years ago #141356
tomas262
7 years ago #141368
Viewing 6 replies - 1 through 6 (of 6 total)