Help with this strategy - futures io
futures io futures trading

Help with this strategy

Discussion in MultiCharts

Updated by ABCTG
    1. trending_up 1,103 views
    2. thumb_up 0 thanks given
    3. group 3 followers
    1. forum 1 replies
    2. attach_file 0 attachments

Welcome to futures io: the largest futures trading community on the planet, with well over 100,000 members
  • 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 and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

Search this Thread

Help with this strategy

(login for full post details)
  #1 (permalink)
Miami Lakes
Experience: Beginner
Platform: Multicharts
Broker: Interactive Brokers
Trading: Emini ES
Posts: 19 since Oct 2016
Thanks: 2 given, 3 received

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

Can you help answer these questions
from other members on futures io?
Show bar number above each tick bar
EasyLanguage Programming
The value of High minus Open and Open minus Low.
Macros for flatten and reverse
3x Fangdango
Traders Hideout
Dollar crash in 2021
Best Threads (Most Thanked)
in the last 7 days on futures io
Coronavirus COVID-19
25 thanks
Lost & losing hope
25 thanks
VWAP for stock index futures trading?
25 thanks
Emini 4 Tick Scalp still valid?
17 thanks
Price Action Kewltech Style
15 thanks
(login for full post details)
  #2 (permalink)
Hamburg Germany
Experience: Advanced
Platform: Multicharts, Tradestation
Broker: DTN IQ
Trading: ES
Posts: 2,199 since Apr 2013
Thanks: 386 given, 1,432 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).



Follow me on Twitter Visit my Facebook Reply With Quote

futures io Trading Community Platforms and Indicators MultiCharts > Help with this strategy

November 10, 2016

Upcoming Webinars and Events

Copyright © 2020 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432,
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