NexusFi: Find Your Edge


Home Menu

 





Need help with a profitable automated trading strategy


Discussion in MultiCharts

Updated
    1. trending_up 9,064 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

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


alex20037 View Post
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.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Better Renko Gaps
The Elite Circle
NexusFi Journal Challenge - April 2024
Feedback and Announcements
Deepmoney LLM
Elite Quantitative GenAI/LLM
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
  #22 (permalink)
hoang101483
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?

Reply With Quote
  #23 (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
Thank you. can this code be applied to PowerLanguage on the Multichart .NET?

I tried but it failed.

This is for Multicharts

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


alex20037 View Post
This is for Multicharts

Alex, Can you code this in PowerLanguage?

I will return your favor with copy of my profitable strategy

Reply With Quote
  #25 (permalink)
 
tradingest's Avatar
 tradingest 
Milan, Italy
 
Experience: Master
Platform: NT8
Trading: Futures, Forex
Posts: 111 since Dec 2014
Thanks Given: 9
Thanks Received: 11


hoang101483 View Post
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

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


tradingest View Post
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.

Reply With Quote
  #27 (permalink)
hoang101483
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?

Reply With Quote
  #28 (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
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();
}

}
}
}

Reply With Quote
  #29 (permalink)
hoang101483
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?

Reply With Quote
  #30 (permalink)
hoang101483
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?

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