Help with this strategy - MultiCharts | futures io social trading
futures io futures trading

Help with this strategy
Updated: Views / Replies:271 / 1
Created: by alex20037 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

Thread Tools Search this Thread

Help with this strategy

  #1 (permalink)
Elite Member
Miami Lakes
Futures Experience: Beginner
Platform: Multicharts
Broker/Data: Interactive Brokers
Favorite Futures: Emini ES
Posts: 19 since Oct 2016
Thanks: 2 given, 3 received

Help with this 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 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 {

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;

public int ProfitTicks { get; set; }
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() {

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));



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));




Reply With Quote
  #2 (permalink)
Elite Member
Hamburg Germany
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
Posts: 1,284 since Apr 2013
Thanks: 203 given, 724 received


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).



Reply With Quote


futures io > > > > Help with this strategy

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

Introducing iSystems with Stage 5 Trading

Apr 27

FIO Journal Challenge featuring NinjaTrader ($2,000+ of prizes)


Prototyping Python Strategies (part 2) w/Ran Aroussi

Elite only

Ask Me Anything w/Raymond Deux @ NinjaTrader

May 3

An Afternoon with FIO member Softsoap

Elite only

Machine Learning & Data Mining Bias w/Kris Longmore @ Robot Wealth

Elite only

Brannigan Barrett (TBA)

Elite only

FIO member Gomi (TBA)

Elite only

FuturesTrader71 (TBA)

Elite only

EasyLanguage Programming w/Chris @ ABC Trading Group

Elite only

Portfolio Diversification w/Brendon Delate

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 11:37 AM
Convert code from multicharts(ELD) to Multicharts.NET rmiller863 MultiCharts 4 May 21st, 2016 09:16 AM
Multicharts and MultiCharts.NET 9.1 Beta 2 Aufidius MultiCharts 0 August 24th, 2015 12:05 AM
MultiCharts and MultiCharts.NET 9.1 Beta 1 panz MultiCharts 1 August 5th, 2015 11:47 AM
MultiCharts and MultiCharts .NET: where are indicators more performant? GoSlow MultiCharts 3 February 3rd, 2014 01:33 AM

All times are GMT -4. The time now is 10:23 PM.

no new posts
Page generated 2017-04-27 in 0.09 seconds with 20 queries on phoenix via your IP