Dark Theme
Light Theme
Trading Articles
Article Categories
Article Tools
Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to
register in order to view the content of the threads and start contributing to our community.
It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Updated October 26, 2016
trending_up
9,990 views
thumb_up
0 thanks given
group
5 followers
forum
41 posts
attach_file
2 attachments
October 25th, 2016, 03:54 PM
Oklahoma City USA
Posts: 47 since Oct 2016
Thanks Given: 0
Thanks Received: 1
alex20037
I think this is what you are looking for:
inputs:
Length( 20 ),
NumDevs( 2 ) ;
variables:
UpperBand( 0 ),
LowerBand( 0 );
UpperBand = BollingerBand( Close, Length, NumDevs );
LowerBand = BollingerBand( Close, Length, -NumDevs );
condition1 = CurrentBar > 1 and Close crosses over UpperBand;
if condition1 then
Buy ( "BB_LE" ) next bar at market;
condition2 = CurrentBar > 1 and Close crosses under LowerBand;
if condition2 then
Sell Short ( "BB_SE" ) next bar at market;
if (MarketPosition = 1) then
begin
if (Close crosses under UpperBand) then sell ("BB_LX") next bar at market;
end;
if (MarketPosition = -1) then
begin
if (Close crosses over LowerBand) then buytocover ("BB_SX") next bar at market;
end;
However, I don't think it can profitable with such simple rules, in any timeframe. It would be too easy.
Thank you. can this code be applied to PowerLanguage on the Multichart .NET?
I tried but it failed.
Can you help answer these questions from other members on NexusFi?
Best Threads (Most Thanked) in the last 7 days on NexusFi
October 25th, 2016, 04:06 PM
Oklahoma City USA
Posts: 47 since Oct 2016
Thanks Given: 0
Thanks Received: 1
This code doesn't seem to work with PowerLanguage Editor. I tried to added as Signals using C# and VB#NET but both failed. Can you tell me what I'm doing wrong here?
October 25th, 2016, 04:23 PM
Miami Lakes
Experience: Beginner
Platform: Multicharts
Broker: Interactive Brokers
Trading: Emini ES
Posts: 19 since Oct 2016
Thanks Given: 2
Thanks Received: 3
hoang101483
Thank you. can this code be applied to PowerLanguage on the Multichart .NET?
I tried but it failed.
This is for Multicharts
October 25th, 2016, 04:27 PM
Oklahoma City USA
Posts: 47 since Oct 2016
Thanks Given: 0
Thanks Received: 1
alex20037
Alex, Can you code this in PowerLanguage?
I will return your favor with copy of my profitable strategy
October 25th, 2016, 06:41 PM
Milan, Italy
Experience: Master
Platform: NT8
Trading: Futures, Forex
Posts: 111 since Dec 2014
Thanks Given: 9
Thanks Received: 11
hoang101483
Alex, Can you code this in PowerLanguage?
The code offered by Alex is power language. You have need the C# code to run the strategy in .NET platform
Sent using the NexusFi mobile app
October 25th, 2016, 07:56 PM
Oklahoma City USA
Posts: 47 since Oct 2016
Thanks Given: 0
Thanks Received: 1
tradingest
The code offered by Alex is power language. You have need the C# code to run the strategy in .NET platform
Sent using the
NexusFi mobile app
Tradingest,
Thanks for the clarification. The editor named powerlanguage so I thought that what it is. Great to know.
October 25th, 2016, 07:58 PM
Oklahoma City USA
Posts: 47 since Oct 2016
Thanks Given: 0
Thanks Received: 1
I was able to get the code kinda work. But need further refinement. You can find the thread here. Can you help?
October 25th, 2016, 09:08 PM
Miami Lakes
Experience: Beginner
Platform: Multicharts
Broker: Interactive Brokers
Trading: Emini ES
Posts: 19 since Oct 2016
Thanks Given: 2
Thanks Received: 3
hoang101483
Tradingest,
Thanks for the clarification. The editor named powerlanguage so I thought that what it is. Great to know.
No problem here is the code in C# . I am really interested in seeing how you can get this strategy to work, please do share the results with me.
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.Sell));
m_BBandSE = OrderCreator.MarketNextBar(new SOrderParameters(Contracts.Default, "BBandSE", EOrderAction.SellShort));
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 (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();
}
}
}
}
October 25th, 2016, 09:50 PM
Oklahoma City USA
Posts: 47 since Oct 2016
Thanks Given: 0
Thanks Received: 1
Thanks Alex,
I compiled it, didn't give back an error, but It still show Unverified.
Can you double check the code to see if we missing anything?
October 25th, 2016, 09:58 PM
Oklahoma City USA
Posts: 47 since Oct 2016
Thanks Given: 0
Thanks Received: 1
It said build suceeded, but still have that RED icon next to the signal icon on the list on the left hand. does it work on your computer? Perhaps I need to reboot mine?
Last Updated on October 26, 2016