Help with this multicharts.net strategy - MultiCharts | futures.io
futures.io futures trading
 

Go Back   futures.io

> Futures Trading, News, Charts and Platforms > Platforms and Indicators > MultiCharts


Help with this multicharts.net strategy
Started:November 10th, 2016 (03:20 AM) by alex20037 Views / Replies:175 / 1
Last Reply:November 10th, 2016 (04:38 AM) Attachments:0

Welcome to futures.io.

Welcome, Guest!

This forum was established to help traders (especially futures traders) by openly sharing indicators, strategies, methods, trading journals and discussing the psychology of trading.

We are fundamentally different than most other trading forums:
  • We work extremely hard to keep things positive on our forums.
  • We do not tolerate rude behavior, trolling, or vendor advertising in posts.
  • We firmly believe in openness and encourage sharing. The holy grail is within you, it is not something tangible you can download.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.


You'll need to register in order to view the content of the threads and start contributing to our community. It's free and simple, and we will never resell your private information.

-- Big Mike
     

Reply
 
Thread Tools Search this Thread

Help with this multicharts.net strategy

Old November 10th, 2016, 03:20 AM   #1 (permalink)
Elite Member
Miami Lakes
 
Futures Experience: Beginner
Platform: Multicharts
Broker/Data: Interactive Brokers
Favorite Futures: Emini ES
 
Posts: 18 since Oct 2016
Thanks: 2 given, 3 received

Help with this multicharts.net strategy

Hi everyone,

I am working on this strategy and need help figuring this out please. The strategy begins with opening up a position either long or short doesn't matter. Set a target profit and a stop loss and send the profit and stop orders right away. If target profit is reached, then exit and wait for another position to be opened (manually). If the stop loss is reached, then it should close the initial position, and then open up twice as many contracts in the opposite direction, and this is where I need help. The stop works fine, but I haven't been able to figure out how to send those twice as many contracts. This is what I have so far.

With this line

stoLongToShort.Send(takeReversePrice,takeReversePrice,orderSize*2);

stoLongToShort is a stop limit order, I am attempting to enter the reverse position, but the order just won't go through. I am sure I am missing something. Please help, thanks in advance.


using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;
using ATCenterProxy.interop;

namespace PowerLanguage.Strategy {

[IOGMode(IOGMode.Enabled)]
public class ProfitTaker : SignalObject
{
private IOrderMarket bto,sto;
private IOrderPriced stcProfitLong, btcProfitShort;
private IOrderStopLimit stcStopLong, btcStopShort, stoLongToShort, btoShortToLong;
private double takeProfitPrice, takeReversePrice;

int orderSize = 0;
int maxEntriesInPosition = 10;
int maxOrderSize = 1000;

[Input]
public int ProfitTicks { get; set; }
[Input]
public int StopTicks { get; set; }

public ProfitTaker(object _ctx) : base(_ctx) { }

private bool bracketSet;

protected override void Create() {

bto = OrderCreator.MarketThisBar(new SOrderParameters(Contracts.UserSpecified, "Buy", EOrderAction.Buy));
sto = OrderCreator.MarketThisBar(new SOrderParameters(Contracts.UserSpecified, "SellShort", EOrderAction.SellShort));

stcProfitLong = OrderCreator.Limit(new SOrderParameters(Contracts.UserSpecified, "TakeProfitLong", EOrderAction.Sell));
stcStopLong = OrderCreator.StopLimit(new SOrderParameters(Contracts.UserSpecified, "StopLong", EOrderAction.Sell));
stoLongToShort = OrderCreator.StopLimit(new SOrderParameters(Contracts.UserSpecified, "LongToShort", EOrderAction.SellShort));

btcProfitShort = OrderCreator.Limit(new SOrderParameters(Contracts.UserSpecified, "TakeProfitShort", EOrderAction.BuyToCover));
btcStopShort = OrderCreator.StopLimit(new SOrderParameters(Contracts.UserSpecified, "StopReverseShort", EOrderAction.BuyToCover));
btoShortToLong = OrderCreator.StopLimit(new SOrderParameters(Contracts.UserSpecified, "ShortToLong", EOrderAction.Buy));

ProfitTicks = 24;
StopTicks = 8;
}

protected override void StartCalc() {
Output.Clear();
}

protected override void CalcBar() {

if (StrategyInfo.MarketPosition == 0 && StrategyInfo.MarketPositionAtBroker != 0) {
ChangeMarketPosition(StrategyInfo.MarketPositionAtBroker - StrategyInfo.MarketPosition, StrategyInfo.AvgEntryPriceAtBroker);
Output.WriteLine("{0} - Sync with broker", Bars.Time[0].ToString("d-M HH:mm"));
}

if (StrategyInfo.MarketPosition == 0) {
orderSize = 1;
} else {
orderSize = Math.Min(CurrentPosition.OpenLots, maxOrderSize);
}

if (StrategyInfo.MarketPosition > 0) {

int barsInPosition = Bars.CurrentBar - Positions[0].OpenTrades[0].EntryOrder.BarNumber;
if (barsInPosition == 0) {
takeProfitPrice = Positions[0].OpenTrades[0].EntryOrder.Price + (ProfitTicks * (Bars.Info.MinMove / Bars.Info.PriceScale));
takeReversePrice = Positions[0].OpenTrades[0].EntryOrder.Price - (StopTicks * (Bars.Info.MinMove / Bars.Info.PriceScale));
}

stcProfitLong.Send(takeProfitPrice,orderSize);
stcStopLong.Send(takeReversePrice,takeReversePrice,orderSize);
stoLongToShort.Send(takeReversePrice,takeReversePrice,orderSize*2);

}

if (StrategyInfo.MarketPosition < 0) {

int barsInPosition = Bars.CurrentBar - Positions[0].OpenTrades[0].EntryOrder.BarNumber;
if (barsInPosition == 0) {
takeProfitPrice = Positions[0].OpenTrades[0].EntryOrder.Price - (ProfitTicks * (Bars.Info.MinMove / Bars.Info.PriceScale));
takeReversePrice = Positions[0].OpenTrades[0].EntryOrder.Price + (StopTicks * (Bars.Info.MinMove / Bars.Info.PriceScale));
}

btcProfitShort.Send(takeProfitPrice,orderSize);
btcStopShort.Send(takeReversePrice,takeReversePrice,orderSize);
btoShortToLong.Send(takeReversePrice,takeReversePrice,orderSize*2);

}

}
}
}

Reply With Quote
     

Old November 10th, 2016, 04:38 AM   #2 (permalink)
 Vendor: abctradinggroup.com 
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,151 since Apr 2013
Thanks: 191 given, 648 received

alex20037,

you might want to add output statements to check that you send the correct prices etc. for the orders.

What do you intend with "OrderCreator.MarketThisBar"? Seeing that you use IOG, is there a reason for not using "OrderCreator.MarketNextBar"? 4.6.9 Advanced. How The Strategy Backtesting Engine works - MultiCharts

I am not saying you shouldn't use it, but if you do, think about how this affects your code. Especially when you check for something like "barsInPosition == 0".

One thing that I would suggest not to do is sending a stop and an entry order (with twice the size) at the same price. Worst case is that you get filled on both and get an overfill - the reverse orders as you have coded them will exit your position and set you short/long twice the amount. On top of that your exit orders close the open position, too. The result in realtime could be that you are long three times the open short position now (or vice versa).

Regards,

ABCTG

Reply With Quote
     

Reply



futures.io > Futures Trading, News, Charts and Platforms > Platforms and Indicators > MultiCharts > Help with this multicharts.net strategy

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)
 

Trading Technologies: ADL hands-on

Dec 13

Normal webinar schedule resumes after the holidays

January

Ernie Chan: Risk Management

Elite only

Dedicated Trading Servers: Advantages/Disadvantages w/sam028

Elite only

An Afternoon with FIO member Massive I

Elite only

Leo Murphy: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
strategy with EMA and range - comaprison of codes in MultiCharts /.NET / AmiBroker jamesfisher MultiCharts 0 May 28th, 2016 12:37 PM
Convert code from multicharts(ELD) to Multicharts.NET rmiller863 MultiCharts 4 May 21st, 2016 10:16 AM
Multicharts and MultiCharts.NET 9.1 Beta 2 Aufidius MultiCharts 0 August 24th, 2015 01:05 AM
MultiCharts and MultiCharts.NET 9.1 Beta 1 panz MultiCharts 1 August 5th, 2015 12:47 PM
MultiCharts and MultiCharts .NET: where are indicators more performant? GoSlow MultiCharts 3 February 3rd, 2014 02:33 AM


All times are GMT -4. The time now is 06:44 AM.

Copyright © 2016 by futures.io. 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.
 
no new posts
Page generated 2016-12-10 in 0.08 seconds with 19 queries on phoenix via your IP 54.166.37.177