NexusFi: Find Your Edge


Home Menu

 





Need help with a profitable automated trading strategy


Discussion in MultiCharts

Updated
    1. trending_up 9,057 views
    2. thumb_up 0 thanks given
    3. group 5 followers
    1. forum 41 posts
    2. attach_file 2 attachments




 
Search this Thread

Need help with a profitable automated trading strategy

  #31 (permalink)
 alex20037 
Miami Lakes
 
Experience: Beginner
Platform: Multicharts
Broker: Interactive Brokers
Trading: Emini ES
Posts: 19 since Oct 2016
Thanks Given: 2
Thanks Received: 3


hoang101483 View Post
It said build suceeded, but still have that RED icon next two the signal icon list. does it works on your computer? Perhaps I need to reboot mine?

It works for me just fine. See attached, you should be able to unzip and import it to your Multicharts.NET. I have the latest version.

Attached Files
Elite Membership required to download: BB.zip
Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
Exit Strategy
NinjaTrader
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
Are there any eval firms that allow you to sink to your …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
65 thanks
Funded Trader platforms
40 thanks
Battlestations: Show us your trading desks!
29 thanks
NexusFi site changelog and issues/problem reporting
23 thanks
The Program
19 thanks

  #32 (permalink)
hoang101483
Oklahoma City USA
 
Posts: 47 since Oct 2016
Thanks Given: 0
Thanks Received: 1


alex20037 View Post
It works for me just fine. See attached, you should be able to unzip and import it to your Multicharts.NET. I have the latest version.

Thanks Alex,

It is working now. One small issue. If you open the default BB LE and SE it will basically reverse at each signal. Can we do exactly that?

Your code basically have entry long, exit long and vice versa instead of reversal at each signal. If you add the signal to the chart, you will see what I'm talking about. I wonder if you code each signal on a separate file would fix this issue. Let me know if you can fix this.

Reply With Quote
  #33 (permalink)
 alex20037 
Miami Lakes
 
Experience: Beginner
Platform: Multicharts
Broker: Interactive Brokers
Trading: Emini ES
Posts: 19 since Oct 2016
Thanks Given: 2
Thanks Received: 3



hoang101483 View Post
Thanks Alex,

It is working now. One small issue. If you open the default BB LE and SE it will basically reverse at each signal. Can we do exactly that?

Your code basically have entry long, exit long and vice versa instead of reversal at each signal. If you add the signal to the chart, you will see what I'm talking about. I wonder if you code each signal on a separate file would fix this issue. Let me know if you can fix this.

See attached now. I can't get it to actually show the reverse in the chart, show 2 contracts instead of 1, that'll be something to look into later on when we have good numbers. But you can see that it is doing it, if you see the performance report for example. So if it is long one contract it sells it and short sells a second one, if it is short then it covers it and then buys another one.

Attached Files
Elite Membership required to download: BBv2.zip
Reply With Quote
  #34 (permalink)
hoang101483
Oklahoma City USA
 
Posts: 47 since Oct 2016
Thanks Given: 0
Thanks Received: 1

Alex,

thanks for that. i think you misunderstood me. you see how the default bb has LE and SE. what we can do is spliting up the BB file into two file. one foe LE LX, another for SE and SX. this way we have perfect reversal I hope. let me know if you can do it

Reply With Quote
  #35 (permalink)
 alex20037 
Miami Lakes
 
Experience: Beginner
Platform: Multicharts
Broker: Interactive Brokers
Trading: Emini ES
Posts: 19 since Oct 2016
Thanks Given: 2
Thanks Received: 3


hoang101483 View Post
Alex,

thanks for that. i think you misunderstood me. you see how the default bb has LE and SE. what we can do is spliting up the BB file into two file. one foe LE LX, another for SE and SX. this way we have perfect reversal I hope. let me know if you can do it

Splitting in two files won't make a difference, code is still the same. I will look into it when I have a chance, however this is for sure doing now what we want to, see the strategy performance report please, it does reverse, only doesn't show in the chart.
I was looking and also the you see how the default bb LE and SE that come with multicharts also behave like this, they do reverse, but the chart only shows the new open order.

Reply With Quote
  #36 (permalink)
hoang101483
Oklahoma City USA
 
Posts: 47 since Oct 2016
Thanks Given: 0
Thanks Received: 1

Alex,

I got it to work. Here is the code

using System;

namespace PowerLanguage.Strategy
{
public class BB : SignalObject
{
private IOrderMarket m_BBandLE;
private IOrderMarket m_BBandLX;
private IOrderMarket m_BBandSE;
private IOrderMarket m_BBandSX;

public BB(object ctx) :
base(ctx)
{
Length = 20;
NumDevsDn = 2;
}

[Input]
public int Length { get; set; }

[Input]
public double NumDevsDn { get; set; }

private VariableSeries<double> m_LowerBand;
private VariableSeries<double> m_UpperBand;

protected override void Create()
{
m_LowerBand = new VariableSeries<Double>(this);
m_UpperBand = new VariableSeries<Double>(this);
m_BBandLE = OrderCreator.MarketNextBar(new SOrderParameters(Contracts.Default, "BBandLE", EOrderAction.Buy));
m_BBandLX = OrderCreator.MarketNextBar(new SOrderParameters(Contracts.Default, "BBandLX", EOrderAction.SellShort));
m_BBandSE = OrderCreator.MarketNextBar(new SOrderParameters(Contracts.Default, "BBandSE", EOrderAction.SellShort));
m_BBandSX = OrderCreator.MarketNextBar(new SOrderParameters(Contracts.Default, "BBandSX", EOrderAction.Buy));
}

protected override void CalcBar()
{
m_LowerBand.Value = Bars.Close.BollingerBandCustom(Length, -NumDevsDn);
m_UpperBand.Value = Bars.Close.BollingerBandCustom(Length, NumDevsDn);

if (CurrentPosition.Value == 0) {
if (Bars.CurrentBar > 1 && Bars.Close.CrossesOver(m_LowerBand, ExecInfo.MaxBarsBack))
m_BBandLE.Send();
if (Bars.CurrentBar > 1 && Bars.Close.CrossesUnder(m_UpperBand, ExecInfo.MaxBarsBack))
m_BBandSE.Send();
}

if (CurrentPosition.Value > 0) {
if (Bars.CurrentBar > 1 && Bars.Close.CrossesUnder(m_UpperBand, ExecInfo.MaxBarsBack))
m_BBandLX.Send();
}
if (CurrentPosition.Value < 0) {
if (Bars.CurrentBar > 1 && Bars.Close.CrossesOver(m_LowerBand, ExecInfo.MaxBarsBack))
m_BBandSX.Send();
}

}
}
}

Reply With Quote
  #37 (permalink)
 alex20037 
Miami Lakes
 
Experience: Beginner
Platform: Multicharts
Broker: Interactive Brokers
Trading: Emini ES
Posts: 19 since Oct 2016
Thanks Given: 2
Thanks Received: 3

I guess now the question is, how do we make this profitable long term?

Reply With Quote
  #38 (permalink)
hoang101483
Oklahoma City USA
 
Posts: 47 since Oct 2016
Thanks Given: 0
Thanks Received: 1

argh. never mind. It did create a double order. so That code didn't work

Reply With Quote
  #39 (permalink)
hoang101483
Oklahoma City USA
 
Posts: 47 since Oct 2016
Thanks Given: 0
Thanks Received: 1

Alex,

I think the issue is somewhere here.

protected override void CalcBar()
{
m_LowerBand.Value = Bars.Close.BollingerBandCustom(Length, -NumDevsDn);
m_UpperBand.Value = Bars.Close.BollingerBandCustom(Length, NumDevsDn);

if (CurrentPosition.Value == 0) {
if (Bars.CurrentBar > 1 && Bars.Close.CrossesOver(m_LowerBand, ExecInfo.MaxBarsBack))
m_BBandLE.Send();
if (Bars.CurrentBar > 1 && Bars.Close.CrossesUnder(m_UpperBand, ExecInfo.MaxBarsBack))
m_BBandSE.Send();
}

if (CurrentPosition.Value > 0) {
if (Bars.CurrentBar > 1 && Bars.Close.CrossesUnder(m_UpperBand, ExecInfo.MaxBarsBack))
m_BBandLX.Send();
}
if (CurrentPosition.Value < 0) {
if (Bars.CurrentBar > 1 && Bars.Close.CrossesOver(m_LowerBand, ExecInfo.MaxBarsBack))
m_BBandSX.Send();
}

}
}
}

Reply With Quote
  #40 (permalink)
hoang101483
Oklahoma City USA
 
Posts: 47 since Oct 2016
Thanks Given: 0
Thanks Received: 1


I think I might have fixed the issue by getting rid of the position argument all together

using System;

namespace PowerLanguage.Strategy
{
public class BB : SignalObject
{
private IOrderMarket m_BBandLE;
private IOrderMarket m_BBandLX;
private IOrderMarket m_BBandSE;
private IOrderMarket m_BBandSX;

public BB(object ctx) :
base(ctx)
{
Length = 20;
NumDevsDn = 2;
}

[Input]
public int Length { get; set; }

[Input]
public double NumDevsDn { get; set; }

private VariableSeries<double> m_LowerBand;
private VariableSeries<double> m_UpperBand;

protected override void Create()
{
m_LowerBand = new VariableSeries<Double>(this);
m_UpperBand = new VariableSeries<Double>(this);
m_BBandLE = OrderCreator.MarketNextBar(new SOrderParameters(Contracts.Default, "BBandLE", EOrderAction.Buy));
m_BBandLX = OrderCreator.MarketNextBar(new SOrderParameters(Contracts.Default, "BBandLX", EOrderAction.SellShort));
m_BBandSE = OrderCreator.MarketNextBar(new SOrderParameters(Contracts.Default, "BBandSE", EOrderAction.Sell));
m_BBandSX = OrderCreator.MarketNextBar(new SOrderParameters(Contracts.Default, "BBandSX", EOrderAction.BuyToCover));
}

protected override void CalcBar()
{
m_LowerBand.Value = Bars.Close.BollingerBandCustom(Length, -NumDevsDn);
m_UpperBand.Value = Bars.Close.BollingerBandCustom(Length, NumDevsDn);


if (Bars.CurrentBar > 1 && Bars.Close.CrossesOver(m_LowerBand, ExecInfo.MaxBarsBack))
m_BBandLE.Send();
if (Bars.CurrentBar > 1 && Bars.Close.CrossesUnder(m_UpperBand, ExecInfo.MaxBarsBack))
m_BBandSE.Send();
if (Bars.CurrentBar > 1 && Bars.Close.CrossesUnder(m_UpperBand, ExecInfo.MaxBarsBack))
m_BBandLX.Send();
if (Bars.CurrentBar > 1 && Bars.Close.CrossesUnder(m_UpperBand, ExecInfo.MaxBarsBack))
m_BBandLX.Send();
}



}
}

Reply With Quote





Last Updated on October 26, 2016


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts